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 › decreasing rect alpha
Page Index Toggle Pages: 1
decreasing rect alpha (Read 351 times)
decreasing rect alpha
Jun 17th, 2007, 3:23pm
 
I'm trying to create a cheap little slideshow essentially where the image fades from black, delays for a bit, then fades back into black before reloading the image. I haven't gotten to the last part yet.  First I started with trying to tint an image in the default renderer, but it seemed to drop the bit depth or something as even at full alpha, it was blotchy.  then i decided to try a black rect over the image that changed in opacity.  I can't quite get that to work though.  
Code:

rectangle [] r;
int photoTimeSpan=3;
int playhead=0;
PImage b;
File dir = new File("C:/phototemp");
String[] children = dir.list();

void setup(){
size(700, 700, OPENGL);
//startFullscreen();
background(255,0,0);
frameRate(40);
r=new rectangle[1];
r[0]=new rectangle(0,0,width,height);
}

void draw(){
if (children == null) {
println("Directory listing failed");
} else {
float alphatemp=255f;
if(r[0].alpha>=alphatemp){
int picnum=round(random(children.length-1));
b=loadImage(children[picnum]);
image(b,0,0);
println("Image born!");
println(children[picnum]);
delay(2000);
}
r[0].draw();
}
}

class rectangle{
float r,g,b,alpha;
boolean AlphaStatus = true;
rectangle(float x,float y, float wide,float high){
alpha = 255f;
r = 0;
g = 0;
b = 0;
}
void draw(){
if(AlphaStatus == true && alpha<=0){
delay(5000);
AlphaStatus=false;
}
if(AlphaStatus == false){
fill(0, alpha);
stroke(0, alpha);
rect(0,0,width-20,height-20);
alpha += 2;
println("alpha increasing");
}
if(AlphaStatus == true){
fill(0, alpha);
stroke(0, alpha);
rect(0,0,width-20,height-20);
alpha -= 2;
println("alpha decreasing");
println(alpha);
}
}
}


Any suggestions?  Thanks
Re: decreasing rect alpha
Reply #1 - Jun 17th, 2007, 8:44pm
 
scratch that, got tint to work.  Thanks anyway.
Page Index Toggle Pages: 1