|
Author |
Topic: Alpha fadeout and translation (Read 317 times) |
|
Jerronimo
|
Alpha fadeout and translation
« on: Sep 11th, 2003, 9:49pm » |
|
Hey all. I've been experimenting with this one, but i'm stuck, and I don't understand what's up. If you set "backing" to false, it should do a nifty fadeout (by applying a transparent dark rectangle over the entire image). I've done this on other sketches successfully, but it fails on this one. Also, I wanted to have it so that moving the mouse tilts the rendered pixels/boxes.. but i couldn't figure out rotateX and rotateY enough to get it working the way I wanted it. Help? Code: boolean useVideo = false; // set to true if you have a webcam. boolean backing = true; // set to false to see it break int vw = 40; int vh = 30; // our initialization void setup() { size( 320, 240 ); // screen size if( backing == false ) { noBackground( ); // don't clear the backing store with each frame fill( 0 ); rect( 0, 0, width, height ); } else { background( 0 ); } if( useVideo ) beginVideo( vw, vh, 30 ); // start up video capture noStroke(); } // the main loop... void loop() { if( backing == false ) { // dim out the previous frame noStroke(); fill( 255, 0, 0, 50 ); rect( 0, 0, width, height ); } push(); // bad -- i want these to work... :( /* rotateX( radians( mouseX )); rotateY( radians( mouseY )); */ for( int y = 0 ; y < vh ; y++ ) { int offset = y*vw; for( int x = 0 ; x < vw ; x++ ) { color ccc; if( useVideo ) ccc = video.pixels[offset]; else ccc = color( x*4 + random( 50 ), y*4 + random( 50 ), abs( x-y)*4 + random( 50 ) ); push(); translate( x * width / vw, y * height/vh ); float bbb = brightness( ccc ); if( mousePressed ) { stroke( ccc ); point( 0, 0, bbb/4); } else { noStroke(); fill( ccc ); box( bbb/16, bbb/16, bbb/2 ); } offset++; pop(); } } pop(); } |
|
|
|
|
|
trip
|
Re: Alpha fadeout and translation
« Reply #1 on: Sep 12th, 2003, 5:26pm » |
|
I am having a similar problem... it seems like fill()+pushpop+noBackground() does not behave as expected. try this code, press the mouse and notice that things are getting drawn, but they are filled with the first call to fill() (which in your case is 0, so everything is filled with black) boolean useVideo = false; // set to true if you have a webcam. boolean backing = false; // set to false to see it break int vw = 40; int vh = 30; // our initialization void setup() { size( 320, 240 ); // screen size if( backing == false ) { noBackground(); // don't clear the backing store with each frame fill( 0 ); rect( 0, 0, width, height ); } else { background( 0 ); } if( useVideo ) beginVideo( vw, vh, 30 ); // start up video capture noStroke(); } // the main loop... void loop() { if( backing == false ) { // dim out the previous frame // noStroke(); // fill( 255, 0, 0, 1 ); //rect( 0, 0, width, height ); } push(); // bad -- i want these to work... /* rotateX( radians( mouseX )); rotateY( radians( mouseY )); */ for( int y = 0 ; y < vh ; y++ ) { int offset = y*vw; for( int x = 0 ; x < vw ; x++ ) { color ccc; if( useVideo ){ ccc = video.pixels[offset]; }else{ ccc = color( x*4 + random( 50 ), y*4 + random( 50 ),abs( x-y)*4 + random( 50 ) ); } push(); translate( x * width / vw, y * height/vh ); float bbb = brightness( ccc ); if( mousePressed ) { stroke( ccc ); point( 0, 0, bbb/4); } else { //noStroke(); // -------------------> i changed this fill( ccc ); // ----------------------> and added this box( bbb/16, bbb/16, bbb/2 ); } offset++; pop(); } } pop(); } ------------------------------- please see my post (which was posted last night!) for a suspiciously similar problem: http://proce55ing.net/discourse/yabb/board_Proce55ing_software__bugs_action_display_num_1063342683.html and if you hear of a fix, let me know! c
|
|
|
|
|