Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created June 5, 2013 19:30
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/5716541 to your computer and use it in GitHub Desktop.
Save C4Code/5716541 to your computer and use it in GitHub Desktop.
H E L L O, my name is...
//
// C4WorkSpace.m
// test
//
// Created by travis on 2013-05-28.
// Copyright (c) 2013 Slant. All rights reserved.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace
-(void)setup {
C4Font *helloFont = [C4Font fontWithName:@"Avenir-Medium" size:120];
C4Shape *hello = [C4Shape shapeFromString:@"H E L L O" withFont:helloFont];
hello.lineWidth = 0.0f;
hello.center = CGPointMake(self.canvas.center.x, hello.height);
C4Font *nameFont = [C4Font fontWithName:@"Avenir-Light" size:60];
C4Shape *myNameIs = [C4Shape shapeFromString:@"my name is" withFont:nameFont];
myNameIs.lineWidth = 0.0f;
myNameIs.center = CGPointMake(hello.center.x, hello.center.y + hello.height);
self.canvas.multipleTouchEnabled = YES;
[self.canvas addObjects:@[hello,myNameIs]];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *currentTouch = [touches anyObject];
CGPoint currentPoint = [currentTouch locationInView:self.canvas];
CGPoint previousPoint = [currentTouch previousLocationInView:self.canvas];
NSInteger distance = (NSInteger)[C4Vector distanceBetweenA:currentPoint andB:previousPoint];
if(distance > 2) {
CGPoint linePoints[2] = {previousPoint, currentPoint};
C4Shape *line = [C4Shape line:linePoints];
line.lineWidth = 12;
line.lineCap = CAPROUND;
line.strokeColor = distance % 2 == 0 ? C4RED : C4BLUE;
[self.canvas addShape:line];
}
event = event;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment