Skip to content

Instantly share code, notes, and snippets.

@C4Tutorials
Created April 10, 2013 20:58
Show Gist options
  • Save C4Tutorials/5358388 to your computer and use it in GitHub Desktop.
Save C4Tutorials/5358388 to your computer and use it in GitHub Desktop.
Create a random polygon every time you touch the canvas.
//
// 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