Created
January 20, 2013 21:09
-
-
Save jhoughjr/4581804 to your computer and use it in GitHub Desktop.
not sure what i was thinking here. anhone care to guess what i was doing?
This file contains hidden or 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
| #pragma mark Setup | |
| // Add shadows to graph labels | |
| -(void) setupLayers{ | |
| // make some locals to elminate un needed meesaging and struct acceessing | |
| const float theWidth = [self bounds].size.width; | |
| const float theHeight = [self bounds].size.height; | |
| const float theRadius = [[self circle] radius]; | |
| const CGRect axisLabelBounds = CGRectMake(0, 0, 15, 15); | |
| NSArray* dash = [NSArray arrayWithObjects:[NSNumber numberWithInt:1], [NSNumber numberWithInt:1],nil]; | |
| [[self layer] setMasksToBounds:YES]; | |
| [[self layer] setShadowOffset:CGSizeZero]; | |
| [[self layer] setShadowRadius:5.0f]; | |
| [[self layer] setShadowOpacity:1.0f]; | |
| // X AXis | |
| CAShapeLayer* anXLayer = [CAShapeLayer layer]; | |
| UIBezierPath* xPath = [UIBezierPath bezierPath]; | |
| [xPath moveToPoint:CGPointMake(25.0f,theHeight/2)]; | |
| [xPath addLineToPoint:CGPointMake(theWidth - 25.0f, theHeight/2)]; | |
| [anXLayer setLineWidth:1.0f]; | |
| [anXLayer setPath:[xPath CGPath]]; | |
| [self setXAxisLayer:anXLayer]; | |
| [[self layer] addSublayer:anXLayer]; | |
| // top X Axis | |
| UIBezierPath* topPath = [UIBezierPath bezierPath]; | |
| [topPath moveToPoint:CGPointMake(25, 25)]; | |
| [topPath addLineToPoint:CGPointMake(theWidth - 25, 25)]; | |
| CAShapeLayer* topLayer = [CAShapeLayer layer]; | |
| [topLayer setLineWidth:1.0f]; | |
| [topLayer setPath:[topPath CGPath]]; | |
| [self setTopXAxisLayer:topLayer]; | |
| [[self layer] addSublayer:topLayer]; | |
| // bottom Xaxis | |
| UIBezierPath* bottomPath = [UIBezierPath bezierPath]; | |
| [bottomPath moveToPoint:CGPointMake(25.0f, theHeight - 25.0f)]; | |
| [bottomPath addLineToPoint:CGPointMake(theWidth - 25.0f, theHeight - 25.0f)]; | |
| CAShapeLayer* bottomLayer = [CAShapeLayer layer]; | |
| [bottomLayer setLineWidth:1.0f]; | |
| [bottomLayer setPath:[bottomPath CGPath]]; | |
| [self setBottomXAxisLayer:bottomLayer]; | |
| [[self layer] addSublayer:bottomLayer]; | |
| // Y Axis | |
| CAShapeLayer* aYLayer = [CAShapeLayer layer]; | |
| UIBezierPath* yPath = [UIBezierPath bezierPath]; | |
| [yPath moveToPoint:CGPointMake(theWidth / 2, 25.0f)]; | |
| [yPath addLineToPoint:CGPointMake(theWidth / 2, theHeight - 25.0f)]; | |
| [aYLayer setLineWidth:1.0f]; | |
| [aYLayer setPath:[yPath CGPath]]; | |
| [self setYAxisLayer:aYLayer]; | |
| [[self layer] addSublayer:aYLayer]; | |
| // right Y Axis | |
| UIBezierPath* rightPath = [UIBezierPath bezierPath]; | |
| [rightPath moveToPoint:CGPointMake(theWidth - 25, 25)]; | |
| [rightPath addLineToPoint:CGPointMake(theWidth - 25, theHeight - 25 )]; | |
| CAShapeLayer* rightLayer = [CAShapeLayer layer]; | |
| [rightLayer setLineWidth:1.0f]; | |
| [rightLayer setPath:[rightPath CGPath]]; | |
| [self setRightYAxisLayer:rightLayer]; | |
| [[self layer] addSublayer:rightLayer]; | |
| // left Y axis | |
| UIBezierPath* leftPath = [UIBezierPath bezierPath]; | |
| [leftPath moveToPoint:CGPointMake(25, 25)]; | |
| [leftPath addLineToPoint:CGPointMake(25, theHeight - 25)]; | |
| CAShapeLayer* leftLayer = [CAShapeLayer layer]; | |
| [leftLayer setLineWidth:1.0f]; | |
| [leftLayer setPath:[leftPath CGPath]]; | |
| [self setLeftYAxisLayer:leftLayer]; | |
| [[self layer] addSublayer:leftLayer]; | |
| // text layers /////////////////////////////////////////////////////////////////////////////////// | |
| // left axis zero | |
| CATextLayer* leftAxisZeroTextLayer = [CATextLayer layer]; | |
| [leftAxisZeroTextLayer setString:@"0"]; | |
| [leftAxisZeroTextLayer setBounds:axisLabelBounds]; | |
| [leftAxisZeroTextLayer setPosition:CGPointMake(10, theHeight / 2)]; | |
| [leftAxisZeroTextLayer setFontSize:18.0f]; | |
| [self setLeftYAxisZeroTextLayer:leftAxisZeroTextLayer]; | |
| [[self layer] addSublayer:leftAxisZeroTextLayer]; | |
| CATextLayer* topAxisMinusLayer = [CATextLayer layer]; | |
| [topAxisMinusLayer setString:@"-1"]; | |
| [topAxisMinusLayer setBounds:axisLabelBounds]; | |
| [topAxisMinusLayer setPosition:CGPointMake(theWidth / 2 - theRadius, 7.0f)]; | |
| [topAxisMinusLayer setFontSize:18.0f]; | |
| [self setTopXAxisMinusOneTextLayer:topAxisMinusLayer]; | |
| [[self layer] addSublayer:topAxisMinusLayer]; | |
| CATextLayer* topAxisPlusLayer = [CATextLayer layer]; | |
| [topAxisPlusLayer setString:@"1"]; | |
| [topAxisPlusLayer setBounds:axisLabelBounds]; | |
| [topAxisPlusLayer setPosition:CGPointMake(theWidth/2 + theRadius, 7.0f)]; | |
| [topAxisPlusLayer setFontSize:18.0f]; | |
| [self setTopXAxisOneTextLayer:topAxisPlusLayer]; | |
| [[self layer] addSublayer:topAxisPlusLayer]; | |
| CATextLayer* bottomAxisMinus = [CATextLayer layer]; | |
| [bottomAxisMinus setString:@"-1"]; | |
| [bottomAxisMinus setBounds:axisLabelBounds]; | |
| [bottomAxisMinus setPosition:CGPointMake(theWidth / 2 - theRadius, theHeight - 7.0f)]; | |
| [bottomAxisMinus setFontSize:18.0f]; | |
| [self setBottomXAxisMinusOneTextLayer:bottomAxisMinus]; | |
| [[self layer] addSublayer:bottomAxisMinus]; | |
| CATextLayer* bottomPlusOne = [CATextLayer layer]; | |
| [bottomPlusOne setString:@"1"]; | |
| [bottomPlusOne setBounds:axisLabelBounds]; | |
| [bottomPlusOne setPosition:CGPointMake(theWidth / 2 + theRadius, theHeight - 7.0f)]; | |
| [bottomPlusOne setFontSize:18.0f]; | |
| [self setBottomXAxisOneTextLayer:bottomPlusOne]; | |
| [[self layer] addSublayer:bottomPlusOne]; | |
| CATextLayer* leftMinusOne = [CATextLayer layer]; | |
| [leftMinusOne setString:@"-1"]; | |
| [leftMinusOne setBounds:axisLabelBounds]; | |
| [leftMinusOne setPosition:CGPointMake(5.0f, theHeight/2 +theRadius)]; | |
| [leftMinusOne setFontSize:18.0f]; | |
| [self setLeftYAxisMinusOneTextLayer:leftMinusOne]; | |
| [[self layer] addSublayer:leftMinusOne]; | |
| CATextLayer* leftPlusOne = [CATextLayer layer]; | |
| [leftPlusOne setString:@"1"]; | |
| [leftPlusOne setBounds:axisLabelBounds]; | |
| [leftPlusOne setPosition:CGPointMake(5.0f, theHeight/2 - theRadius)]; | |
| [leftPlusOne setFontSize:18.0f]; | |
| [self setLeftYAxisOneTextLayer:leftPlusOne]; | |
| [[self layer] addSublayer:leftPlusOne]; | |
| CATextLayer* rightPlus = [CATextLayer layer]; | |
| [rightPlus setString:@"1"]; | |
| [rightPlus setBounds:axisLabelBounds]; | |
| [rightPlus setPosition:CGPointMake(theWidth - 5, theHeight / 2 - theRadius)]; | |
| [rightPlus setFontSize:18.0f]; | |
| [self setRightYAxisOneTextLayer:rightPlus]; | |
| [[self layer]addSublayer:rightPlus]; | |
| //right axis zero | |
| CATextLayer* rightAxisZeroLayer = [CATextLayer layer]; | |
| [rightAxisZeroLayer setString:@"0"]; | |
| [rightAxisZeroLayer setBounds:axisLabelBounds]; | |
| [rightAxisZeroLayer setPosition:CGPointMake(theWidth - 5, theHeight/2)]; | |
| [rightAxisZeroLayer setFontSize:18.0f]; | |
| [self setRightYAxisZeroTextLayer:rightAxisZeroLayer]; | |
| [[self layer] addSublayer:rightAxisZeroLayer]; | |
| CATextLayer* rightMinus = [CATextLayer layer]; | |
| [rightMinus setString:@"-1"]; | |
| [rightMinus setBounds:axisLabelBounds]; | |
| [rightMinus setPosition:CGPointMake(theWidth - 5, theHeight / 2 + theRadius)]; | |
| [rightMinus setFontSize:18.0f]; | |
| [self setRightYAxisMinusOneTextLayer:rightMinus]; | |
| [[self layer] addSublayer:rightMinus]; | |
| //quadrant TextLayers | |
| CATextLayer* firstTextLayer = [CATextLayer layer]; | |
| [firstTextLayer setString:@"I"]; | |
| [firstTextLayer setFontSize:18.0f]; | |
| [firstTextLayer setOpacity:0.5]; | |
| [self setFirstQuadrantTextLayer:firstTextLayer]; | |
| [[self layer] addSublayer:firstTextLayer]; | |
| CATextLayer* secondTextLayer = [CATextLayer layer]; | |
| [secondTextLayer setString:@"II"]; | |
| [secondTextLayer setFontSize:18.0f]; | |
| [secondTextLayer setOpacity:0.5]; | |
| [self setSecondQuadrantTextLayer:secondTextLayer]; | |
| [[self layer] addSublayer:secondTextLayer]; | |
| CATextLayer* thirdTextLayer = [CATextLayer layer]; | |
| [thirdTextLayer setString:@"III"]; | |
| [thirdTextLayer setFontSize:18.0f]; | |
| [thirdTextLayer setOpacity:0.5f]; | |
| [self setThirdQuadrantTextLayer:thirdTextLayer]; | |
| [[self layer] addSublayer:thirdTextLayer]; | |
| CATextLayer* fourthTextLayer = [CATextLayer layer]; | |
| [fourthTextLayer setString:@"IV"]; | |
| [fourthTextLayer setFontSize:18.0f]; | |
| [fourthTextLayer setOpacity:0.5f]; | |
| [self setFourthQuadrantTextLayer:fourthTextLayer]; | |
| [[self layer] addSublayer:fourthTextLayer]; | |
| // Paths ///////////////////////////////////////////////////////////////////////////// | |
| //cirlce path | |
| UIBezierPath* aCirclePath = [UIBezierPath bezierPath]; | |
| [aCirclePath addArcWithCenter:[[self circle] centerPoint] | |
| radius:[[self circle] radius] | |
| startAngle:0.0f endAngle:2 * M_PI clockwise:NO]; | |
| CAShapeLayer* aCircleLayer = [CAShapeLayer layer]; | |
| [aCircleLayer setLineWidth:1.0f]; | |
| [aCircleLayer setZPosition:-1.0]; | |
| [aCircleLayer setPath:[aCirclePath CGPath]]; | |
| [aCircleLayer setShadowOffset:CGSizeZero]; | |
| [self setCircleLayer:aCircleLayer]; | |
| [[self layer] addSublayer:aCircleLayer]; | |
| //radian | |
| UIBezierPath* radPath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* radianLayer = [CAShapeLayer layer]; | |
| [radianLayer setLineWidth:3.0f]; | |
| [radianLayer setZPosition:0.0f]; | |
| [radianLayer setShadowOffset:CGSizeZero]; | |
| [radianLayer setShadowOpacity:1.0f]; | |
| [radianLayer setPath:[radPath CGPath]]; | |
| [self setRadianLayer:radianLayer]; | |
| [[self layer] addSublayer:radianLayer]; | |
| UIBezierPath* radiusPath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* radiusLayer = [CAShapeLayer layer]; | |
| [radiusLayer setLineWidth:1.0f]; | |
| [radiusLayer setZPosition:0.0f]; | |
| [radiusLayer setPath:[radiusPath CGPath]]; | |
| [radiusLayer setShadowOffset:CGSizeZero]; | |
| [self setRadiusLayer:radiusLayer]; | |
| [[self layer] addSublayer:radiusLayer]; | |
| //sine | |
| UIBezierPath* sinepath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* sineLayer = [CAShapeLayer layer]; | |
| [sineLayer setLineWidth:1.0f]; | |
| [sineLayer setShadowOffset:CGSizeZero]; | |
| [sineLayer setPath:[sinepath CGPath]]; | |
| [self setSineLayer:sineLayer]; | |
| [[self layer] addSublayer:sineLayer]; | |
| //xt | |
| UIBezierPath* xtSinePath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* xtSineLayer = [CAShapeLayer layer]; | |
| [xtSineLayer setShadowOffset:CGSizeZero]; | |
| [xtSineLayer setLineWidth:1.0f]; | |
| [xtSineLayer setLineDashPhase:0]; | |
| [xtSineLayer setLineDashPattern:dash]; | |
| [xtSineLayer setPath:[xtSinePath CGPath]]; | |
| [self setExtendedSineLayer:xtSineLayer]; | |
| [[self layer] addSublayer:xtSineLayer]; | |
| //cosine | |
| UIBezierPath* cosPath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* cosLayer = [CAShapeLayer layer]; | |
| [cosLayer setLineWidth:1.0f]; | |
| [cosLayer setShadowOffset:CGSizeZero]; | |
| [cosLayer setPath:[cosPath CGPath]]; | |
| [self setCosineLayer:cosLayer]; | |
| [[self layer] addSublayer:cosLayer]; | |
| //xt | |
| UIBezierPath* xtCosinePath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* xtCosineLayer = [CAShapeLayer layer]; | |
| [xtCosineLayer setLineWidth:1.0f]; | |
| [xtCosineLayer setLineDashPhase:0.0f]; | |
| [xtCosineLayer setLineDashPattern:dash]; | |
| [xtCosineLayer setPath:[xtCosinePath CGPath]]; | |
| [self setExtendedCosineLayer:xtCosineLayer]; | |
| [[self layer] addSublayer:xtCosineLayer]; | |
| //Tangent | |
| UIBezierPath* tanPath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* tanLayer = [CAShapeLayer layer]; | |
| [tanLayer setLineWidth:1.0f]; | |
| [tanLayer setShadowOffset:CGSizeZero]; | |
| [tanLayer setPath:[tanPath CGPath]]; | |
| [self setTangentLayer:tanLayer]; | |
| [[self layer] addSublayer:tanLayer]; | |
| UIBezierPath* xtTangentPath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* xtTangentLayer = [CAShapeLayer layer]; | |
| [xtTangentLayer setLineWidth:1.0f]; | |
| [xtTangentLayer setLineDashPhase:0]; | |
| [xtTangentLayer setLineDashPattern:dash]; | |
| [xtTangentLayer setPath:[xtTangentPath CGPath]]; | |
| [self setExtendedTangentLayer:xtTangentLayer]; | |
| [[self layer] addSublayer:xtTangentLayer]; | |
| // secant | |
| UIBezierPath* secPath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* secLayer = [CAShapeLayer layer]; | |
| [secLayer setLineWidth:1.0f]; | |
| [secLayer setShadowOffset:CGSizeZero]; | |
| [secLayer setPath:[secPath CGPath]]; | |
| [self setSecantLayer:secLayer]; | |
| [[self layer] addSublayer:secLayer]; | |
| // cosecant | |
| UIBezierPath* cosecPath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* cosecLayer = [CAShapeLayer layer]; | |
| [cosecLayer setLineWidth:1.0f]; | |
| [cosecLayer setShadowOffset:CGSizeZero]; | |
| [cosecLayer setPath:[cosecPath CGPath]]; | |
| [self setCosecantLayer:cosecLayer]; | |
| [[self layer] addSublayer:cosecLayer]; | |
| //cot | |
| UIBezierPath* cotPath = [UIBezierPath bezierPath]; | |
| CAShapeLayer* cotLayer = [CAShapeLayer layer]; | |
| [cotLayer setLineWidth:1.0f]; | |
| [cotLayer setShadowOffset:CGSizeZero]; | |
| [cotLayer setPath:[cotPath CGPath]]; | |
| [self setCotangentLayer:cotLayer]; | |
| [[self layer] addSublayer:cotLayer]; | |
| /////////////////////// | |
| CATextLayer* sineValue = [CATextLayer layer]; | |
| [sineValue setString:@""]; | |
| [sineValue setBounds:CGRectMake(0, 0, 75, 15)]; | |
| if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { | |
| [sineValue setFontSize:14.0f]; | |
| }else{ | |
| [sineValue setFontSize:18.0f]; | |
| } | |
| [self setSineValueTextLayer:sineValue]; | |
| [[self layer] addSublayer:sineValue]; | |
| CATextLayer* cosineValue = [CATextLayer layer]; | |
| [cosineValue setString:@""]; | |
| [cosineValue setBounds:CGRectMake(0, 0, 75, 15)]; | |
| [cosineValue setTransform:CATransform3DMakeRotation(M_PI/2, 0, 0, 1)]; | |
| if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { | |
| [cosineValue setFontSize:14.0f]; | |
| }else{ | |
| [cosineValue setFontSize:18.0f]; | |
| } | |
| [self setCosineValueTextLayer:cosineValue]; | |
| [[self layer] addSublayer:cosineValue]; | |
| CATextLayer* tangentValue = [CATextLayer layer]; | |
| [tangentValue setString:@""]; | |
| if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { | |
| [tangentValue setFontSize:14.0f]; | |
| }else{ | |
| [tangentValue setFontSize:18.0f]; | |
| } | |
| [tangentValue setBounds:CGRectMake(0, 0, 75, 15)]; | |
| [self setTangentValueTextLayer:tangentValue]; | |
| [[self layer] addSublayer:tangentValue]; | |
| } | |
| -(void) setupAnimations{ | |
| [self setRadianAnimation: [CABasicAnimation animationWithKeyPath:@"path"]]; | |
| [self setSineAnimation: [CABasicAnimation animationWithKeyPath:@"path"]]; | |
| [self setCosineAnimation:[CABasicAnimation animationWithKeyPath:@"path"]]; | |
| [self setCosecantAnimation:[CABasicAnimation animationWithKeyPath:@"path"]]; | |
| [self setSecantAnimation:[CABasicAnimation animationWithKeyPath:@"path"]]; | |
| [self setCotangentAnimation:[CABasicAnimation animationWithKeyPath:@"path"]]; | |
| NSArray* anims = [NSArray arrayWithObjects:_radianAnimation, | |
| _sineAnimation, | |
| _cosineAnimation, | |
| _tangentAnimation, | |
| _cosecantAnimation, | |
| _secantAnimation, | |
| _cotangentAnimation, | |
| nil]; | |
| [self setAngleChangeAnimations:[CAAnimationGroup animation]]; | |
| [_angleChangeAnimations setAnimations:anims]; | |
| [_angleChangeAnimations setDuration:2.0]; | |
| } | |
This file contains hidden or 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
| -(void) angleDidChange:(NSNotification*) notifcation | |
| { | |
| DLog(@""); | |
| //// | |
| const float theWidth = [self bounds].size.width; | |
| const float myRad = [_circle radius]; | |
| const float mySin = [_angle sine] * myRad; | |
| const float myCos = [_angle cosine] * myRad; | |
| const float myTan = [_angle tangent] * myRad; | |
| const float centerX = [_circle centerPoint].x; | |
| const float centerY = [_circle centerPoint].y; | |
| const CGPoint centerPoint = CGPointMake(centerX, centerY); | |
| UIBezierPath* newRadianPathFinal = [UIBezierPath bezierPathWithArcCenter:CGPointMake(centerX, centerY) | |
| radius:myRad | |
| startAngle:0.0f | |
| endAngle:M_PI * 2.0f - [[[notifcation userInfo] objectForKey:@"radians"] doubleValue] | |
| clockwise:NO]; | |
| [_radianLayer addAnimation:_radianAnimation forKey:@"radianAnimation"]; | |
| [_radianLayer setPath:[newRadianPathFinal CGPath]]; | |
| UIBezierPath* newSinePath = [UIBezierPath bezierPath]; | |
| [newSinePath moveToPoint:CGPointMake(centerX + myCos, centerY)]; | |
| [newSinePath addLineToPoint:CGPointMake(centerX + myCos, centerY - mySin)]; | |
| [_sineAnimation setFromValue:(id)[_sineLayer path]]; | |
| [_sineAnimation setToValue:(id)[newSinePath CGPath]]; | |
| [_sineLayer addAnimation:_sineAnimation forKey:@"sineAnimation"]; | |
| [_sineLayer setPath:[newSinePath CGPath]]; | |
| UIBezierPath* newCosinePath = [UIBezierPath bezierPath]; | |
| [newCosinePath moveToPoint:centerPoint]; | |
| [newCosinePath addLineToPoint:CGPointMake(centerX + myCos, centerY)]; | |
| [_cosineAnimation setFromValue:(id) [_cosineLayer path]]; | |
| [_cosineAnimation setToValue:(id) [newCosinePath CGPath]]; | |
| [_cosineLayer addAnimation:_cosineAnimation forKey:@"cosineAnimation"]; | |
| [_cosineLayer setPath:[newCosinePath CGPath]]; | |
| UIBezierPath* newTangentPath = [UIBezierPath bezierPath]; | |
| [newTangentPath moveToPoint:CGPointMake(centerX + myRad, centerY)]; | |
| [newTangentPath addLineToPoint:CGPointMake(centerX + myRad, centerY - myTan)]; | |
| [_tangentAnimation setFromValue:(id)[_tangentLayer path]]; | |
| [_tangentAnimation setToValue:(id)[newTangentPath CGPath]]; | |
| [_tangentLayer addAnimation:_tangentAnimation forKey:@"tangentAnimation"]; | |
| [_tangentLayer setPath:[newTangentPath CGPath]]; | |
| UIBezierPath* newCosecantPath = [UIBezierPath bezierPath]; | |
| [newCosecantPath moveToPoint:centerPoint]; | |
| [newCosecantPath addLineToPoint:CGPointMake(centerX + [_angle cotangent] * myRad, centerY - myRad)]; | |
| [_cosecantAnimation setFromValue:(id) [_cosecantLayer path]]; | |
| [_cosecantAnimation setToValue:(id) [newCosecantPath CGPath]]; | |
| [_cosecantLayer addAnimation:_cosecantAnimation forKey:@"cosecantAnimation"]; | |
| [_cosecantLayer setPath:[newCosecantPath CGPath]]; | |
| UIBezierPath* newSecantPath = [UIBezierPath bezierPath]; | |
| [newSecantPath moveToPoint:centerPoint]; | |
| [newSecantPath addLineToPoint:CGPointMake(centerX + myRad, centerY - myTan)]; | |
| [_secantAnimation setFromValue:(id)[_secantLayer path]]; | |
| [_secantAnimation setToValue:(id)[newSecantPath CGPath]]; | |
| [_secantLayer addAnimation:_secantAnimation forKey:@"secantAnimation"]; | |
| [_secantLayer setPath:[newSecantPath CGPath]]; | |
| UIBezierPath* newCotangentPath = [UIBezierPath bezierPath]; | |
| [newCotangentPath moveToPoint:CGPointMake(centerX, centerY - myRad)]; | |
| [newCotangentPath addLineToPoint:CGPointMake(centerX + [_angle cotangent] * myRad, centerY - myRad)]; | |
| [_cotangentAnimation setFromValue:(id)[_cotangentLayer path]]; | |
| [_cotangentAnimation setToValue:(id)[newCotangentPath CGPath]]; | |
| [_cotangentLayer addAnimation:_cotangentAnimation forKey:@"cotangentAnimation"]; | |
| [_cotangentLayer setPath:[newCotangentPath CGPath]]; | |
| // textLayers | |
| [_sineValueTextLayer setPosition:CGPointMake(theWidth - 5, centerY - mySin - 8)]; | |
| [_sineValueTextLayer setString:[NSString stringWithFormat:@"%0.4f", [_angle sine]]]; | |
| [_cosineValueTextLayer setString:[NSString stringWithFormat:@"%0.4f", [_angle cosine]]]; | |
| [_cosineValueTextLayer setPosition:CGPointMake(centerX + myCos + 5, 40)]; | |
| [_tangentValueTextLayer setString:[NSString stringWithFormat:@"%0.4f", [_angle tangent]]]; | |
| [_tangentValueTextLayer setPosition:CGPointMake(theWidth - 5 , centerY - myTan - 8)] ; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment