import processing.video.*; PImage img, imgOrig; MovieMaker mm; boolean recordMovie = true; int iteration = 0; void setup() { imgOrig = loadImage("puffball.png"); img = imgOrig; size(img.width, img.height, P2D); if(recordMovie) { mm = new MovieMaker(this, img.width, img.height, "catmap.mov"); } } boolean equal(PImage p1, PImage p2) { for(int i = 0; i < p1.pixels.length; i++) { if(p1.pixels[i] != p2.pixels[i]) return false; } return true; } void draw() { image(img, 0, 0); if(recordMovie) mm.addFrame(); if(equal(img, imgOrig) && iteration > 0) { noLoop(); if(recordMovie) mm.finish(); } PImage imgNext = createImage(img.width, img.height, RGB); for(int y = 0; y < img.height; y++) { for(int x = 0; x < img.width; x++) { int pixel = img.pixels[y*img.width + x]; int xNew = (2*x + y) % img.width; int yNew = (x + y) % img.height; imgNext.pixels[yNew*img.width + xNew] = pixel; } } img = imgNext; iteration++; }