Hello everyone! I have this code that has a dot effect on the images and has code to change said image into the next one when the mouse is pressed.
int numFrames = 18; // The number of frames in the animation
int frame = 0;
PImage[] images = new PImage[numFrames];
void setup() {
size(900, 900, P3D);
images[0] = loadImage("2.jpg");
images[1] = loadImage("3.jpg");
images[2] = loadImage("4.jpg");
images[3] = loadImage("5.jpg");
images[4] = loadImage("6.jpg");
images[5] = loadImage("7.jpg");
images[6] = loadImage("8.jpg");
images[7] = loadImage("9.jpg");
images[8] = loadImage("10.jpg");
images[9] = loadImage("11.jpg");
images[10] = loadImage("12.jpg");
images[11] = loadImage("13.jpg");
images[12] = loadImage("14.jpg");
images[13] = loadImage("15.jpg");
images[14] = loadImage("16.jpg");
images[15] = loadImage("17.jpg");
images[16] = loadImage("18.jpg");
images[17] = loadImage("19.jpg");
}
void draw() {
background(#f1f1f1);
fill(0);
noStroke();
frame = (frame) % numFrames; // Use % to cycle through frames
image(images[frame], 0, 0);
float tiles = mouseX;
float tileSize = width/tiles;
for(int x = 0; x < tiles; x++){
for(int y = 0; y < tiles; y++){
color c = (images[frame]).get(int(x*tileSize), int(y*tileSize));
float b = map(brightness(c), 0,255,1,0);
push();
translate(x*tileSize, y*tileSize);
ellipse(0,0, tileSize, tileSize*b);
pop();
}
}
images[frame].resize(900, 900);
}
void mousePressed() {
changeImage();
}
void changeImage() {
if (frame<18)
{ frame++;
}
else frame = 0;
}
Problem is, the dot effect is not really applying to said image, but is working on top of the image. Like this:
This effect stopped working after I put the code to skip images… I’ve tried using push() and pop() but it didn’t work.
Can anyone help me out?
Thanks in advance!!