Created
March 19, 2013 17:27
-
-
Save C4Code/5198175 to your computer and use it in GitHub Desktop.
Basic ColorAt example.
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
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
C4Image *image; | |
NSInteger count; | |
C4Timer *timer; | |
} | |
-(void)setup { | |
image = [C4Image imageNamed:@"C4Sky"]; | |
image.center = self.canvas.center; | |
[image loadPixelData]; | |
[self listenFor:@"pixelDataWasLoaded" andRunMethod:@"grabColors"]; | |
} | |
-(void)grabColors { | |
timer = [C4Timer timerWithInterval:0.05f target:self method:@"test" repeats:YES]; | |
[timer start]; | |
} | |
-(void)test { | |
CGPoint randomPoint = CGPointMake([C4Math randomInt:(int)image.width],[C4Math randomInt:(int)image.height]); | |
UIColor *c = [image colorAt:randomPoint]; | |
randomPoint.x += image.origin.x; | |
randomPoint.y += image.origin.y; | |
C4Shape *s = [C4Shape ellipse:CGRectMake(randomPoint.x-10, randomPoint.y-10, 20, 20)]; | |
s.fillColor = c; | |
s.lineWidth = 0.0f; | |
[self.canvas addShape:s]; | |
count++; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment