xxxxxxxxxx
34
// thecodingtrain.com/discord
let angle = 0;
function setup() {
createCanvas(600, 400);
}
function draw() {
colorMode(HSB);
background(0);
translate(width / 2, height / 2);
stroke(255);
strokeWeight(1);
noFill();
let total = 31;
for (let i = 0; i < total; i++) {
let w = map(i, 0, total, 0, 20) ** 2;
let s = sin(angle);
let offset,y;
if (i < total / 2) {
offset = map(i, 0, total/2, 200, 0);
y = map(s, -1, 1, -offset, offset);
} else {
offset = map(i, total/2, total, 0, 200);
y = map(s, -1, 1, offset, -offset);
}
let h = map(abs(y), 0, offset, w, 4);
stroke(y, 100, 100);
ellipse(0, y, w, h);
}
angle += 0.1;
}