Basic fill() help.
in
Programming Questions
•
24 days ago
I've been assigned the task of setting a circle in constant motion across the width of any screen. As it does this, it is supposed to transition from one color to others before reaching a stopping point. I've tried using a while loop as my code indicates, but when I run the program, it returns an entirely blank canvas without the moving ellipse. I've kept its starting color black, but should I be using if statements instead?
float ellipsexposition=0;
void setup(){
size(500,500);
smooth();
}
void draw() {
background(255);
int endx=width/6*5;
int ellipseyposition=height/2;
int colorr=0;
int colorg=0;
int colorb=0;
colorr=colorr-1;
colorg=colorg+1;
colorb=colorb+1;
fill(colorr,colorg,colorb);
ellipse(ellipsexposition,ellipseyposition,50,50);
ellipsexposition=ellipsexposition+=1;
if(ellipsexposition<endx){ellipsexposition=ellipsexposition+1;}
else{ellipsexposition=0;}
while(ellipsexposition<endx){ // The following is supposed to gradually change the color of the moving ellipse
colorr=colorr-1;
colorg=colorg+1;
colorb=colorb+1;
}
}
1