どうやってもできるけど、まあこうやってメモしておくと使うときがあるかも。
- (void)drawArrawFrom:(NSPoint)from to:(NSPoint)to color:(NSColor *)color {
NSPoint arrowPoint1, arrowPoint2;
double theta = atan2(to.y - from.y, to.x - from.x);
NSBezierPath *bezier = [NSBezierPath bezierPath];
arrowPoint1 = NSMakePoint(
to.x - cos(theta + 3.14/6) * 18,
to.y - sin(theta + 3.14/6) * 18);
arrowPoint2 = NSMakePoint(
to.x - cos(theta - 3.14/6) * 18,
to.y - sin(theta - 3.14/6) * 18);
[bezier moveToPoint:from];
[bezier lineToPoint:to];
[bezier lineToPoint:arrowPoint1];
[bezier lineToPoint:to];
[bezier lineToPoint:arrowPoint2];
[bezier setLineWidth:3.0];
[bezier setLineJoinStyle:NSRoundLineJoinStyle];
[color set];
[bezier stroke];
}
コメントを書く