tags:

views:

94

answers:

2

I used the guides on a GIMP file to create a path which is just straight lines - no curves or anything. However, when I export the path, the SVG code uses "C" the curve indicator to draw the path. So part of the code looks like this:

<path id="Unnamed"
    fill="none" stroke="black" stroke-width="1"
    d="M 400.00,1230.00
       C 400.00,1230.00 328.00,1230.00 328.00,1230.00
         328.00,1230.00 328.00,962.00 328.00,962.00
       ...
       Z"
</path>

I want to strip out the coordinates that have been exported in this file and use them for a bunch of other things, and its obviously a trivial matter to handle the "C" format, but I"m wondering why it used C and not L and if I can get the load time faster on really complex paths if the .svg file used L.

A: 

My guess is that GIMP just treats every path segment as a Bézier curve and therefore exports them to SVG as such as well. Or they simply were to lazy to implement specialized encoding of certain paths. In any event, how I see it those curves are functionally equivalent to your straight line segments. so it's still exactly the same information.

As for the load time, I think it doesn't make much of a difference. Both the XML and the path syntax have to be parsed, whether it's a few tokens more or less in the latter shouldn't make much of a difference, I think. However, as usual: If in doubt, profile :-)

Joey
A: 

If you have only straight lines then I suppose it can make a difference in some cases, because a lineto command only needs to specify one point, while the curvto needs three. This can make the file larger, and thus may have an affect on loading/parsing time. Though probably not by very much unless you have a huge number of lines.

Erik Dahlström