Given an SVG Path element, how can I convert all path commands into relative coordinates? For example, convert this path (which includes every command, absolute and relative, interleaved):
<path d="M3,7 L13,7 m-10,10 l10,0 V27 H23 v10 h10 C33,43 38,47 43,47 c0,5 5,10 10,10 S63,67 63,67 s-10,10 10,10 Q50,50 73,57 q20,-5 0,-10 T70,40 t0,-15 A5,5 45 1 0 40,20 a5,5 20 0 1 -10,-10 Z" />
into this equivalent path:
<path d="m3,7 l10,0 m-10 10 l10,0 v10 h10 v10 h10 c0,6 5,10 10,10 c0,5 5,10 10,10 s10,10 10,10 s-10,10 10,10 q-23,-27 0,-20 q20,-5 0,-10 t-3,-7 t0-15 a5,5 45 1 0 -30,-5 a5,5 20 0 1 -10,-10 z"/>
This question was motivated by this question.
Advertisement
Answer
Snap.SVG has Snap.path.toRelative()
.
var rel = Snap.path.toRelative(abspathstring);