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

Using this simple code of 3 points, I can connect them all. The product of this code looks like this...

enter image description here

This is the only way of drawing I know with NSBezierPath (Instead of drawing a circle).

I was wondering how to draw a smooth curve throw 3 different points. Such that it would look like this. (RED)

enter image description here

I couldn't find it on the web. Thank you.

31i45
  • 315
  • 1
  • 2
  • 12

1 Answers1

1

This should do the trick, of course you should play with the values to get the desired look.

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];
31i45
  • 315
  • 1
  • 2
  • 12
Marius Fanu
  • 6,589
  • 1
  • 17
  • 19
  • The question is about `NSBezierPath `. – thxou Feb 19 '16 at 10:03
  • I simply changed every code from yours to NS. Although not a perfect smooth curve (Due to the CGPoint), it should work. Thank. If you can, (Would be very helpful) tell me what controlPoint1 and controlPoint2 is? – 31i45 Feb 19 '16 at 10:09
  • The control point is the point that determines the shape of the curve near the current point. – Marius Fanu Feb 19 '16 at 12:23