Skip to content

Instantly share code, notes, and snippets.

@JoostKiens
Created August 23, 2017 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoostKiens/4480097df1410a9e7fea9c7085279708 to your computer and use it in GitHub Desktop.
Save JoostKiens/4480097df1410a9e7fea9c7085279708 to your computer and use it in GitHub Desktop.
Convert SVG circle arguments to path description
function createPathDFromCircle(cx, cy, r) {
return `d="
M ${cx} ${cy}
m -${r}, 0
a ${r},${r} 0 1,0 ${(r * 2)},0
a ${r},${r} 0 1,0 ${-(r * 2)},0
"`
}
function createPathDFromCircleStartOnTop(cx, cy, r) {
return `d="
M ${cx} ${cy}
m 0, -${r}
a ${r},${r} 0 1,0 0,${(r * 2)}
a ${r},${r} 0 1,0 0,${-(r * 2)}
"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment