SVG

SVG stands for "Scalable Vector Graphics". (Read the linked document for the description.) Sodipodi is a good Linux program for editing SVG images. I found out (the hard way) that depending on the order (ie - direction) in which you place points, the way the images fill (color) can be affected. This is demonstrated in the W3C's SVG recommendations.
While I was creating my image, I didn't know that this could be a factor, so I basically placed points in the order that was most convinient for me (I usually go with the easy points first. The end product of this was that some of the non-fills got rendered, while some did not. I at first thought this was a strange GNOME bug (GNOME desktop renders with fill-rule "nonzero" only), but a few searches online found me the right information.
So I was left with two choices. I could manually relocate/reorder all the nodes that were causing the fill-rule to fail, which is the same as starting all over. Or I could find/make an application to do this for me. Since I couldn't find any information about reversing the direction of the path, I decided to write my own hack.
So here it is. I use Nedit which is a really good customizable text/code editor for Linux. I put the following code in a Shell menu item. To use it, select the path description field within the quotation marks, and choose the menu item you created. perl -ne 's/(M|C | z)//g;while (length ($_)>2){unshift @ARGV, $1 if s/^( [-.\d]+ [-.\d]+)//;}print "M" . (shift);print " C". (shift) . (shift) . (shift) while (@ARGV);print " z ";' Hooray for Perl.
Example:
Suppose you had the following code in an SVG file (this is Sodipodi): <path style="fill:#ffffff;stroke:#000000;stroke-width:0.125;" d=";">M -104.775 630.297 C -86.8317 629.748 -80.0097 616.284 -74.6346 610.031 C -71.3319 634.94 -80.76 657.394 -99.512 657.032 C -113.308 656.761 -131.494 634.946 -137.017 619.336 C -128.95 624.096 -116.903 630.457 -104.775 630.297 z " id="path615" sodipodi:nodetypes="ccscs" transform="translate(0.422945,-1.268875)" /> You would select the highlighted section, just the part of the definition (d=) within the quotes. NOTE!: This only works if all the points between the starting "M" and the end "z" are "C"-type curves.
Maybe I'll write a more universal script another time.

2004-09-11 22:23
Printer-friendly: plain or styled
Sitemap
Get Firefox! Tux Powered Valid XHTML 1.0!