xxxxxxxxxx
55
let t = 0;
let sw = [];
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(5);
let x = 0;
let y = 0;
for (let i = 0; i < 4; i++) {
let prevX = x;
let prevY = y;
let n = i*2+1;
let r = 85 * (4/(n * PI))
x += r * cos(n*t);
y += r * sin(n*t)
push();
translate(200, height/2);
noFill();
strokeWeight(2);
stroke(255, 100);
ellipse(prevX, prevY, r*2);
strokeWeight(2);
stroke(255, 200);
line(prevX, prevY, x, y);
pop();
}
sw.unshift(y);
translate(400, height/2);
strokeWeight(2)
stroke(255, 200);
line(x - 200, y, 0, sw[0]);
beginShape();
noFill();
strokeWeight(4);
stroke(255, 244, 79);
for (let i = 0; i < sw.length; i++) {
vertex(i, sw[i]);
}
endShape();
if (sw.length >= 1500) {
sw.pop();
}
t += 0.02
}