Created
September 21, 2012 08:57
Revisions
-
imrekel revised this gist
Sep 27, 2012 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,5 +11,14 @@ - (void)drawRect:(CGRect)rect CGFloat colorWidth = self.bounds.size.width/kColorCount; CGContextFillRect(context, CGRectMake(colorWidth*i, 0, colorWidth, self.bounds.size.height)); /* if (i == _selectedColorIndex) { [[UIColor blackColor] setStroke]; CGContextSetLineWidth(context, 2.0); CGContextStrokeRect(context, CGRectMake(colorWidth*i, 1, colorWidth-1, self.bounds.size.height-1)); } */ } } -
imrekel revised this gist
Sep 21, 2012 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ - (void)handleTap:(UITapGestureRecognizer*)gestureRecognizer { CGPoint tapPoint = [gestureRecognizer locationInView:self]; CGFloat colorWidth = self.bounds.size.width/kColorCount; _selectedColorIndex = tapPoint.x / colorWidth; _selectedColor = [UIColor colorWithHue:_selectedColorIndex*(1.0/kColorCount) saturation:1.0 brightness:1.0 alpha:1.0]; [self setNeedsDisplay]; } -
imrekel revised this gist
Sep 21, 2012 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ - (id)initWithCoder:(NSCoder*)coder { self = [super initWithCoder:coder]; if (self) { self.selectedColor = [UIColor colorWithHue:0.0 saturation:1.0 brightness:1.0 alpha:1.0]; _selectedColorIndex = 0; } return self; } -
imrekel revised this gist
Sep 21, 2012 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); for (int i=0; i<kColorCount; i++) { UIColor* color = [UIColor colorWithHue:i*(1.0/kColorCount) saturation:1.0 brightness:1.0 alpha:1.0]; [color setFill]; CGFloat colorWidth = self.bounds.size.width/kColorCount; CGContextFillRect(context, CGRectMake(colorWidth*i, 0, colorWidth, self.bounds.size.height)); } } -
imrekel revised this gist
Sep 21, 2012 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ - (void)drawCircleWithCenter: (CGPoint)center radius: (CGFloat)radius color:(UIColor*)color { // Új grafikus kontextus létrehozása, képre való rajzoláshoz UIGraphicsBeginImageContextWithOptions(self.canvas.bounds.size, 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 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ - (void)drawSquareWithCenter: (CGPoint)center width: (CGFloat)width color:(UIColor*)color { // Új grafikus kontextus létrehozása, képre való rajzoláshoz UIGraphicsBeginImageContextWithOptions(self.canvas.bounds.size, 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 -
imrekel revised this gist
Sep 21, 2012 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ - (void)drawSquareWithCenter: (CGPoint)center width: (CGFloat)width color:(UIColor*)color { // Új grafikus kontextus létrehozása, képre való rajzoláshoz UIGraphicsBeginImageContextWithOptions(CGSizeMake([UIScreen mainScreen].bounds.size.height, [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]; CGContextFillRect(context, CGRectMake(center.x-width/2, center.y-width/2, width, width)); // 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(); } -
imrekel renamed this gist
Sep 21, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
imrekel created this gist
Sep 21, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ - (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(); }