Skip to content

Instantly share code, notes, and snippets.

@Grafikart
Created November 28, 2013 19:04
Show Gist options
  • Save Grafikart/7696781 to your computer and use it in GitHub Desktop.
Save Grafikart/7696781 to your computer and use it in GitHub Desktop.
Donnuts !
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