Posted By

Pjotor on 10/19/15


path convertion points svg ES2015

Versions (?)

SVG Polygon => SVG Path

 / Published in: JavaScript


Convert SVG polygon points to a SVG path with this little lexical. (Supports scale and precision rounding)

  1. var polygonToPath=(points, scale, precision, P)=>(P=points.split(/\s+|,/).map(i=>scale?precision?(i*scale).toPrecision(precision):i*scale:i),'M'+P.shift()+','+P.shift()+'L'+P.join(' ')+'z');

Report this snippet  

You need to login to post a comment.