int n = 12;
PImage[] images = new PImage[n];
// offset to the reference point
int dx = 100;
int dy = 200;
// factor to slow our animation down
int slowdown = 10;
// zoom factor for our image
float zoom = 0.1;
void setup() {
// canvas size
size(600, 600);
// background
background(120);
// load images into the array using a loop
for(int i=0; i < n; i++) {
// load the image
images[i] = loadImage("schwarn" + i + ".jpg");
// the hack !
images[i].mask(images[i]);
}
}
void draw() {
// pick the index of an image
int pick = (frameCount / slowdown) % n;
// move to the mouse position
translate(mouseX -dx/2 , mouseY -dy/2);
// scale the image
scale(zoom);
// move to the reference point
translate(-dx, -dy);
// get image from the array and display it
image(images[pick], 0, 0);
}