image viewer
in
Programming Questions
•
1 year ago
hello,
i am creating an image viewer by counting frames. when the frameCounter hits a defined threshold, i would like it to fade the image for the rest of the duration, however, the condition, although met, is never interpreted. an extra pair of eyes would be greatly appreciated. why does the program never enter the embedded conditional for frameCounter <= 150?
thanks much.
my code:
int numImages = 4;
int numFrames = 3000;
int imageCounter = 0;
int frameCounter = (int)(numFrames/numImages);
float fade;
PImage [] ref = new PImage[numImages];
void setup()
{
size(1000, 1200);
background(0);
frameRate(30);
for(int i = 0; i < numImages; i ++)
{
ref[i] = loadImage("image0" + (i) + ".png");
// println(ref[i]);
}
}
void draw()
{
if(frameCounter == numFrames/numImages)
{
if(frameCounter <= ((numFrames/numImages) * 0.2))
{
fade = (int)map(frameCounter, ((numFrames/numImages) * 0.2), 0, 255, 0);
tint(255, fade);
}
image(ref[imageCounter], 0, 0);
}
frameCounter --;
if(frameCounter < 0)
{
imageCounter ++;
frameCounter = numFrames/numImages;
}
if(imageCounter >= numImages) imageCounter = 0;
println(frameCounter + ", " + imageCounter);
}
i am creating an image viewer by counting frames. when the frameCounter hits a defined threshold, i would like it to fade the image for the rest of the duration, however, the condition, although met, is never interpreted. an extra pair of eyes would be greatly appreciated. why does the program never enter the embedded conditional for frameCounter <= 150?
thanks much.
my code:
int numImages = 4;
int numFrames = 3000;
int imageCounter = 0;
int frameCounter = (int)(numFrames/numImages);
float fade;
PImage [] ref = new PImage[numImages];
void setup()
{
size(1000, 1200);
background(0);
frameRate(30);
for(int i = 0; i < numImages; i ++)
{
ref[i] = loadImage("image0" + (i) + ".png");
// println(ref[i]);
}
}
void draw()
{
if(frameCounter == numFrames/numImages)
{
if(frameCounter <= ((numFrames/numImages) * 0.2))
{
fade = (int)map(frameCounter, ((numFrames/numImages) * 0.2), 0, 255, 0);
tint(255, fade);
}
image(ref[imageCounter], 0, 0);
}
frameCounter --;
if(frameCounter < 0)
{
imageCounter ++;
frameCounter = numFrames/numImages;
}
if(imageCounter >= numImages) imageCounter = 0;
println(frameCounter + ", " + imageCounter);
}
1