Skip to content

Instantly share code, notes, and snippets.

@imrekel
Created September 21, 2012 08:57
Show Gist options
  • Save imrekel/3760460 to your computer and use it in GitHub Desktop.
Save imrekel/3760460 to your computer and use it in GitHub Desktop.
bme-ios - iPaint
- (void)drawCircleWithCenter: (CGPoint)center radius: (CGFloat)radius color:(UIColor*)color
{
// Új grafikus kontextus létrehozása, képre való rajzoláshoz
UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.canvas.bounds.size, [UIScreen mainScreen].bounds.size.height), NO, [[UIScreen mainScreen] scale]);
// Ha már van valami a képen, akkor azt kirajzoljuk az új grafikus kontextusra
// UIImage drawAtPoint automatikusan az aktuális grafikus kontextust használja
if (self.canvas.image)
[self.canvas.image drawAtPoint:CGPointZero];
// Grafikus kontextus elkérése és rajzolás
CGContextRef context = UIGraphicsGetCurrentContext();
[color setStroke];
[color setFill];
CGContextFillEllipseInRect(context, CGRectMake(center.x-radius, center.y-radius, radius*2, radius*2));
// A grafikus kontextus tartalmának lekérése egy UIImage-ben, majd
// ennek beállítása a UIImageView-hez
self.canvas.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment