Processing Forum
PImage maskimage; PImage backgroundimage; PGraphics pg; String maskname="mask"; int i=0; float count=0; boolean marche=false; boolean inver=false; int cycle=0; void setup() { size(800, 600,P3D); backgroundimage = loadImage("img.jpg"); maskimage = loadImage(maskname+".jpg"); backgroundimage.loadPixels(); pg = createGraphics(800, 600, P3D); imageMode(CENTER); noCursor(); smooth(); } void draw() { background(0); if(marche)count+=.03; pg.beginDraw(); pg.background(0); pg.fill(255); if (inver) { pg.filter(INVERT); } pg.endDraw(); pg.translate(width/2, height/2); if(cycle==0){ pg.rotateX(count); pg.translate(-pg.width/2,maskimage.height/2-pg.height/2); } if(cycle==1){ pg.rotateY(count); pg.translate(maskimage.width/2-pg.width/2,-pg.height/2); } if(cycle==2){ pg.rotateZ(count); pg.translate(-pg.width/2,-pg.height/2); } pg.image(maskimage,width/2-maskimage.width/2,height/2-maskimage.height/2); backgroundimage.mask(pg); image(backgroundimage, width/2, height/2); } void mousePressed() { if (mouseButton == RIGHT) { inver=!inver; }else{ marche=true; cycle++; if(cycle==3)cycle=0; } } void mouseReleased() { if (mouseButton == RIGHT) { inver=!inver; } }