Skip to content

Instantly share code, notes, and snippets.

@C4Examples
Created April 23, 2013 09:06
Show Gist options
  • Select an option

  • Save C4Examples/5442003 to your computer and use it in GitHub Desktop.

Select an option

Save C4Examples/5442003 to your computer and use it in GitHub Desktop.

Revisions

  1. C4Examples created this gist Apr 23, 2013.
    45 changes: 45 additions & 0 deletions C4Workspace.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    //
    // C4WorkSpace.m
    // Examples
    //
    // Created by Travis Kirton and Greg Debicki.
    //

    #import "C4WorkSpace.h"

    @implementation C4WorkSpace {
    NSMutableArray *shapes;
    }

    -(void)setup {
    shapes = [@[] mutableCopy];

    for(int i = 0; i < 40; i++) {
    C4Shape *s = [C4Shape rect:CGRectMake(0, 0, 600, 20)];
    s.fillColor = [UIColor colorWithWhite:0.0f alpha:i/40.0f];
    s.strokeColor = [UIColor clearColor];
    s.anchorPoint = CGPointMake(0.5f,8.0f+i);
    CGPoint p = self.canvas.center;
    p.y += self.canvas.height/2;
    s.center = p;
    [shapes addObject:s];
    }
    [self.canvas addObjects:shapes];
    [self runMethod:@"setupAnimations" afterDelay:0.1f];
    }

    -(void)setupAnimations {
    for(int i = 0; i < [shapes count]; i++) {
    C4Shape *s = shapes[i];
    s.animationDuration = i*.01f + 1.0f;
    [self animateObject:s];
    }
    }

    -(void)animateObject:(C4Shape *)shape {
    shape.animationDuration *= 0.98f;
    shape.rotation += TWO_PI;
    [self runMethod:@"animateObject:" withObject:shape afterDelay:shape.animationDuration+ 0.2f];
    }

    @end