Reputation: 7039
In Inkscape, I have a path representing a star. I am using Inkscape as a benchmark to create my own SVG parser using Linq to XML, but I am having trouble parsing the path data that Inkscape generated. I am coding according to the documentation at MDN but Inkscape generated this path data:
m 100.93837,238.62186 -15.635004,13.72009 2.438549,20.65787 -17.880056,-10.63004 -18.893249,8.70283 4.584526,-20.28981 -14.11522,-15.27922 20.71345,-1.90975 10.169563,-18.14592 8.21709,19.10952 z
As you can see, there is a move instruction, but no line instruction, so my path parsing fails. How am I supposed to interpret this properly if there is no line instruction? All this does is move the "pencil" around a bunch and then close the path.
Upvotes: 0
Views: 1427
Reputation: 354734
Subsequent coordinate pairs after a move are supposed to be interpreted as lineto instructions. If the moveto was relative, the subsequent implicit linetos are also relative, and the same with absolute.
As a general rule of thumb, if you want to implement a standard, read the specification if you can, not a convenient summary that leaves out crucial details. The SVG specification is quite readable, actually and I've found little reason to use anything else as reference in the past 10 years.
SVG path data parsing has all kinsd of fun edge cases anyway, e.g. the following are valid coordinate pairs: 5-3
, 0.0.1
.
Upvotes: 2