Avishkar Autar · Jan 14 2011 · Graphics and Rendering
I’m working on a little SVG project using Raphaël. Unfortunately, Illustrator exports polygons in its SVG output which is not supported by Raphaël (only paths are supported). So I wrote an app to convert the SVG polygon string to an SVG path string.[airbadge]poly2path,http://aautar.digital-radiation.com/apps/poly2path.air,1,http://aautar.digital-radiation.com/apps/poly2path-badge.png[/airbadge]
Note that you only input the points data from the polygon (from the points attribute), not the entire polygon element. The result is the path string for the d attribute of the path element.
The conversion is very simple and based upon the fact that a polygon is a path starting with an absolute moveto, linetos to each of the points, and a closepath (this bug report [yes, a bug report!] was pretty helpful).
I actually wanted to render the output, but I was disappointed to discover that Adobe Air doesn’t currently support SVG.