How do I convert SVG paths to xy-coordinates? Until recently I used a webpage, which used the jQuery code below. However, I have no idea how to execute the code on a locally stored SVG file. Any help or recommended tool (for Mac) is appreciated.
$("path").each(function(i){
var path = this;
var len = path.getTotalLength();
var p=path.getPointAtLength(0);
stp=p.x+","+p.y
for(var i=1; i<len; i++){
p=path.getPointAtLength(i);
stp=stp+" "+p.x+","+p.y;
}
$(path).replaceWith('<polygon points="' + stp + '" />');
});
All right. Sometimes it is just about knowing the right search terms. In this case, the path coordinates I was talking about is called Well-known text (WKT)—of course. So, a quick google search gave me this SVG to WKT converter. Perfect for my needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With