0

I am trying to convert a disconnected path in SVG into SVG lines . e.g If I have drawn a triangle using

<path id="path" d="M150 0 L75 200 L225 200 Z" /> 

then after conversion , i should get 3 SVG lines

<line x1=150 y1=0 x2=75 y2=200/>
<line x1=75 y1=200 x2=225 y2=200 />
<line x1=225 y1=200 x2=150 y2=0 />

And this path can be disconnected that it can have multiple Moveto commands like

<path id="path" d="M150 0 L75 200 L225 200 M450 200 L375 400 L525 400 Z" />

In this case I should get 6 SVG lines. Also moveto and lineto commands may be absolute and relative Any help ? Thanks

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
Harshal
  • 961
  • 1
  • 11
  • 26
  • 1
    Have a look at Robert Longson's [answer](http://stackoverflow.com/a/9103307/4235784) to [*"Turn SVG path into line segments"*](/q/9102563). – altocumulus Jan 10 '16 at 12:17
  • Thanks for the help altocumulus. I had already gone throught the link you provided. With some help from it , I wrote code to convert Path in Polyline. Here is fiddle https://jsfiddle.net/fq9n7f76/18/ – Harshal Jan 10 '16 at 17:13
  • 1
    Possible duplicate of [Turn SVG path into line segments](http://stackoverflow.com/questions/9102563/turn-svg-path-into-line-segments) – Asons Jan 10 '16 at 19:16

0 Answers0