// This draws the mirror image of the input image when button is pressed.
PImage img;
void setup() {
//img = loadImage("");
//make the size the size of your image, which you will have to look up in your computer
size(300, 300);
}
void draw() {
if (mousePressed) {
mirror(img);
}
else {
image(img, 0, 0);
}
}
// This creates the mirror on the screen of the given image.
void mirror(PImage img) {
int mirrorx;
// for each x,y set the image to the mirror x but the same y
for (int x = 0; x < img.width; x++) {
mirrorx = img.width - x - 1;
for (int y = 0; y < img.width; y++) {
set(mirrorx, y, img.get(x, y));
}
}
}