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.
IndexProcessing DevelopmentLibraries,  Tool Development › "Candy", SVG Importer for Processing
Pages: 1 2 
"Candy", SVG Importer for Processing (Read 7534 times)
"Candy", SVG Importer for Processing
Jul 22nd, 2006, 12:36am
 
Hello guys. By Casey's suggestion I am releasing this so people can begin playing with it.

My second attempt at writing an SVG importer, this time with Christian Reikoff's proXML. Everything is a lot cleaner and more stable, and it handles most shapes.

Compatibility is greatest when you use illustrator, since that was my testbed software.

It's still in -beta- so please test it and let me know what you think. Report all bugs to flux.blackcat -a- gmail -d- com with subject "Delicious Candy".

Download:
http://www.ghost-hack.com/post/candy072106.rar

Enjoy!

~M
Re: "Candy", SVG Importer for Processing
Reply #1 - Aug 8th, 2006, 2:34pm
 
sorry to ask, but would it bother you to supply this as .zip and/or tar.gz? .rar is not that usual outside of microsoft's realm… (and requires extra software for extraction)
Re: "Candy", SVG Importer for Processing
Reply #2 - Aug 9th, 2006, 7:33am
 
Gotcha. Here you go!!

http://www.ghost-hack.com/post/candy072106.zip

I just use it because rar integrated with my OS context menu a bit better than Zip.
Re: "Candy", SVG Importer for Processing
Reply #3 - Sep 24th, 2006, 2:09am
 
mflux,

please get an HTML page + documentation made for this library so we can get it out to the masses!

casey
Re: "Candy", SVG Importer for Processing
Reply #4 - Sep 27th, 2006, 2:42pm
 
Here you go, you can add this!

http://ghost-hack.com/p5/svgcandy/

Please let me know how I can improve this doc. It's mainly from the read-me.
Re: "Candy", SVG Importer for Processing
Reply #5 - Sep 27th, 2006, 6:59pm
 
Thank you very much, Michael, for making that reference. It looks great. I recommend making the text bold in the part about how the file must be saved.

I was not able to get a file to load. I was getting an InvalidDocumentException from proXML. My guess is that I'm not making the file in a way that is compatible.

I'm creating with Illustrator CS 2 on Windows XP, using the Save For Web feature with this config:
SVG, SVG 1.1, None(Use System Fonts), Embed Images, Presentation Attributes, [] Compressed, Decimals 3, Abobe CEF, UTF-8. [] Optimize for Adobe SVG Viewer

Are your settings different?
Re: "Candy", SVG Importer for Processing
Reply #6 - Sep 28th, 2006, 12:19am
 
Here's an example SVG that works.

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 11.0, SVG Export Plug-In  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
<!ENTITY ns_svg "http://www.w3.org/2000/svg">
<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
]>
<svg  xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
width="128" height="158" viewBox="-0.893 -0.641 128 158" xml:space="preserve">
<defs>
</defs>
<g>
<path fill="#F48B8B" stroke="#E96363" d="M22.441,11.359c-4.046,12.813-31.667,58.333-18.333,90s15.833,34.166,13.333,48.
333
s13.333-7.5,43.333-7.5s50,30.835,43.333,0.834c-6.667-30,1.667-11.667,17.5-47.5s-
15.833-52.5-25-84.167
s-9.167,19.167-34.167,17.5S32.441-20.307,22.441,11.359z"/>
<circle fill="#E96363" stroke="#EEA5A6" cx="59.107" cy="101.776" r="28.333"/>
<circle fill="#E96363" stroke="#EEA5A6" cx="23.691" cy="71.776" r="8.75"/>
<circle fill="#E96363" stroke="#EEA5A6" cx="86.191" cy="66.442" r="8.75"/>
</g>
</svg>

I'll try and see if I can get a hold of Illustrator CS 2 to see any differences, as a last resort. I have CS(1), so the difference shouldn't be too big.


--

I've updated the site to reflect a few things:
http://ghost-hack.com/p5/svgcandy/

