xxxxxxxxxx
48
let count = 10;
let spacing = 15;
let start = [];
let vel = [];
let angle = 0;
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
for (let i=0; i<count; i++){
start[i] = 0;
vel[i] =(i+1) * 0.5;
}
}
function draw() {
background(20);
translate(width/2, height/2);
noFill();
strokeWeight(4);
for (let i=0; i<count; i++){
stroke(200, 120*(i/count), 0);
// stroke(120*(i/count), 120, 120);
start[i] = constrain(start[i], 0, 180);
arc(0, 0, (i+1)*spacing, (i+1)*spacing, angle + (-180), angle + (-180 + start[i]));
arc(0, 0, (i+1)*spacing, (i+1)*spacing, angle + 0, angle + start[i]);
if (start[i] <= 0){
vel[i] = vel[i] * -1;
} else if (start[i] >= 180) {
vel[i] = vel[i] * -1;
}
start[i] = start[i] + vel[i];
angle = angle + 0.1;
}
}