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.
IndexProgramming Questions & HelpSyntax Questions › Fade-in effect due to low framerate !
Page Index Toggle Pages: 1
Fade-in effect due to low framerate ?! (Read 530 times)
Fade-in effect due to low framerate ?!
May 2nd, 2007, 4:02pm
 
Hi.
Running this simple script:

Code:

void setup()
{
size(800,800);
frameRate(1);
}

void draw() {
//probabilities for 3 different cases (these need to add up to 100% since something always occurs here!)
float red_prob = 0.10; // 10% chance of red color occurring
float green_prob = 0.60 + red_prob; // 60% chance of green color occuring
float blue_prob = 0.30 + green_prob; // 30% chance of blue color occuring
float num = random(1); // pick a random number between 0 and 1
if (num < red_prob) {
fill(255,0,0,50);
}
else if (num < green_prob) {
fill(0,255,0,50);
}
else {
fill(0,0,255,50);
}
ellipse(random(width),random(height),16,16);
}


You'll notice that spots appear to "fade in" instead of being printed promptly. I noticed this while lowering the framerate. You know why?
Re: Fade-in effect due to low framerate ?!
Reply #1 - May 2nd, 2007, 4:57pm
 
Remove the alpha value in fill()

e.g fill(0,0,255);
Re: Fade-in effect due to low framerate ?!
Reply #2 - May 2nd, 2007, 4:59pm
 
What if I want to mantain it ?
lol

I did understood that this "fade in" effect was due the alpha value of the fillShape() but I cant understand why...
Re: Fade-in effect due to low framerate ?!
Reply #3 - May 2nd, 2007, 5:01pm
 
This may seem like an odd suggestion, but:  put a "background(255)" call right after your size() call.  Now when you run the sketch what color is the background?  White or gray?

Based on what you've described, my guess is you'll see gray, which indicates a problem - specifically, this one: http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1173650269

So, what's happing is that the internal buffer didn't get properly set up, and will have alpha values of 0, except where your ellipses set it to 50.  So each frame when it's blitted to the screen, it will add to itself and "accumulate" your ellipses in the way you've noticed.

Further prove it by putting "if (frameCount==1)" before your ellipse statement, so that ONLY one ellipse is ever drawn.  Do they still "accumulate"?

What to do?  With the background() statement still in place, alter your setup() call as:  setup(800,800,P3D);
Now run the sketch, does it work as expected?
Page Index Toggle Pages: 1