Re: Select a NSBezierPath
Re: Select a NSBezierPath
- Subject: Re: Select a NSBezierPath
- From: "R. Scott Thompson" <email@hidden>
- Date: Tue, 21 Sep 2004 14:59:34 -0500
Also - I'm curious. How do you you handle wide lines ? What if the
user makes a curve
with a one inch line width ? (Or any width much larger than your
picking tolerance.) Do
you require them to click near the center ? What about filled shapes ?
If you have
a filled circle do you have to click near the edge ? (These can be
handled analytically, but
it is a *lot* of trouble.)
Handling wide lines is not that much harder. When you tessellate the
curve you end up approximating the curve near the hit point with line
segments. A simple calculation of the distance from the mouse point to
that line segment (note if just do a point-to-line calculation you can
get it wrong) will tell you if you are within the distance needed to
hit the stroke of the curve.
Filled shapes is pretty much the same idea. When you tessellate the
curve you end up with a polygon and point-in-polygon tests are pretty
easy. Similar techniques can be used for hit testing things like end
caps, mitre joins, etc... FreeHand (and I would presume Illustrator)
used these kinds of techniques for hit testing all the time. With some
professional vector illustrations, even on relatively modern hardware,
documents can become complex enough for the "draw it to see what you
hit" method to be effective.
For the simple case of the OP, however, you might even get away with
the technique used by the latest Carbon Sketch where you simply create
a 1 pixel offscreen scaled and offset to the "right place". You then
draw each object in that offscreen and see if that pixel has changed or
not.
--
Macintosh Software Engineering Consulting Services
Visit my resume at <http://homepage.mac.com/easco/RSTResume.html>
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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