Last active
December 17, 2015 03:39
-
-
Save C4Tutorials/5545252 to your computer and use it in GitHub Desktop.
boilerplate
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
@implementation C4WorkSpace | |
-(void)setup { | |
C4Image *table = [C4Image imageNamed:@"C4Table"]; | |
table.center = self.canvas.center; | |
C4Image *sky = [C4Image imageNamed:@"C4Sky"]; | |
[self.canvas addObjects:@[table,sky]]; | |
C4Image *icon = [C4Image imageNamed:@"[email protected]"]; | |
} | |
@end | |
@implementation C4WorkSpace | |
-(void)setup { | |
C4Image *table = [C4Image imageNamed:@"C4Table"]; | |
table.center = self.canvas.center; | |
C4Image *sky = [C4Image imageNamed:@"C4Sky"]; | |
sky.width /= 2; | |
[table addImage:sky]; | |
[self.canvas addImage:table]; | |
} | |
@end | |
@implementation C4WorkSpace | |
-(void)setup { | |
C4Image *table = [C4Image imageNamed:@"C4Table"]; | |
table.center = self.canvas.center; | |
C4Image *sky = [C4Image imageNamed:@"C4Sky"]; | |
[table colorInvert]; | |
[table colorDodge:sky]; | |
[self.canvas addImage:table]; | |
} | |
@end | |
@implementation C4WorkSpace { | |
C4Image *animated; | |
} | |
-(void)setup { | |
[C4Image defaultStyle].borderColor = C4BLUE; | |
[C4Image defaultStyle].borderWidth = 10.0f; | |
NSArray *names = @[ | |
@"C4Spin01", | |
@"C4Spin02", | |
@"C4Spin03", | |
@"C4Spin04", | |
@"C4Spin05", | |
@"C4Spin06", | |
@"C4Spin07", | |
@"C4Spin08", | |
@"C4Spin09", | |
@"C4Spin10", | |
@"C4Spin11" | |
]; | |
animated = [C4Image animatedImageWithNames:names]; | |
[self.canvas addImage:animated]; | |
animated.animatedImageDuration = 2.0f; | |
animated.center = self.canvas.center; | |
} | |
-(void)touchesBegan { | |
[animated play]; | |
} | |
@end | |
@implementation C4WorkSpace { | |
C4Image *pixelImage; | |
} | |
-(void)setup { | |
pixelImage = [C4Image imageNamed:@"C4Sky"]; | |
pixelImage.userInteractionEnabled = NO; | |
[pixelImage loadPixelData]; | |
pixelImage.center = self.canvas.center; | |
[self.canvas addImage:pixelImage]; | |
} | |
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { | |
CGPoint p = [[touches anyObject] locationInView:pixelImage]; | |
UIColor *c = [pixelImage colorAt:p]; | |
self.canvas.backgroundColor = c; | |
} | |
@end | |
@implementation C4WorkSpace { | |
C4Movie *movie; | |
} | |
-(void)setup { | |
movie = [C4Movie movieNamed:@"inception.mov"]; | |
movie.center = self.canvas.center; | |
[self.canvas addMovie:movie]; | |
movie.shouldAutoplay = YES; | |
movie.loops = YES; | |
} | |
// | |
//-(void)touchesBegan { | |
// if(movie.isPlaying) { | |
// [movie pause]; | |
// } else { | |
// [movie play]; | |
// } | |
//} | |
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { | |
CGPoint p = [[touches anyObject] locationInView:self.canvas]; | |
CGFloat value = p.x / self.canvas.width; | |
// [movie seekToTime:value]; | |
movie.rate = value; | |
} | |
@end | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
C4Movie *movie; | |
C4Shape *s; | |
C4GL *gl; | |
} | |
-(void)setup { | |
movie = [C4Movie movieNamed:@"inception.mov"]; | |
movie.center = self.canvas.center; | |
[self.canvas addMovie:movie]; | |
movie.shouldAutoplay = YES; | |
movie.loops = YES; | |
s = [C4Shape rect:CGRectMake(0, 0, 200, 200)]; | |
s.center = self.canvas.center; | |
[self.canvas addShape:s]; | |
s.zPosition = 1; | |
gl = [C4GL glWithFrame:s.frame]; | |
[self.canvas addGL:gl]; | |
gl.zPosition = 3; | |
} | |
-(void)touchesBegan { | |
movie.zPosition = 2; | |
[gl startAnimation]; | |
} | |
@end | |
@implementation C4WorkSpace | |
-(void)setup { | |
circle = [C4Shape ellipse:CGRectMake(0,0,100,100)]; | |
[self.canvas addShape:circle]; | |
[self listenFor:@"nobodyListensToMe" andRunMethod:@"thatsBecauseYoureBoring"]; | |
[self listenFor:@"touchesBegan" andRunMethod:@"thatsBecauseYoureBoring"]; | |
} | |
-(void)touchesBegan { | |
self.canvas.backgroundColor = [UIColor colorWithRed:[C4Math randomInt:100]/100.0f green:0 blue:0 alpha:1]; | |
[self postNotification:@"nobodyListensToMe"]; | |
} | |
-(void)thatsBecauseYoureBoring { | |
C4Log(@"That's because you're boring"); | |
} | |
@end | |
@implementation C4WorkSpace { | |
C4Shape *circle; | |
MyShape *square; | |
} | |
-(void)setup { | |
circle = [C4Shape ellipse:CGRectMake(0,0,100,100)]; | |
[self.canvas addShape:circle]; | |
square = [[MyShape alloc] initWithFrame:CGRectMake(200,0,100,100)]; | |
[square rect:square.frame]; | |
[self.canvas addShape:square]; | |
[self listenFor:@"My Shape Was Touched" andRunMethod:@"thatsBecauseYoureBoring"]; | |
} | |
-(void)touchesBegan { | |
C4Log(@"touchesBegan"); | |
} | |
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { | |
CGPoint p = [[touches anyObject] locationInView:self.canvas]; | |
C4Log(@"%4.2f,%4.2f",p.x,p.y); | |
} | |
-(void)touchesMoved { | |
C4Log(@"touchesMoved"); | |
} | |
-(void)touchesEnded { | |
C4Log(@"touchesEnded"); | |
} | |
@end | |
@implementation C4WorkSpace { | |
C4Shape *circle; | |
C4Image *image; | |
} | |
-(void)setup { | |
image = [C4Image imageNamed:@"C4Sky"]; | |
image.center = self.canvas.center; | |
[self.canvas addImage:image]; | |
circle = [C4Shape ellipse:CGRectMake(0, 0, 100, 100)]; | |
image.mask = circle; | |
} | |
-(void)touchesBegan { | |
circle.animationDuration = 2.0f; | |
circle.animationOptions = REPEAT | AUTOREVERSE | EASEOUT; | |
circle.alpha = 0.0f; | |
[circle rect:CGRectMake(0, 0, 500, 500)]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-(void)setup {
CGFloat circleSize = 10.0f;
CGFloat circleGap = 10.0f;
}
-(void)animate:(C4Shape *)shape {
shape.animationDuration = 5.0f;
shape.animationOptions = LINEAR | REPEAT;
shape.rotationX = TWO_PI;
shape.rotationY = TWO_PI;
}