float ANGLE_STEP = PI / 64;
float angle = 0.0;
float targetColorR;
float targetColorG;
float targetColorB;
float currentColorR;
float currentColorG;
float currentColorB;
void setup(){
size(500, 500);
smooth();
frameRate(24);
noStroke();
background(255);
setNewTargetColor();
currentColorR = int(random(256));
currentColorG = int(random(256));
currentColorB = int(random(256));
}
void setNewTargetColor(){
targetColorR = int(random(256));
targetColorG = int(random(256));
targetColorB = int(random(256));
}
void draw(){
if(currentColorR == targetColorR && currentColorG == targetColorG && currentColorB == targetColorB){
setNewTargetColor();
}
if(currentColorR < targetColorR){
currentColorR += 1;
} else if(currentColorR > targetColorR){
currentColorR -= 1;
}
if(currentColorG < targetColorG){
currentColorG += 1;
} else if(currentColorG > targetColorG){
currentColorG -= 1;
}
if(currentColorB < targetColorB){
currentColorB += 1;
} else if(currentColorB > targetColorB){
currentColorB -= 1;
}
fill(currentColorR, currentColorG, currentColorB);
arc(width/2, height/2, 300, 300, angle, angle + ANGLE_STEP);
angle += ANGLE_STEP;
if(angle >= 2*PI){
angle -= 2*PI;
}
}