Most importantly, the exact settings I've used to generate a readable svg for our importer. http://ghost-hack.com/p5/svgcandy/settings.jpg

Let me know if this helps.



--

BTW I don't remember seeing "optimize for Adobe SVG Viewer".
I appreciate the help testing Cheesy
Re: "Candy", SVG Importer for Processing
Reply #7 - Sep 28th, 2006, 1:07am
 
I think the changes you made to the documentation will be extremely helpful for people. Thank you.

The problem I'm having loading the SVG files seems to be something other than the export settings. I'm also not able to load the file you posted that is working for you. This is the error:

Code:
java.lang.UnsupportedClassVersionError: proxml/InvalidDocumentException (Unsupported major.minor version 49.0)

at java.lang.ClassLoader.defineClass0(Native Method)


So it seems my problem is with proXML.
Re: "Candy", SVG Importer for Processing
Reply #8 - Sep 28th, 2006, 1:31am
 
Strange.

Try re-downloading the proXML package. I know that Christian has updated the lib very recently (like, today). There was a bug in proXML that needed fixed before SVG import was fully functional, so that might be it. Lemme know if that works.
Re: "Candy", SVG Importer for Processing
Reply #9 - Sep 28th, 2006, 2:00am
 
That code was compiled for Java 1.5.
http://dev.processing.org/libraries/
Scroll down to "Getting a UnsupportedClassVersionError?"
Re: "Candy", SVG Importer for Processing
Reply #10 - Sep 28th, 2006, 2:31am
 
Ah. proXML is compiled for Java 1.5 I guess. I'll send an email to Mister Riekoff.
Re: "Candy", SVG Importer for Processing
Reply #11 - Sep 28th, 2006, 2:52am
 
I don't know why I always forget to change the compile settings. Sorry I fixed it.
Re: "Candy", SVG Importer for Processing
Reply #12 - Sep 28th, 2006, 4:18am
 
Well, I have good news. That was the problem and now the file Michael posted earlier is loading fine. I'm using CS 2 to export and the <g> tag is not a part of the file, despite trying many settings (including 1.0 vs 1.1 SVG). The files I'm exporting look like this:

Code:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [

<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">

<!ENTITY ns_svg "http://www.w3.org/2000/svg">

<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
]>
<svg version="1.1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"

width="272" height="174" viewBox="-0.937 -0.795 272 174" enable-background="new -0.937 -0.795 272 174" xml:space="preserve">
<defs>
</defs>
<rect x="15.409" y="15.409" fill="#FFFFFF" stroke="#000000" stroke-width="30.8183" width="170.079" height="141.732"/>
<line fill="none" stroke="#007FD4" stroke-width="30" x1="100.449" y1="86.275" x2="270.527" y2="86.275"/>
</svg>


They won't draw, but if I manually put in the <g> tags surrounding the graphics and then save the file, they do draw. To be more compatible, I think the parser in Candy needs to not require <g>.

I haven't tried exporting in Inkscape to see what kind of files are made.
Re: "Candy", SVG Importer for Processing
Reply #13 - Sep 28th, 2006, 12:04pm
 
Alright. I'll try to catch this strange exception tomorrow. You're right, it shouldn't require it, but <g> is usually the identifier for when the graphics begin being listed.
Re: "Candy", SVG Importer for Processing
Reply #14 - Oct 7th, 2006, 10:01pm
 
I have a problem with complex shapes. If a path element has more then one closed path then I got an ArrayIndexOutOfBoundsException:

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 84

at java.util.Vector.get(Vector.java:710)

at candy.SVG$Path.draw(SVG.java:532)

at candy.SVG$VectorObject.basicDraw(SVG.java:249)

at candy.SVG.draw(SVG.java:116)

at Temporary_7528_1241.draw(Temporary_7528_1241.java:62)

at processing.core.PApplet.handleDisplay(PApplet.java:1336)

at processing.core.PGraphics.requestDisplay(PGraphics.java:535)

at processing.core.PApplet.run(PApplet.java:1152)
Pages: 1 2