Obtaining all points on a line segment
Obtaining all points on a line segment
- Subject: Obtaining all points on a line segment
- From: Cody Garvin <email@hidden>
- Date: Mon, 22 Nov 2010 08:12:58 -0800
Hi all,
I searched back through 2005 in the Cocoa Mailing List and didn't see any requests for this.
We need all the points on a line / arc / path on the screen. We need to do hit detection on stroked line, so we must know if the point is valid or not.
I thought using CGPathContainsPoint would work, but it must be done on a closed path or it returns true on all points in the test area.
I also tried NSBezierPath containsPath: and , but it returned the exact same things as the CGPath functions.
Another idea I have, though not sure if it will work, is converting the drawing to NSBitmapImageRep and using colorAtX:y to test for a specific color to test for a point.
The downside of this approach is you must test all the points in a bounding box, and could get quite large if our line segment is complicated.
I'm surprised I haven't found a convenience method to return all the points in an outline.
Any help would be greatly appreciated.
- Cody_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden