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