Changing Color with Motion
in
Programming Questions
•
1 year ago
Hello,
Let me say I am still learning this program so please bear with me and what might be the simple problems.
For this program I want the color to change smoothly as the text moves up/down the screen. Right now the color change starts smooth and then will abruptly start over. Is there a way to smooth the color transitions?
I am thinking it has to do with me randomizing the colors, but then again I don't know.
Thanks for all the help!!!
Let me say I am still learning this program so please bear with me and what might be the simple problems.
For this program I want the color to change smoothly as the text moves up/down the screen. Right now the color change starts smooth and then will abruptly start over. Is there a way to smooth the color transitions?
I am thinking it has to do with me randomizing the colors, but then again I don't know.
Thanks for all the help!!!
- PFont font;
float y1 = 0;
int direction = 1;
int c = color(random(255),random(255),random(255));
void setup(){
size(200,400);
font = loadFont("Serif-48.vlw");
textFont(font);
fill(0);
}
void draw(){
background(255);
fill(c);
y1 += 1.0*direction;
if (y1 >= 450 || y1 < -50){
direction *= -1;
}
if (direction == -1) {
text("Goodbye",12,y1);
}
if (direction == 1) {
text("Hello",50,y1);
}
c += 2*direction;
}
1