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 & HelpSyntax Questions › increment/decrement
Page Index Toggle Pages: 1
increment/decrement (Read 466 times)
increment/decrement
Jul 24th, 2006, 8:08pm
 
Hi all,

I would like to fade in/fade out the tint of an image:
I looked at the examples for increment/decrement, but I don't get how to modify the code so that it works. How do I modify this code so that the alpha channel fades in and out?

int a = 0; a++; if(a > 1) { a = 255; }
     tint(255, 255, 255, a);
     image(video, 200, 200);

Thanks for helping a beginner:)
Re: increment/decrement
Reply #1 - Jul 24th, 2006, 11:50pm
 
So you're saying a = 0. Then plus one to a. Then if a is greater than one immediately change a to 255. I think you have your logic a bit backwards. I have a couple of examples below. I hope they help.

http://www.robotacid.com/PBeta/fader/index.html

Code:

float fade = 0.0;
void setup(){
//get images etc.
}
void draw(){
background(0);
if(a < 255){
a += 0.3;
tint(255, 255, 255, fade);
}
image(video, 200, 200);
}
Page Index Toggle Pages: 1