Created
November 28, 2013 19:04
-
-
Save Grafikart/7696781 to your computer and use it in GitHub Desktop.
Donnuts !
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
var circleSegment = function(centerX, centerY, radius, startAngle, endAngle) { | |
var PI = Math.PI, | |
cos = Math.cos, | |
sin = Math.sin | |
var startRadians = startAngle * PI / 180, | |
endRadians = endAngle * PI / 180, | |
largeArc = ((endRadians - startRadians) % (PI * 2)) > PI ? 1 : 0 | |
var startX = centerX + cos(startRadians) * radius, | |
startY = centerY + sin(startRadians) * radius, | |
endX = centerX + cos(endRadians) * radius, | |
endY = centerY + sin(endRadians) * radius | |
var commands = [ | |
'M', startX, startY, | |
'A', radius, radius, 0, largeArc, 1, endX, endY | |
] | |
return commands.join(' ') | |
} | |
var $bar = $('.bar'); | |
var center = 100, | |
radius = 77.5, | |
startAngle = 90, | |
endAngle = 360 + 90, | |
duration = 2; | |
var path = circleSegment(center, center, radius, -90, 269); | |
$bar.attr('d', path); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment