Last active
December 18, 2015 21:59
-
-
Save briandw/5851343 to your computer and use it in GitHub Desktop.
rantlab post 1.2
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)mouseDown:(NSEvent *)event | |
{ | |
arrow = [CAShapeLayer layer]; | |
CGFloat minMagnitude = 20; | |
CGPoint middle = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)); | |
CGPoint vector = CGPointMake(target.x-middle.x, target.y-middle.y); | |
CGFloat magnitude = sqrt(vector.x*vector.x+vector.y*vector.y); | |
CGPoint start = CGPointMake(middle.x+vector.x/magnitude*minMagnitude, middle.y+vector.y/magnitude*minMagnitude); | |
CGPathRef startPath = [RLArrowView createPathWithArrowFromPoint:middle | |
toPoint:start | |
tailWidth:2.0 | |
headWidth:10.0 | |
headLength:20.0 | |
wiggle:0]; | |
arrow.path = startPath; | |
arrow.fillColor = [NSColor redColor].CGColor; | |
arrow.lineWidth = 1; | |
arrow.fillRule = kCAFillRuleNonZero; | |
[self.layer addSublayer:arrow]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment