views:

121

answers:

1

I am trying to copy paths from inkscape into Raphael (individual countries), the problem is the moveTo is way off, how do I make it display on the relatively correct position on the canvas?

A: 

If you're trying to draw a path on a canvas in a relative position, you need to transform all of the absolute coordinates to relative coordinates. I had the same problem recently and resorted to a calculator and paper (it was a short path, and wasn't worth it to attack programatically). There are a few tools out there that claim to be able to do these transformations, but in my experience they were either incomplete or outdated links.

The problem is that Inkscape has already decided for you that you want your SVG files optimized for size, and will switch back and forth from relative to absolute whenever it would save a few bytes. Essentially, what you would need to do is iterate through the path, keeping track of your position, compare each absolute node to the previous node (or the origin, if it's the initial moveTo), and replace any absolute coordinates with the difference.

The Inkscape preferences have an option to force absolute coordinates, (uncheck Preferences->SVG Output->Allow relative coordinates) which may make the transformation a little easier.

C-Mo