We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Fading to black
Page Index Toggle Pages: 1
Fading to black (Read 976 times)
Fading to black
Mar 18th, 2010, 5:11am
 
In several of my sketches (usually on black background) I want to draw things directly and "fade away" the display over time (while drawing new things on top of it.) I can achieve this fairly easy by drawing a black rectangle over the screen with a lower alpha value instead of using the background() command, f.e.
Code:
fill(0,0,0,fadeStrength); 
rect(0,0,width,height);

(see example sketch)

This works fine, but it becomes problematic for  very low alpha-values of the fill colour (=slower fading) because it will not darken things to black completely anymore. My solution was to use this fading only every n-th frame, but for really smooth & slow fades, this does not work. Now I wonder what other "fading" solutions others have come up with...  Please share you code!
Re: Fading to black
Reply #1 - Mar 18th, 2010, 7:09am
 
I don't know if this would help, but you could set the colorMode so that alpha has a large number of steps....

colorMode(RGB, 255, 255, 255, 2000);

for example....
Re: Fading to black
Reply #2 - Mar 18th, 2010, 8:10am
 
has something to do with the renderer you use.
It doesnt work when using Java2D but works when switching to P2D...

see the difference :


Code:

void setup() {
// size(600,400);
size(600,400,P2D);
smooth();
background(255);

}

void draw() {
fill(0,1);
rect(0,0,width,height);
noStroke();
fill(255);
ellipse(mouseX,mouseY,30,30);


}
Re: Fading to black
Reply #3 - Mar 19th, 2010, 6:28pm
 
Quote:
has something to do with the renderer you use.


True, happens with OpenGL too...leaves a trace of faint-black-ish areas where shapes have been previously drawn...
Re: Fading to black
Reply #4 - Mar 20th, 2010, 10:58am
 
Does this then mean it is a bug, or is there an explaination for it?
Anyway, any other suggestions for fading to black?
Page Index Toggle Pages: 1