Created
July 18, 2018 06:22
-
-
Save Holger-Will/d62d263a167b46d5319ce7658c914d73 to your computer and use it in GitHub Desktop.
convert an svg path to line segments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flatten(path,num){ | |
var l = path.getTotalLength() | |
var p = path.getPointAtLength(0) | |
var d = `M${p.x} ${p.y}` | |
for(var i = (l/num);i<=l;i+=(l/num)){ | |
p = path.getPointAtLength(i) | |
d+=`L${p.x} ${p.y}` | |
} | |
path.setAttribute("d",d+"z") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/41534487/svg-curve-to-many-small-straight-lines/41537362#41537362