Issue when using loadShape()

Hello there!

I’m currently migrating a game I’m currently writing from .png to .svg for better scaling however I’m having issues with using a certain icon from (Settings icon).Processing throws an error when trying to use the following code:


The “settings.svg” is the renamed icon. Processing then throws the following error:

parsed: M,15.95,10.78,c,.03,-.25.05,-.51.05,-.78,s,-.02,-.53,-.06,-.78,l,1.69,-1.32,c,.15,-.12.19,-.34.1,-.51,l,-1.6,-2.77,c,-.1,-.18,-.31,-.24,-.49,-.18,l,-1.99.8,c,-.42,-.32,-.86,-.58,-1.35,-.78,L,12,2.34,c,-.03,-.2,-.2,-.34,-.4,-.34,H,8.4,c,-.2,0,-.36.14,-.39.34,l,-.3,2.12,c,-.49.2,-.94.47,-1.35.78,l,-1.99,-.8,c,-.18,-.07,-.39,0,-.49.18,l,-1.6,2.77,c,-.1.18,-.,l,1.69,1.32,c,-.04.25,-.07.52,-.07.78,s,.,L,2.37,12.1,c,-.15.12,-.19.34,-.1.51,l,1.6,2.77,c,.,l,1.99,-.8,c,.,1.35.78,l,.3,2.12,c,.,h,3.2,c,.2,0,.37,-.14.39,-.34,l
unparsed: .3,-2.12,c,.49,-.2.94,-.47,1.35,-.78,l,1.99.8,c,.18.07.39,0,.49,-.18,l,1.6,-2.77,c,.1,-.18.06,-.39,-.1,-.51,l,-1.67,-1.32,z,M,10,13,c,-1.65,0,-3,-1.35,-3,-3,s,1.35,-3,3,-3,3,1.35,3,3,-1.35,3,-3,3,z
RuntimeException: shape command not handled: .3

Can’t Processing’s svg-parser handle real numbers? Are there any solutions not involving using a different icon or using a .png variant?


Note that Processing has no problems handling some other icons but has problems processing for example this icon and this icon

You will have to use a different svg file, this is from the reference page. " The loadShape() function supports SVG files created with Inkscape and Adobe Illustrator. It is not a full SVG implementation, but offers some straightforward support for handling vector data."

Which subset of svg-features does Processing actually support?

I believe that this is documented by the source. If you are using the default JAVA2D renderer, then loadShape is going to call loadXML on your svg file and pass it to PShapeJAVA2D. That extends PShapeSVG, which has all the xml parsing code in it – it starts building the PShape internally by checking the contents of the XML object, called “properties”. You can see exactly what it parses and what it doesn’t. The SVG spec is huge; PShape only parses a small part of it. If you create a simple SVG yourself, it generally works. If you try to use ones that you find lying around, it is really hit-and-miss.

1 Like