We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
simple fade (Read 966 times)
simple fade
Jul 11th, 2007, 5:15am
 
I've got what's probably a really simple problem....

I'm trying to create a smooth fade effect that will cover black shapes with a white overlay. I thought I could draw a series of white rectangles over the whole stage, building up opacity until the stage went to white, but the black never gets covered all the way.

what's a better way to fade to white? what am I doing wrong?

link:
http://www.divinepenguin.com/processing/fadetest/

Quote:

int stageHeight = 300;
int stageWidth = 300;
int count = 0;

void setup(){
 size(stageWidth,stageHeight);
 background(255);
 noStroke();
 fill(0);
 ellipse(150,150,50,50);
}

void draw(){
 fill(255,5);
 rect(0,0,stageWidth,stageHeight);
 count ++;
 if (count > 50){
   fill(0);
   ellipse(random(stageWidth),random(stageHeight),50,50);
   count = 0;
 }
}



tia!
Re: simple fade
Reply #1 - Jul 11th, 2007, 7:59am
 
this is a known effect and has been discussed before. please try and search the forum for "fade" or "opacity" ..

F
Re: simple fade
Reply #2 - Jul 11th, 2007, 7:09pm
 
I'm sorry if my question was redundant...I looked around but didn't find a solution that would work.

I managed to do what I needed to do by manipulating the pixel array directly. it seems just as fast and offers more flexibility than drawing a rectangle, so I guess it's a better solution in the long run.

Quote:


int stageHeight = 300;
int stageWidth = 300;
int fadeSpeed = 25;

void setup(){
 size(stageWidth,stageHeight);
 background(255,255,255);
 noStroke();
 smooth();
 fill(0);
}

void draw(){
 ellipse(random(stageWidth),random(stageHeight),50,50);
 fadeScreen();
}

void fadeScreen(){
 loadPixels();
 for(int i=0; i<pixels.length; i++){
   pixels[i] = color(red(pixels[i])+fadeSpeed,green(pixels[i])+fadeSpeed,blue(pixels[i])+fadeSpeed);
 }
 updatePixels();
}


Page Index Toggle Pages: 1