Created
April 10, 2013 20:58
-
-
Save C4Tutorials/5358388 to your computer and use it in GitHub Desktop.
Create a random polygon every time you touch the canvas.
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 characters
// | |
// C4WorkSpace.m | |
// Examples | |
// | |
// Created by Travis Kirton. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
C4Shape *s; | |
} | |
-(void)setup { | |
CGPoint pts[10]; | |
for(int i = 0; i < 10; i++) { | |
pts[i] = CGPointMake([C4Math randomInt:386], [C4Math randomInt:386]); | |
} | |
s = [C4Shape polygon:pts pointCount:10]; | |
s.lineWidth = 20.0f; | |
s.center = self.canvas.center; | |
[self.canvas addShape:s]; | |
} | |
-(void)touchesBegan { | |
CGPoint pts[10]; | |
for(int i = 0; i < 10; i++) { | |
pts[i] = CGPointMake([C4Math randomInt:386], [C4Math randomInt:386]); | |
} | |
[s polygon:pts pointCount:10]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment