Re: Select a NSBezierPath
Re: Select a NSBezierPath
- Subject: Re: Select a NSBezierPath
- From: Robert Clair <email@hidden>
- Date: Tue, 21 Sep 2004 08:13:27 -0400
It sounds simpler, but it's much slower.
When you draw a Bezier curve, you have to first compute the curve, then
rasterize it into a buffer, then hit test that. The mathematical
approach involves only the first of these steps, and it can bail early
if a hit is found. The drawing step is the killer, dwarfing the time
the rest takes.
"much slower" ??? Perhaps literally true, but certainly misleading. The
rendering approach is "fast enough" - i.e. it will appear close
to instantaneous for a user. It was fast enough 10 years ago on a
Sparcstation
and it is fast enough on a G4/G5.
I don't have any exact measurements, but, as an example, I just made a
file
with 5500 arcs. I do the selection on mouse down. The selection takes
place
and the selected curve is hilited in about the time it takes the spring
to return
the mouse button to the un-pushed position.
Drawing *is* slow. But you're not going to draw too much. You're going
to keep a bounding
box for each object and test it against the bounding box of your pick
area
so that you don't bother Quartz with things that can't possibly be
picked. And while
I'm not privy to the internal workings of Quartz, I'm sure it makes a
reasonable effort not to
waste its time on things that are outside the view bounds. There's not
much pixel pushing.
Depending on the size of your pick area, we are probably talking about
less than 200 pixels.
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.)
......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