awebneck/savage

Initial move to command should always be absolute.

grahamjenson opened this issue · 6 comments

According to the SVG Spec

" If a relative moveto (m) appears as the first element of the path, then it is treated as a pair of absolute coordinates. In this case, subsequent pairs of coordinates are treated as relative even though the initial moveto is interpreted as an absolute moveto."

I have noticed that this does not mark up the first move command as absolute=true for a path "m100 100".

Graham
P.S. great Gem, saved me a lot of time

Good point Graham, thanks! I'll get it sorted.

I've added a test and code to ensure that any initial drawing command is parsed to absolute. Thanks!

Hey,
I just noticed that your fix works, but it overdoes its absolute-ness.
If I have a path "m100 100 20 20", this is equal to "M100 100 l20 20", but your fix parses it as "M100 100 L20 20".
It seems to make everything absolute in that first move command, where only the very first move command should be made absolute.
Cheers again for the library.
Graham

My hacky fix is just after everything is parsed setting the first move command to absolute.

Graham,
Well, it took me a while, but you are correct - I've added specs to check for the issue and corrected the problem in v1.1.7. Sorry for the delay, was laden down with paying work. :)

Awesome. I am just using this gem for hobby/learning, and I have been busy with paid work as well. I am still grateful that you did the hard work of writing a parser.