image fades out?
in
Contributed Library Questions
•
2 years ago
so i'm trying to make this image fade out but it doesnt seem to be working!
help!
-----
import hypermedia.video.*;
OpenCV opencv;
PImage one;
int a = 255;
float fade;
int passedTime;
int maxTime = 50;
boolean boolFade;
boolean bFadeIn;
void setup() {
size(640,480);
opencv = new OpenCV(this);
opencv.capture(640,480);
noStroke();
one = loadImage("outline.jpg");
}
void draw() {
//sketch opens with outline over video: please stand between the lines
background(0);
imgFade();
boolFade = true;
bFadeIn = !bFadeIn;
opencv.read();
opencv.flip(OpenCV.FLIP_HORIZONTAL);
image(opencv.image(), 0,0);
}
void imgFade() {
if (boolFade) {
passedTime++;
if (bFadeIn) {
fade = map(passedTime, 0, maxTime, 0, 255);
} else {
fade = map(maxTime - passedTime, 0, maxTime, 0, 255);
}
println(bFadeIn + " " + passedTime + " " + fade);
if (fade > 254 || fade < 1) {
boolFade = false;
passedTime = 0;
}
}
fill(255, fade);
image(one,0,0);
}
2