forked from zzu-andrew/linux-sys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.js
40 lines (33 loc) · 935 Bytes
/
default.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const pageWidth = document.getElementsByTagName("canvas")[0].clientWidth;
const pageHeight = document.getElementsByTagName("canvas")[0].clientHeight;
const iterations = 8;
const startVectorLength = 75;
const startLinesCount = 3;
const vectorLengthIncrement = 15;
const linesCountIncrement = 1;
const start = new Point(pageWidth / 2, pageHeight / 2);
let iter, linesCount, vectorLength;
const resetAll = () => {
iter = 0;
linesCount = startLinesCount;
vectorLength = startVectorLength;
};
const drawStar = () => {
project.clear();
++iter;
linesCount += linesCountIncrement;
vectorLength += vectorLengthIncrement;
if (iter > iterations) {
resetAll();
}
for (let i = 0; i < linesCount; i++) {
const path = new Path.Line(
start,
(start + [vectorLength, 0]).rotate((360 / linesCount) * i, start)
);
path.strokeColor = "black";
}
};
resetAll();
drawStar();
setInterval(drawStar, 200);