xxxxxxxxxx
60
let arcs = [];
let b_arcs = [];
let count = 15;
let speed = 3;
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
for (let i=0; i<count; i++){
arcs[i] = new Arc((180/count) * (count - (i)), speed, (i+1)*15);
}
for (let i=0; i<count; i++){
b_arcs[i] = new Arc((180/count) * (count - (i)), speed, (i+1)*15);
}
}
function draw() {
background(0);
translate(width/2, height/2);
push();
rotate(180);
for (let i=0; i<count; i++){
arcs[i].update();
arcs[i].display();
}
pop();
for (let i=0; i<count; i++){
b_arcs[i].update();
b_arcs[i].display();
}
}
class Arc {
constructor(pos, vel, size){
this.pos = pos;
this.vel = vel;
this.size = size;
}
update(){
this.pos = constrain(this.pos, 0, 180);
if (this.pos >= 180 || this.pos <= 0) {
this.vel = this.vel * -1;
}
this.pos = this.pos + this.vel;
}
display(){
noFill();
stroke(255);
strokeWeight(3);
arc(0, 0, this.size, this.size, 0, this.pos);
}
}