Hello! I am writing a sketch to animate the drawing of a circle (arc); what I would like to do is to change to a random color every time the full arc is drawn, I have so far gotten to change it once only, how to continue this behaviour within the setup draw () loop?
float centerX;
float centerY;
float startArc = 0;
float endArc = 0;
float speed = .0125;
float L1;
float L2;
int r;
int g;
int b;
color c = color(r,g,b);
void setup(){
size (600,600);
}
void draw(){
background(120);
animate();
display();
}
void animate (){
// startArc = startArc + speed;
endArc = endArc + speed;
centerX = width/2;
centerY = height/2;
L1 = width/2;
L2 = height/2;
r = 255;
g = 0;
b = 0;
c = color(r,g,b);
if (endArc >= TWO_PI) {
r = r *-1;
g = r *-1;
b = r *-1;
c = color(r,g,b);
}
}
void display() {
noFill();
stroke(c);
arc(centerX, centerY, L1, L2, startArc, endArc);
}