// Linear Strip Image Generator v2 // // Scott "Jerry" Lawrence // 2003-08-27 int scanpos = 0; // starting position. 0=left, 160=center boolean scanning = true; // scan? boolean resettogether = true; // reset both scanners? int xpos = 0; // the current position in the video capture buffer boolean newFrame = false; // was there a new frame? int[] theimage = new int[640*240]; // where we store the rows of pixels // our initialization void setup() { size( 640, 240 ); // screen size noBackground(); // don't clear the backing store with each frame cls(); // reset the counter, clear the screen beginVideo( 320, height, 30 ); // start up video capture } // clear the screen with black, reset x position void cls() { xpos = 0; if( resettogether ) { scanpos = 0; } for( int i=0 ; i= width) { fill( 0, 0, 0 ); // black fill for( int x=0 ; x< (width*height) ; x++ ) { pixels[ x ] = theimage[ x ]; } screenGrab(); // save out the image cls(); // clear the screen } if( scanpos >= 320 ) { scanpos = 0; } // copy over the screen image( video, 50, 0 ); // and show where we're snagging from stroke( 255, 0, 0 ); line( 50+scanpos, 0, 50+scanpos, height ); // initialize the variables int srcoffset = scanpos; int dstoffset = xpos; // blit the column over to the proper location in the pixels array for( int j=0 ; j < height ; j++ ) { color pix = video.pixels[srcoffset]; theimage[ dstoffset ] = pix; // show it on screen pixels[ dstoffset ] = pix; srcoffset += 320; dstoffset += width; } // clear the counter, increment the frame/scan position newFrame = false; xpos++; if( scanning ) { scanpos++; } } } // keyboard handler void keyPressed() { if( key == 'r' ) // reset everything if the user hits 'r'; { cls(); } if( key == 'd' ) // for debugging { xpos = width; } }