Created
July 25, 2012 17:12
-
-
Save C4Examples/3177319 to your computer and use it in GitHub Desktop.
Line Widths (Advanced)
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 an x position, 1% of the width of the canvas | |
CGFloat x1 = self.canvas.width*0.01f; | |
//create a second x position, equally distant from the right edge of the canvas | |
CGFloat x2 = self.canvas.width-x1; | |
//create and array of points to use for lines | |
CGPoint linePoints[2] = {CGPointMake(x1, 75),CGPointMake(x2, 75)}; | |
//create the first line, at the default width | |
C4Shape *line = [C4Shape line:linePoints]; | |
[self.canvas addShape:line]; | |
//shift the line points | |
linePoints[0].y *= 2; | |
linePoints[1].y *= 2; | |
//loop until the screen is full | |
for(int i = 0; linePoints[0].y < self.canvas.height; i++) { | |
//define the current line with, exponentially growing | |
CGFloat currentLineWidth = 2.0f + [C4Math pow:1.15f raisedTo:i]; | |
//shift the line points based on the current line width (with a little gap) | |
linePoints[0].y += currentLineWidth+1.0f; | |
linePoints[1].y += currentLineWidth+1.0f; | |
//create a new line and add it to the canvas | |
C4Shape *newLine = [C4Shape line:linePoints]; | |
newLine.lineWidth = currentLineWidth; | |
[self.canvas addShape:newLine]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment