0

Is it possible to draw a free hand path using Objective C on Mac OS application views?

I'm trying to draw with NSBBezierPath and able to draw basic shapes like line,circle,etc..,

But, is it possible to draw a free hand path using NSBezierPath?

Please suggest.

Thanks.

rs priya
  • 31
  • 3

2 Answers2

2

If you create a subclass of NSView to use as your drawing board, you can implement the mouseDragged: method (or any of the other mouse methods) and use it to capture mouse movements.

- (void)mouseDragged:(NSEvent *)theEvent
{
    NSPoint mouseLoc = [self.superview convertPoint:[theEvent locationInWindow] fromView:nil];

    // Do something with mouseLoc
}
Michael Knudsen
  • 629
  • 1
  • 7
  • 23
1

If you detect the location of the free hand input you want and get the associated screen points then you can create a bezier path and use moveToPoint: (with the first point) and lineToPoint: (with the latter points) to add the points and specify the path.

Wain
  • 118,658
  • 15
  • 128
  • 151