Re: NSBezierPath (Modifying Paths)
Re: NSBezierPath (Modifying Paths)
- Subject: Re: NSBezierPath (Modifying Paths)
- From: Quincey Morris <email@hidden>
- Date: Wed, 4 Feb 2009 11:33:22 -0800
On Feb 4, 2009, at 10:54, Joseph Crawford wrote:
This is all just messing around trying to replicate the capabilities
of the curve tool in many drawing applications, I already saw how to
replicate the drawing of a line and that would be a different tool
to choose from.
What would you suggest I look into for wanting to modify the points?
I had this working perfectly with a tempPath for the dragging and
actually had it grey in color and when it was drawn it was done so
in black (the visual queue) but was told that I could do it with
only one path which is why I was looking into modifying the path
elements. When I have one point the dragging operation always added
more and more points which led to the line being drawn with every
drag and that was not the wanted solution.
You *could* take an approach where your underlying data model
consisted of just NSBezierPath objects. Then, drawing in your user
interface would be easy -- just stroke the underlying paths. However,
the *usability* isn't great, and would likely get worse as you added
more functionality. (For example, by following this approach, you
already lost the ability to draw new stuff in gray.)
You'll find things easier, though, if you design your own objects for
your underlying data model. How you would break it down depends on
what you're trying to achieve. Perhaps each path/contour/outline is an
object, which contains an array of segment objects, and each segment
has 2 or 4 points. Maybe you have curved and straight line segment
objects in a path object, or maybe you have only curved segments in a
curved path and only straight line segments in a polyline path. Maybe
you have to keep track of whether your paths are open or closed. At
some point you'll need to work out where to keep track of the stroke
width and color, probably. It all depends what you want.
Most likely you'd want to use NSBezierPaths for actual drawing. It
wouldn't be wrong to create *those* on the fly in your drawRect, used
for drawing and discarded, but if that was anything but trivial you
might want to consider pre-creating these drawing paths and having
them ready before you get to the actual drawing. Again, it depends.
The messing around part is fine, but I think you'll find that it very
quickly becomes a data model design exercise PLUS a user interface
design exercise, neither of them trivial. (Cue Graham Cox...)
_______________________________________________
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