Skip to content

Instantly share code, notes, and snippets.

@madebyjeffrey
Created June 3, 2011 02:34
Show Gist options
  • Save madebyjeffrey/1005761 to your computer and use it in GitHub Desktop.
Save madebyjeffrey/1005761 to your computer and use it in GitHub Desktop.
pie Slice
+ pieSliceWithCentre: (CGPoint) c innerRadius: (double) ir outerRadius: (double) or
startAngle: (double) theta1 endAngle: (double) theta2 {
UIBezierPath *path = [UIBezierPath bezierPath];
if (path) {
[path moveToPoint: CGPointMake(cos(theta1)*ir, sin(theta1)*or)];
[path addLineToPoint: CGPointMake(cos(theta1)*or, sin(theta1)*or)];
[path addArcWithCenter: CGPointZero radius: or startAngle: theta1 endAngle: theta2 clockwise: NO];
[path addLineToPoint: CGPointMake(cos(theta2)*ir, sin(theta2)*ir)];
[path addArcWithCenter: CGPointZero radius: ir startAngle: theta2 endAngle:theta1 clockwise: NO];
[path closePath];
[path applyTransform: CGAffineTransformMakeTranslation(c.x, c.y)];
}
return path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment