// colorAnaglyph // // experiments with color red-blue anaglyphs // // standard red-blue glasses have a red filter over the right eye // and a blue (or green) filter over the left eye. // this means that the image to go into the left eye should be colored // green and/or blue, while the image to go into the right eye should // be colored red. BImage left; BImage right; // 01: 31, 5 // 02: -6, -5 // 03: 7, -4 int x = 0; int y = 0; int c = -1; // set up the screen and then set up the images void setup() { size( 320, 240 ); fill( 255 ); newImages(); } // change to the next set of images, adjust offsets void newImages() { c++; if( c>2 ) { c=0; } if( c==0 ) { left = loadImage( "01L.jpg" ); right = loadImage( "01R.jpg" ); x = 31; y = 5; } if( c==1 ) { left = loadImage( "02L.jpg" ); right = loadImage( "02R.jpg" ); x = -6; y = -5; } if( c==2 ) { left = loadImage( "03L.jpg" ); right = loadImage( "03R.jpg" ); x = 7; y = -4; } } void loop() { rect( 0, 0, width, height ); // backfill with white image( right, x, y ); // spin out the right image for( int i=0 ; i<(width*height) ; i++ ) { // mask off the green and blue of the right image (leave them alone) // then and-in the red from the left image. pixels[i] = (pixels[i] & 0x0000ffff) | (left.pixels[i] & 0x00ff0000); } if( mousePressed ) { newImages(); while( mousePressed ) /* wait till released */ ; }; if( keyPressed && !online() && key == 'G' ) { saveFrame(); } }