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.
Page Index Toggle Pages: 1
Tweening Alpha (Read 819 times)
Tweening Alpha
Apr 26th, 2010, 9:37pm
 
I'm currently writing something to tween the alpha value in the fill. I'm writing something basic to change the state of the fill from 0 to 255. For some reason is not changing on the draw. The values are correct when printed.

Code:

int opacF = 255;
int opacC = 0;
int opac;


boolean opacState;

void setup(){
size (400,400);
background (255);
opac = opacF;
opacState = true;
}

void draw(){
fill (0,opac);
rect(0,0,400,400);
//println (opac);
}

void mouseClicked(){
if (opacState==true){
opacState = false;
opac = opacC;
println ("false"+" "+opac);
}
else{
opacState = true;
opac = opacF;
println ("true"+" "+opac);
}

}




Re: Tweening Alpha
Reply #1 - Apr 26th, 2010, 10:27pm
 
How do you expect to see an opacity change?
You can see transparency when there is something behind the transparent shape you draw. Against a neutral background, you only see something uniform.
Re: Tweening Alpha
Reply #2 - Apr 26th, 2010, 10:35pm
 
Right now I'm just checking to see if the boolean I have work so I'm swamping the alpha value from 255 to 0. with a white background. I'm changing the black square's fill. So if it works, I'll see a white background when I click the mouse. Am I right?
Re: Tweening Alpha
Reply #3 - Apr 26th, 2010, 11:13pm
 
If you add a background, yes.
Re: Tweening Alpha
Reply #4 - Apr 26th, 2010, 11:20pm
 
background is in setup
Re: Tweening Alpha
Reply #5 - Apr 26th, 2010, 11:21pm
 
Ah ha. Ok. Nevermind should be in the draw. Thanks for making me realize that.
Page Index Toggle Pages: 1