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 › Erasing PGraphics
Page Index Toggle Pages: 1
Erasing PGraphics (Read 540 times)
Erasing PGraphics
Mar 10th, 2010, 11:57pm
 
How do you erase a PGraphics object?

I draw some stuff on a PGraphics object and display the PGraphics with image(pg, 0, 0) on an animated background. Some frames later the PGraphics needs to be updated. I’d like to start again with an empty (all transparent!) PGraphics. How do you make a PGraphics all-transparent again?

Re-initalizing the object with pg = new PGraphics(...) doesn’t seem to work.

Any ideas?
Re: Erasing PGraphics
Reply #1 - Mar 11th, 2010, 12:51am
 
I don't expect you used "new" to create the PGraphics object in the first place (you are not supposed to!); you can use createGraphics() again, or reuse the existing PGraphics object:

Code:
  pg.beginDraw();
 pg.background(0, 0); // grey level (black), alpha (transparent)
 // .. draw new content
 pg.endDraw();


-spxl
Re: Erasing PGraphics
Reply #2 - Mar 11th, 2010, 1:33am
 
Everything working now!
Thanks!
Page Index Toggle Pages: 1