Select a NSBezierPath
Select a NSBezierPath
- Subject: Select a NSBezierPath
- From: Robert Clair <email@hidden>
- Date: Mon, 20 Sep 2004 11:13:04 -0400
> And this is wrong.
<x-tad-bigger>
</x-tad-bigger>
No... [aBezierPath containsPoint: aPoint] will only tell you if the
point is in the interior of the curve, with the "interior"" of an open curve
being defined as the interior of the closed curve that would result
from joining the last point of the open curve to the curve's first
point with a straight line.
Given that, the behavior you describe is exactly what you would expect.
That you get 1 instead of 2 sometimes is a function of the way your if statement
is structured - if the point is in the interior of both your code will report 1.
To do what you want is more involved - most approaches are variants on
the idea of conceptually making a small area around the mouse point, traversing
your display list and determining, one by one, if each object on the list is going to draw into
that small area.
This can be done:
1) analytically - tessellate the curve, and then do some geometry to see if
any of the resulting line segments intersect your pick rectangle. (You use
- bezierPathByFlatteningPath to get the tessellation and then extract the data with
- elementAtIndex:associatedPoints).
2) by pixels - actually make a small image, set the coordinates so the mouse point is in the
center, draw each object into it in turn and after each object
draws look and see if any of the pixels have changed. Since the actual number of pixels involved
is small this is actually reasonably fast and has the advantage of taking care of things
like linewidth.
Hope this helps,
Bob Clair
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden