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 › background() not optimal
Page Index Toggle Pages: 1
background() not optimal? (Read 188 times)
background() not optimal?
Jul 30th, 2008, 10:52pm
 
Hey, I recently profiled one of my bigger processing apps, and I noticed that a great deal of time was spent on the background() call I make at the start of draw(), specifically the clear() call made by background.  I looked in the source code implementation and saw that it clear() does push/pop matrix just in case the programmer made any prior tranforms.  I replaced the background() call with my own call to rect():

fill(50);
rect(0,0,width,height);

and more than halved the processing time for that part.  I fully realize the point of implementing background() like this; I just wanted to make sure my "custom background()" isn't missing anything important, or if there's a better optimization.

aside:
I don't know if it's the actual latest source code but I saw that most drawing methods check for if there is a recorder, which made me sad because I don't need this ability in every app.  I suppose in general I ought to value processing more as an incredible prototyping tool, that is easy to iterate through designs quickly with.  But then maybe build the final app directly with Java2D or other rendering API, being able to control.
Page Index Toggle Pages: 1