Created
August 19, 2012 19:32
-
-
Save tamask/3397189 to your computer and use it in GitHub Desktop.
SVG arc
This file contains 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 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