Created
July 25, 2012 17:27
-
-
Save C4Examples/3177399 to your computer and use it in GitHub Desktop.
Advanced stroke start / end
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
// | |
// C4WorkSpace.m | |
// Examples | |
// | |
// Created by Travis Kirton on 12-07-19. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace | |
-(void)setup { | |
//create and array of points to use for lines | |
CGPoint linePoints[2] = {CGPointZero,CGPointMake(self.canvas.width,0.0f)}; | |
//figure out the total number of lines to draw | |
CGFloat totalLineCount = self.canvas.height / 6.0f; //default lineWidth (5.0f) + 1.0f gap between each line | |
//figure out displacement of strokeStart and strokeEnd | |
CGFloat strokeDisplacement = 0.5f / totalLineCount; | |
for(int i = 0; i < totalLineCount; i++) { | |
linePoints[0].y = i*6.0f + 2.5f; | |
linePoints[1].y = linePoints[0].y; | |
//create a new line | |
C4Shape *newLine = [C4Shape line:linePoints]; | |
//determine the current displacement of the ends of the line | |
CGFloat currentDisplacement = strokeDisplacement*(i+1); | |
newLine.strokeStart = 0.5 - currentDisplacement; | |
newLine.strokeEnd = 0.5f + currentDisplacement; | |
//... and add it to the canvas | |
[self.canvas addShape:newLine]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment