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 › creating multiple canvases
Page Index Toggle Pages: 1
creating multiple canvases (Read 370 times)
creating multiple canvases
Jul 31st, 2008, 2:37am
 
i need the canvases to be created (one by one) in real time.

is that possible in processing?
Re: creating multiple canvases
Reply #1 - Jul 31st, 2008, 9:30am
 
Yes, create several instances of PGraphics.
I think I gave an example in Saving images with transparent backgrounds.
Re: creating multiple canvases
Reply #2 - Jul 31st, 2008, 9:31am
 
Yes.

Reference > Advanced > Rendering > createGraphics()
http://processing.org/reference/createGraphics_.html
Re: creating multiple canvases
Reply #3 - Aug 2nd, 2008, 6:01am
 
thanks for the links ppl
i had a try with it but it seems it only works if i predefined everything before evaluating it.

is it possible to make each canvas part of an array of objects(the object being the canvases) and create them one by one(more than 2) with a GUI in real time?
Re: creating multiple canvases
Reply #4 - Aug 2nd, 2008, 11:00am
 
Yes, for example you create a new instance of PGraphics with createGraphics, and put it in an ArrayList which will grow on demand.

 pg = createGraphics(w, h, r);
 al.add(pg);

When you need one of them, just use pg = (PGraphics) al.get(i); and use it as usual.
Page Index Toggle Pages: 1