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: Draw svg on PGraphics
Page Index Toggle Pages: 1
Candy: Draw svg on PGraphics (Read 582 times)
Candy: Draw svg on PGraphics
Feb 27th, 2008, 4:12pm
 
Hi,

I am currently trying to draw an svg onto a PGraphics object.

I tried it like this:

import processing.candy.*;
import processing.xml.*;

PGraphics nimg;
SVG bot;

bot = new SVG(this, "cross.svg");

nimg = createGraphics(width, height, JAVA2D);
nimg.beginDraw();
nimg.bot.draw(0,0,100,100);
nimg.endDraw();

it tells me:
"no field named "bot" was found in type "processing.core.PGraphics""

Is there a simple way to get this to work?
Re: Candy: Draw svg on PGraphics
Reply #1 - Feb 27th, 2008, 7:10pm
 
no. you can't use this syntax, since candy is written to draw directly onto the main applet's graphics, and there's unfortunately no way to specify another PGraphics to draw onto.

indeed, that would be great if we could somehow specify another graphic buffer. something like bot.draw(nimg, ...);
Re: Candy: Draw svg on PGraphics
Reply #2 - Feb 27th, 2008, 7:55pm
 
antiplastik wrote on Feb 27th, 2008, 7:10pm:
indeed, that would be great if we could somehow specify another graphic buffer. something like bot.draw(nimg, ...);

that's planned--it just involves reworking how beginRecord() and some related things are handled inside PApplet.
Re: Candy: Draw svg on PGraphics
Reply #3 - Feb 27th, 2008, 8:59pm
 
Yeah. I kinda thought that there is no way right now.

Well since I dont really want to wait till a new release I will shortly tell what I am workin on:

http://www.flickr.com/photos/59697360@N00/

The last 4 images on my flickr account are test renders of an algorithm i wrote inspired by mario klingemanns Image Foam thing he built in flash. I use the PGraphics buffer to draw new shapes on and compare its pixels[] with the pixels[] in the main buffer. Now that I cant use candy this way to load custom shapes id like to know if anyone has a different idea to get this to work with custom shapes!
Re: Candy: Draw svg on PGraphics
Reply #4 - Feb 27th, 2008, 10:01pm
 
If you don't need real-time animation, you can still use Candy to draw your svg to the main screen, and then copy the content into your buffer (nimg). It's a bit tricky, but you'll get what you want (your SVG) where you want (your custom PGraphics).
Re: Candy: Draw svg on PGraphics
Reply #5 - Feb 28th, 2008, 9:03am
 
But if I draw it on the screen once, how do I get rid of it if it does not fit? I cant just redraw the background.
Re: Candy: Draw svg on PGraphics
Reply #6 - Feb 28th, 2008, 9:43am
 
You could create a new PGraphic as your canvas and use the main Pgraphic as your buffer. So you draw your svg on the  screen. Copy it with get() and draw it on the  PGraphic object and draw the PGraphic object on the screen.
Re: Candy: Draw svg on PGraphics
Reply #7 - Feb 28th, 2008, 9:53am
 
Yeah okay, but I dont want to be stuck with pixels in the final one thats why I want to draw candy on the "stage". I had another idea of making a rather big png of the svg and copy the png to the buffer to compare the pixels[] arrays. if they dont collide, i draw the svg at the same spot.
Page Index Toggle Pages: 1