// imagelines // -- does a liney thing to the image loaded in // ** window size should be twice the image size // ** window: 200x200 image: 100x100 // // Scott "Jerry" Lawrence // http://www.cis.rit.edu/~jerry/Software/p5 // BImage ji; int esize = 2; // setup - initialize stuff void setup() { size(200, 200); noBackground(); // persistant background noStroke(); // our ellipses will be solid colored fill(0); rect( 0, 0, width, height ); // clear the screen ellipseMode(CENTER_DIAMETER); // we need to draw ellipses from the center ji = loadImage( "0.jpg" ); // load in our input image (my livejournal icon) } int sx = 0; int sy = 0; boolean upOrOver = false; void loop() { // random coordinate in the image int dx = int( random(width - 1) ); int dy = int( random(height - 1) ); int x = sx; int y = sy; if( upOrOver ) { for( x=min(sx,dx) ; x<=max(sx, dx) ; x++ ) { // snag the source pixel color c = ji.pixels[ (x/2) + ( (y/2) * ji.width ) ]; // set the location in the destination (with an ellipse) fill( c ); ellipse( x, y, esize, esize ); } } for( y=min(sy,dy) ; y<=max(sy, dy) ; y++ ) { // snag the source pixel color c = ji.pixels[ (x/2) + ( (y/2) * ji.width ) ]; // set the location in the destination (with an ellipse) fill( c ); ellipse( x, y, esize, esize ); } if( !upOrOver ) { for( x=min(sx,dx) ; x<=max(sx, dx) ; x++ ) { // snag the source pixel color c = ji.pixels[ (x/2) + ( (y/2) * ji.width ) ]; // set the location in the destination (with an ellipse) fill( c ); ellipse( x, y, esize, esize ); } } if( upOrOver ) upOrOver = false; else upOrOver = true; sx = dx; sy = dy; }