PImage[] imgs = new PImage[4]; // loaded images PImage img1,img2; // current images int curImg1 = 0, curImg2 = 1; // current images void setup() { size(400,600); for(int i = 0; i < imgs.length; i ++) imgs[i] = loadImage("img-"+(i+1)+".jpg"); img1 = imgs[curImg1]; img2 = imgs[curImg2]; } // makes a copy of the current image PImage makeCopy(PImage src) { PImage ret = new PImage(src.width,src.height); // make a image ret.copy(src,0,0,src.width,src.height,0,0,ret.width,ret.height); //copy pixels return ret; } void draw() { // compute the filtered images int w = img1.width; int h = img1.height; PImage f1 = makeCopy(img1); f1.blend(img2,0,0,w,h,0,0,w,h,HARD_LIGHT); PImage f2 = makeCopy(img1); f2.blend(img2,0,0,w,h,0,0,w,h,DODGE); // draw them background(0); image(img1,0,0); image(img2,width/2,0); image(f1,0,height/2); image(f2,width/2,height/2); } void keyPressed() { if(key == ' ') { curImg1 = (curImg1+1)%imgs.length; curImg2 = (curImg2+1)%imgs.length; img1 = imgs[curImg1]; img2 = imgs[curImg2]; } else if(key == 'f') { // swap images int a = curImg1; curImg1 = curImg2; curImg2 = a; img1 = imgs[curImg1]; img2 = imgs[curImg2]; } } // START NO NOTES // code used to capture screenshots void keyReleased() { if(key == '`' && !online) save("sketch.png"); }