Last active
December 17, 2015 00:38
-
-
Save C4Code/5522440 to your computer and use it in GitHub Desktop.
Gestalt - Code for the first session of C4: Media & Interactivity workshop at VIVO Media Arts
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 | |
// Gestalt | |
// | |
// Created by Travis Kirton on 2013-05-05. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace | |
-(void)setup { | |
[self cube3]; | |
} | |
-(void)cube1 { | |
CGPoint cubePolyPoints[6] = { | |
CGPointMake(100, 0), | |
CGPointMake(200, 50), | |
CGPointMake(200, 164), | |
CGPointMake(100, 214), | |
CGPointMake(0, 164), | |
CGPointMake(0, 50) | |
}; | |
C4Shape *cubeOutline = [C4Shape polygon:cubePolyPoints pointCount:6]; | |
[cubeOutline closeShape]; | |
CGPoint linePoints[2] = {cubePolyPoints[0],cubePolyPoints[3]}; | |
C4Shape *line1 = [C4Shape line:linePoints]; | |
linePoints[0] = cubePolyPoints[1]; | |
linePoints[1] = cubePolyPoints[4]; | |
C4Shape *line2 = [C4Shape line:linePoints]; | |
linePoints[0] = cubePolyPoints[2]; | |
linePoints[1] = cubePolyPoints[5]; | |
C4Shape *line3 = [C4Shape line:linePoints]; | |
[cubeOutline addObjects:@[line1,line2,line3]]; | |
cubeOutline.center = self.canvas.center; | |
[self addShape:cubeOutline]; | |
} | |
-(void)cube2 { | |
CGPoint cubePolyPoints[6] = { | |
CGPointMake(50, 0), | |
CGPointMake(150, 0), | |
CGPointMake(150, 100), | |
CGPointMake(100, 150), | |
CGPointMake(0, 150), | |
CGPointMake(0, 50) | |
}; | |
C4Shape *cubeOutline = [C4Shape polygon:cubePolyPoints pointCount:6]; | |
[cubeOutline closeShape]; | |
CGPoint connectionPoints[2] = {CGPointMake(50, 100),CGPointMake(100, 50)}; | |
CGPoint linePoints[2] = {cubePolyPoints[0],connectionPoints[0]}; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[2]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[4]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[1]; | |
linePoints[1] = connectionPoints[1]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[3]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[5]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
cubeOutline.center = self.canvas.center; | |
[self.canvas addShape:cubeOutline]; | |
} | |
-(void)cube3 { | |
[C4Shape defaultStyle].fillColor = [UIColor clearColor]; | |
[C4Shape defaultStyle].strokeColor = [UIColor whiteColor]; | |
CGPoint cubePolyPoints[6] = { | |
CGPointMake(50, 0), | |
CGPointMake(150, 0), | |
CGPointMake(150, 100), | |
CGPointMake(100, 150), | |
CGPointMake(0, 150), | |
CGPointMake(0, 50) | |
}; | |
C4Shape *cubeOutline = [C4Shape polygon:cubePolyPoints pointCount:6]; | |
[cubeOutline closeShape]; | |
C4Shape *container = [cubeOutline copy]; | |
container.lineWidth = 0.0f; | |
container.fillColor = [UIColor clearColor]; | |
CGRect circleFrame = CGRectMake(0, 0, 36, 36); | |
C4Shape *point = [C4Shape ellipse:circleFrame]; | |
point.fillColor = C4GREY; | |
point.lineWidth = 0.0f; | |
for(int i = 0; i < 6; i++) { | |
C4Shape *circle = [point copy]; | |
circle.center = cubePolyPoints[i]; | |
[container addShape:circle]; | |
} | |
CGPoint connectionPoints[2] = {CGPointMake(50, 100),CGPointMake(100, 50)}; | |
for(int i = 0; i < 2; i++) { | |
C4Shape *circle = [point copy]; | |
circle.center = connectionPoints[i]; | |
[container addShape:circle]; | |
} | |
[container addShape:cubeOutline]; | |
CGPoint linePoints[2] = {cubePolyPoints[0],connectionPoints[0]}; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[2]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[4]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[1]; | |
linePoints[1] = connectionPoints[1]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[3]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
linePoints[0] = cubePolyPoints[5]; | |
[cubeOutline addShape:[C4Shape line:linePoints]]; | |
container.center = self.canvas.center; | |
[self.canvas addShape:container]; | |
[self runMethod:@"animate:" withObject:container afterDelay:1.0f]; | |
} | |
-(void)animate:(C4Shape *)shape { | |
shape.animationDuration = 5.0f; | |
shape.animationOptions = LINEAR | REPEAT; | |
shape.rotation = TWO_PI; | |
} | |
-(void)triangleWithPolygons { | |
[C4Shape defaultStyle].lineWidth = 0.0f; | |
C4Shape *circle1, *circle2, *circle3; | |
circle1 = [C4Shape ellipse:CGRectMake(0, 0, 192, 192)]; | |
circle2 = [C4Shape ellipse:CGRectMake(0, 0, 192, 192)]; | |
circle3 = [C4Shape ellipse:CGRectMake(0, 0, 192, 192)]; | |
circle1.center = CGPointMake(self.canvas.center.x - 110, self.canvas.center.y + 75); | |
circle2.center = CGPointMake(self.canvas.center.x + 110, self.canvas.center.y + 75); | |
circle3.center = CGPointMake(self.canvas.center.x, self.canvas.center.y - 120); | |
CGPoint trianglePoints[3] = { | |
circle1.center, | |
circle2.center, | |
circle3.center | |
}; | |
C4Shape *triangle = [C4Shape triangle:trianglePoints]; | |
triangle.fillColor = [UIColor whiteColor]; | |
[self.canvas addObjects:@[circle1, circle2, circle3, triangle]]; | |
} | |
-(void)triangleWithWedges { | |
[C4Shape defaultStyle].lineWidth = 0.0f; | |
C4Shape *wedge1, *wedge2, *wedge3; | |
CGPoint currentCenter = CGPointMake(self.canvas.center.x - 110, self.canvas.center.y + 75); | |
wedge1 = [C4Shape wedgeWithCenter:currentCenter | |
radius:96 | |
startAngle:0 | |
endAngle:TWO_PI * 5/6 | |
clockwise:YES]; | |
currentCenter = CGPointMake(self.canvas.center.x + 110, self.canvas.center.y + 75); | |
wedge2 = [C4Shape wedgeWithCenter:currentCenter | |
radius:96 | |
startAngle:TWO_PI * 4/6 | |
endAngle:PI | |
clockwise:YES]; | |
currentCenter = CGPointMake(self.canvas.center.x, self.canvas.center.y - 120); | |
wedge3 = [C4Shape wedgeWithCenter:currentCenter | |
radius:96 | |
startAngle:TWO_PI*2/6 | |
endAngle:TWO_PI/6 | |
clockwise:YES]; | |
[self.canvas addObjects:@[wedge1,wedge2,wedge3]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment