Created
July 25, 2012 17:50
-
-
Save C4Examples/3177502 to your computer and use it in GitHub Desktop.
Stroke Start / End
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 on 12-07-19. | |
| // | |
| #import "C4WorkSpace.h" | |
| @interface C4WorkSpace () | |
| -(void)animate; | |
| @end | |
| @implementation C4WorkSpace { | |
| C4Shape *start, *end, *both; | |
| } | |
| -(void)setup { | |
| CGRect shapeFrame = CGRectMake(0, 0, self.canvas.height/6, self.canvas.height/6); | |
| //first shape will animate the start to the end | |
| start = [C4Shape ellipse:shapeFrame]; | |
| start.lineWidth = 30.0f; | |
| start.fillColor = [UIColor clearColor]; | |
| start.center = CGPointMake(self.canvas.center.x, self.canvas.height/4); | |
| [self.canvas addShape:start]; | |
| //second shape will animate the end to the start | |
| end = [C4Shape ellipse:shapeFrame]; | |
| end.strokeColor = C4BLUE; | |
| end.lineWidth = 30.0f; | |
| end.fillColor = [UIColor clearColor]; | |
| end.center = self.canvas.center; | |
| [self.canvas addShape:end]; | |
| //third shape will animate the start and end to a mid-point | |
| both = [C4Shape ellipse:shapeFrame]; | |
| both.strokeColor = C4GREY; | |
| both.lineWidth = 30.0f; | |
| both.fillColor = [UIColor clearColor]; | |
| both.center = CGPointMake(self.canvas.center.x, self.canvas.height*3/4); | |
| [self.canvas addShape:both]; | |
| [self runMethod:@"animate" afterDelay:0.1f]; | |
| } | |
| -(void)animate { | |
| start.animationDuration = 2.0f; | |
| start.animationOptions = AUTOREVERSE | REPEAT; | |
| start.strokeStart = 1.0f; | |
| end.animationDuration = 2.0f; | |
| end.animationOptions = AUTOREVERSE | REPEAT; | |
| end.strokeEnd = 0.0f; | |
| both.animationDuration = 2.0f; | |
| both.animationOptions = AUTOREVERSE | REPEAT; | |
| both.strokeStart = 0.5f; | |
| both.strokeEnd = 0.5f; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment