Skip to content

Instantly share code, notes, and snippets.

@tamask
Created August 19, 2012 19:32
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 tamask/3397189 to your computer and use it in GitHub Desktop.
Save tamask/3397189 to your computer and use it in GitHub Desktop.
SVG arc
function arc(x, y, rx, ry, from, to) {
var ar = from * Math.PI / 180;
var ax = x + rx * Math.cos(ar);
var ay = y + ry * Math.sin(ar);
var br = to * Math.PI / 180;
var bx = x + rx * Math.cos(br);
var by = y + ry * Math.sin(br);
var sweep = (to - from) > 180 ? 1 : 0;
return (
' M ' + ax + ' ' + ay +
' A ' + rx + ' ' + ry + ' 0 ' + sweep +
' 1 ' + bx + ' ' + by);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment