Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Archimedean-spiral/JavaScript/archimedean-spiral-1.js
Normal file
24
Task/Archimedean-spiral/JavaScript/archimedean-spiral-1.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<!-- ArchiSpiral.html -->
|
||||
<html>
|
||||
<head><title>Archimedean spiral</title></head>
|
||||
<body onload="pAS(35,'navy');">
|
||||
<h3>Archimedean spiral</h3> <p id=bo></p>
|
||||
<canvas id="canvId" width="640" height="640" style="border: 2px outset;"></canvas>
|
||||
<script>
|
||||
// Plotting Archimedean_spiral aev 3/17/17
|
||||
// lps - number of loops, clr - color.
|
||||
function pAS(lps,clr) {
|
||||
var a=.0,ai=.1,r=.0,ri=.1,as=lps*2*Math.PI,n=as/ai;
|
||||
var cvs=document.getElementById("canvId");
|
||||
var ctx=cvs.getContext("2d");
|
||||
ctx.fillStyle="white"; ctx.fillRect(0,0,cvs.width,cvs.height);
|
||||
var x=y=0, s=cvs.width/2;
|
||||
ctx.beginPath();
|
||||
for (var i=1; i<n; i++) {
|
||||
x=r*Math.cos(a), y=r*Math.sin(a);
|
||||
ctx.lineTo(x+s,y+s);
|
||||
r+=ri; a+=ai;
|
||||
}//fend i
|
||||
ctx.strokeStyle = clr; ctx.stroke();
|
||||
}
|
||||
</script></body></html>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Archimedean spiral</title>
|
||||
<style>h3 {font-family:sans-serif; color:gray;}</style>
|
||||
</head>
|
||||
<body onload="main('red')(15)">
|
||||
<h3>Archimedean spiral</h3></p>
|
||||
<canvas id="spiral" width="640" height="640" style="border: 2px outset;"></canvas>
|
||||
<script>
|
||||
33
Task/Archimedean-spiral/JavaScript/archimedean-spiral-3.js
Normal file
33
Task/Archimedean-spiral/JavaScript/archimedean-spiral-3.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
const main = strColor => intCycles => {
|
||||
const
|
||||
ai = 0.05,
|
||||
ri = 0.1,
|
||||
cvs = document.getElementById('spiral'),
|
||||
ctx = cvs.getContext('2d'),
|
||||
s = cvs.width / 2,
|
||||
|
||||
points = enumFromTo(1)(
|
||||
Math.PI * 2 * intCycles / ai
|
||||
).map(i => [Math.cos, Math.sin].map(
|
||||
f => ri * i * f(ai * i) + s
|
||||
));
|
||||
|
||||
return (
|
||||
console.log(points),
|
||||
ctx.fillStyle = 'white',
|
||||
ctx.fillRect(0, 0, cvs.width, cvs.height),
|
||||
ctx.beginPath(),
|
||||
|
||||
points.forEach(xy => ctx.lineTo(...xy)),
|
||||
|
||||
ctx.strokeStyle = strColor,
|
||||
ctx.stroke(),
|
||||
points
|
||||
);
|
||||
};
|
||||
|
||||
// enumFromTo :: Int -> Int -> [Int]
|
||||
const enumFromTo = m => n =>
|
||||
Array.from({
|
||||
length: 1 + n - m
|
||||
}, (_, i) => m + i);
|
||||
|
|
@ -0,0 +1 @@
|
|||
</script></body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue