Created
March 4, 2020 06:38
-
-
Save ffantasy/c37e1e9cbdeaa4ed920f47d1ca2d7932 to your computer and use it in GitHub Desktop.
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 polarToCartesian(centerX, centerY, radius, angleInDegrees) { | |
var angleInRadians = (angleInDegrees-90) * Math.PI / 180.0; | |
return { | |
x: centerX + (radius * Math.cos(angleInRadians)), | |
y: centerY + (radius * Math.sin(angleInRadians)) | |
}; | |
} | |
function getArcPath(centerX, centerY, radius, startAngle, endAngle){ | |
var start = polarToCartesian(centerX, centerY, radius, endAngle); | |
var end = polarToCartesian(centerX, centerY, radius, startAngle); | |
var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1"; | |
var d = [ | |
"M", start.x, start.y, | |
"A", radius, radius, 0, largeArcFlag, 0, end.x, end.y | |
].join(" "); | |
return d; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment