Re: Re: Re: Tracking rectangles and bezier paths
Re: Re: Re: Tracking rectangles and bezier paths
- Subject: Re: Re: Re: Tracking rectangles and bezier paths
- From: "Michael Ash" <email@hidden>
- Date: Fri, 8 Sep 2006 20:06:50 -0400
On 9/8/06, Wagner Truppel <email@hidden> wrote:
It's not as hard a math problem as suggested, even if the curve is
not monotonic. Recall that the entire bezier path is contained within
the convex hull of the path's control points so a very simple
solution is to retrieve the control points, compute their convex hull
(which is a convex polygon, in 2 dimensions), and use that as your
tracking area. Computing convex hulls in 2 dimensions is almost
trivial - any decent book on algorithms will tell you how.
And if your goal is to track a margin around the path itself then it
can be done even easier. Simply create a 1x1 NSImage, lock focus on
it, apply an appropriate affine transform, then draw your path and see
if the single pixel in the image was altered. For a margin, simply
increase the path's width when drawing for the hit test.
Mike
_______________________________________________
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