-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
49 lines (43 loc) · 927 Bytes
/
sketch.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
41
42
43
44
45
46
47
48
49
let circles = [];
let nodes = 150;
let multiple = 0.01;
let circleRadius = 250;
const SHOW_NODES = 1;
const NO_NODES = 0;
function setup() {
createCanvas(600, 600);
ellipseMode(RADIUS);
for (let i = 0; i < nodes; i++) {
circles.push(new Circle(i));
}
}
function draw() {
background(255);
translate(width / 2, height / 2);
noFill();
stroke(50);
ellipse(0, 0, circleRadius, circleRadius);
frameRate(60);
for (let i of circles) {
i.show(NO_NODES);
line(
i.x,
i.y,
circles[floor((i.i * multiple) % nodes)].x,
circles[floor((i.i * multiple) % nodes)].y
);
}
multiple += 0.01;
}
function Circle(i) {
this.i = i;
this.x = circleRadius * cos(PI - (TAU / nodes) * this.i);
this.y = circleRadius * sin(PI - (TAU / nodes) * this.i);
this.show = (mode) => {
if (mode == 1) {
noFill();
stroke(50);
circle(this.x, this.y, 1);
}
};
}