Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created June 12, 2013 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save C4Code/5767573 to your computer and use it in GitHub Desktop.
Save C4Code/5767573 to your computer and use it in GitHub Desktop.
embedding objects in another object and rotating them.
//
// C4WorkSpace.m
// centered
//
// Created by moi on 13-06-12.
// Copyright (c) 2013 moi. All rights reserved.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace
-(void)setup {
NSInteger gap = 10;
CGFloat squareWidth = 50;
CGFloat containerWidth = 6 * gap + 6 * squareWidth;
C4Shape *container = [C4Shape rect:CGRectMake(0, 0, containerWidth, containerWidth)];
container.lineWidth = 0;
container.fillColor = [UIColor clearColor];
for(int i = 0; i < 36; i++) {
CGFloat x = i%6 * (squareWidth + gap);
CGFloat y = i/6 * (squareWidth + gap);
C4Shape *rect = [C4Shape rect:CGRectMake(x, y, squareWidth, squareWidth)];
[container addShape:rect];
}
[self.canvas addShape:container];
container.center = self.canvas.center;
container.borderWidth = 1.0f;
container.rotation = QUARTER_PI;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment