Skip to content

Instantly share code, notes, and snippets.

@C4Tutorials
Last active December 16, 2015 06:19
Show Gist options
  • Save C4Tutorials/5390712 to your computer and use it in GitHub Desktop.
Save C4Tutorials/5390712 to your computer and use it in GitHub Desktop.
A Spiral made of small points
//
// C4WorkSpace.m
// Complex Shapes Tutorial
//
// Created by Travis Kirton.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace
-(void)setup {
for(int i = 0; i < 64; i++) {
//generate the radius and angle
CGFloat radius = 4 * i;
CGFloat angle = TWO_PI / 16 * i;
//calculate a point based on the radius and angle, using polar equation: {r * sin(theta), r * cos(theta)}
CGPoint currentPosition = CGPointMake(radius*[C4Math sin:angle], radius*[C4Math cos:angle]);
currentPosition.x += self.canvas.center.x;
currentPosition.y += self.canvas.center.y;
//create a point, center it and add it to the canvas
C4Shape *point = [C4Shape ellipse:CGRectMake(0, 0, 8, 8)];
point.center = currentPosition;
[self.canvas addShape:point];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment