// BoxFit04 (flippy textured) // David Bollinger, July 2006 // http://www.davebollinger.com // for Processing 0109 beta // (0115 has trouble loading fasa300.jpg from applet) // /** BoxFit04 - "FlippyTexturedBoxFitter" (derived class)
Draws areas with underlying texture flipped randomly horz/vert.
Click to advance early to next pattern.
*/ FlippyTexturedBoxFitter fitter; int currentSeed = 0; int nextwait = 0; PImage texture; void setup() { size(300,300,P3D); texture = loadImage("fasa300.jpg"); fitter = new FlippyTexturedBoxFitter(texture,4,4,8); framerate(30); next(); } void next() { background(color(255,255,255)); fitter.make(++currentSeed); } void draw() { if (nextwait > 0) { if (--nextwait <= 0) { next(); } } else { fitter.drawone(); if (fitter.at00()) nextwait = 5*30; } } void keyPressed() { if (key=='`') saveFrame("frame.tga"); } void mousePressed() { nextwait=0; next(); } class FlippyTexturedBoxFitter extends BoxFitter{ PImage texture; FlippyTexturedBoxFitter(PImage _texture, int _divx, int _divy, int _maxsizer) { super(_texture.width, _texture.height, _divx, _divy, _maxsizer); texture = _texture; } void render(int x1, int y1, int w, int h) { PImage snippet = texture.get(x1,y1,w,h); snippet.loadPixels(); // flipx? if (random(1.0) > 0.5) { for (int y=0; y 0.5) { for (int y=0; y