通过 3 个 NSPoints 平滑曲线

Smooth curve through 3 NSPoints

NSBezierPath *angle = [NSBezierPath bezierPath];
[angle moveToPoint: NSMakePoint(100, 50)];
[angle lineToPoint: NSMakePoint(125, 100)];
[angle lineToPoint: NSMakePoint(100, 150)];
[angle stroke];

使用这个简单的3点代码,我可以将它们全部连接起来。此代码的产品如下所示...

这是我知道的唯一使用 NSBezierPath 绘制的方法(而不是画圆)。

我想知道如何画出平滑的曲线抛出 3 个不同的点。这样它看起来像这样。 (红色)

我在网上找不到它。谢谢。

这应该可以解决问题,当然您应该调整这些值以获得所需的外观。

NSBezierPath* bezierPath = [NSBezierPath bezierPath];
[bezierPath moveToPoint: NSMakePoint(32.5, 16.5)];
[bezierPath curveToPoint: NSMakePoint(60.5, 47.5) controlPoint1: NSMakePoint(32.5, 16.5) controlPoint2: NSMakePoint(57.5, 15.5)];
[bezierPath curveToPoint: NSMakePoint(35.5, 78.5) controlPoint1: NSMakePoint(63.5, 79.5) controlPoint2: NSMakePoint(35.5, 78.5)];
[[NSColor blackColor]setStroke];
bezierPath.lineWidth = 1;
[bezierPath stroke];