Fade in text
in
Programming Questions
•
3 years ago
Good day,
I'm trying to get some text to fade in to a sketch after a specified amount of time. The issue is that I want it to fade in (not out), and also to do so along side a playing sketch.
I added a fade out technique (within the comment markers) to an adapted sketch below, however this fades out everything on screen: -
float angle = 0.0; // Current angle
float speed = 44.01; // Speed of motion
float radius = 180.0; // Range of motion
float sx = 8.0;
float sy = 2.0;
float hh = 0;
float dir = 2;
float alpha = 0;
color col;
void setup() {
size(800, 600);
noStroke();
background(0);
smooth();
}
void draw() {
angle += speed; // Update the
println("angle:;"+angle);
float x = width/2 + sin(angle) * radius;
float y = height/2 + cos(angle) * radius;
fill(255);
ellipse(x, y, 2, 2); // Draw smaller circle
// Set the position of the large circles based on the
// new position of the small circle
float x2 = x + cos(angle * sx) * radius ;
float y2 = y + sin(angle * sy) * radius ;
ellipse(x2, y2, 1, 1); // Draw larger circle
//line
if(hh<100){
hh+=1;
}
else{
hh--;
}
col = color(255,255,100+hh,15);
stroke(255,hh);
line(x,y,x2,y2);
///////////////////////////////////////////////
fill(255, 0, 0);
text("Fade", 180, 180);
alpha += dir;
fill( 0, alpha );
rect( 0, 0, width, height );
dir *= -1;
}
/////////////////////////////////////////////////////////
}
Does anyone have any idea how to fade the text in after a specified period, after the initial drawing has already started?
1