// Scale Blox demo // // Scott "Jerry" Lawrence // http://www.cis.rit.edu/~jerry/Software/p5 // 2003-09-07 // // I made this as a drop-in helper for a rewrite my QuadBlok, as well as for // a new version of my sand simulator using a Cellular Automata. I figured // that others might find this useful, so I'm releasing it on its own. :) ScaleBlox sb; int xs = 18; // xsize of the array int ys = 15; // ysize of the array int ps = 10; // pixel size for the Ÿberpixels int fm = 2; // frame size -- 0 for no frame // for our mouse position indicator color white; // set this to 'true' to digitize video boolean useVideo = false; // non-video related things int rrrr = 0; // video related things boolean newFrame = false; void setup() { size( 200, 200 ); background( 0, 0, 0 ); white = color( 255, 255, 255 ); sb = new ScaleBlox( xs, ys, // size of the Ÿberpixels 100-(xs*ps/2) + fm/2, 100-(ys*ps/2)+fm/2, // center the SB ps, // Ÿberpixel size fm ); // 2 pixel frame if( useVideo ) beginVideo( xs, ys, 15 ); } void videoEvent() { newFrame = true; } void loop() { if( newFrame && useVideo ) { // copy over the video frame... int pos = 0; for( int y=0; y= maxX ) return w-1; return( (xx-x) / sz ); } // decodeY -- figure out where in the drawn array the passed in window position is int decodeY( int yy ) { int maxY = y+(h*sz); int minY = y; if( yy <= minY ) return 0; if( yy >= maxY ) return h-1; return( (yy-y) / sz ); } // set a color in the array void setC( int xx, int yy, color cc ) { data[xx][yy] = cc; } // return the color at xx,yy color getC( int xx, int yy ) { return( data[xx][yy] ); } // return true if the element is not black boolean occupied( int xx, int yy ) { return( data[xx][yy] != black ); } // clear the frame void clear() { for( int i=0 ; i