Given an SVG Path element, how can I convert all path commands into absolute coordinates? For example, convert this path:
<path d="M17,42 l100,0 v100 h-100 z"/>
into this equivalent path:
<path d="M17,42 L117,42 V142 H17 Z"/>
This question was motivated by this question.
Here’s the JavaScript code I came up with:
Used like so with the path from the question:
Edit: Here’s a test page with a path that includes every command (absolute and relative) interleaved and shows that the conversion works in the now-current versions of IE, Chrome, FF, and Safari.
http://phrogz.net/svg/convert_path_to_absolute_commands.svg