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 & HelpOther Libraries › Candy on new PGraphics
Page Index Toggle Pages: 1
Candy on new PGraphics (Read 1009 times)
Candy on new PGraphics
Dec 12th, 2006, 6:31am
 
Hey, I was wondering if there was some way to get a Candy SVG object to draw to a graphics other than the primary graphics. The constructor takes a PApplet as a parameter, but I'm not sure if that would let me hack it somehow to take a PGraphics instead. Any ideas?
Re: Candy on new PGraphics
Reply #1 - Dec 12th, 2006, 9:20am
 
Hi,
I've had the same idea. My solution was do recompile the source. It's very simple. You need do replace the PApplet statemants by PGraphics and then delete the parent.g by simply parent. At least there are a bunch of parent.acos/sin calls. Change this to (float) Math.acos/asin. Then you can initialize a new svg by calling newSVG(PGraphics,String)
Re: Candy on new PGraphics
Reply #2 - Dec 12th, 2006, 2:56pm
 
i had a student run into this just this week.. i have it using a papplet (instead of pgraphics) because 1) the applet is needed for to load the file 2) when using begin/endRecord, the applet will need to be writing to multiple PGraphics, and that's handled by PApplet, and 3) we don't make people learn about 'g' or writing to their own graphics unless we really have to..

that said, it's obvious that i need re-work how the drawing happens so that other surfaces can be used.. gimme a release or two and i'll get it straightened out.

in the meantime, you can also use a fake PApplet, change its 'g' object, and pass that in to draw if you don't want to recompile the source. this was his hack for it:

Code:
/*
This is a terrible hack to make Candy draw on PGraphics objects.
*/

public class SVG2 extends SVG{

public SVG2(PApplet parent, String filename) {
super(parent, filename);
}

public void drawOn(PGraphics g){
PApplet emptyP = new PApplet();
emptyP.g = g;
parent = emptyP;
}
}
Re: Candy on new PGraphics
Reply #3 - Dec 12th, 2006, 7:07pm
 
Thanks for all the responses, I'm sure I'll get this sorted out now.
Page Index Toggle Pages: 1