Re: NSBezierPath - quadratic curve with one control point?
Re: NSBezierPath - quadratic curve with one control point?
- Subject: Re: NSBezierPath - quadratic curve with one control point?
- From: Daniel Jalkut <email@hidden>
- Date: Sat, 17 Dec 2005 01:19:21 -0500
Hi Jim - I don't think Apple exports any mechanism to add a quadratic
curve directly to an NSBezierPath.
As I understand it the math is easy to approximate quadratic curves
as cubic, but not so the other way around. So I guess Apple decided
to expose cubic curves in NSBezierPath and not bother with the
convenience function required to convert from a quadratic.
You can search the web for various examples of converting the 3
points of a quadratic into the 4 points of a suitable cubic.
Unfortunately, all the results make it look a lot more complicated
than it is. But if you search this page:
http://support.microsoft.com/kb/q243285/
For the function "MakeBezierFromQBSpline," you'll find that each of
the points is calculated with simple math and a reasonable comment
explaining what's going on.
I think you'll be better off translating that logic into a
convenience function of your own, than trying to find any way of
coercing NSBezierPath to do what you want "off the shelf."
Daniel
On Dec 16, 2005, at 8:25 PM, Jim Correia wrote:
CGContext has two functions for dealing with quadratic curves - one
take two control points and the other only one.
/* Append a quadratic curve from the current point to `(x, y)', with
* control point `(cpx, cpy)'. */
CG_EXTERN void CGContextAddQuadCurveToPoint(CGContextRef c, float
cpx, float cpy, float x, float y);
How do I replicate that with NSBezierPath? (I want to keep the path
around, not just render it and toss it.) The only method I see
wants two control points.
Thanks,
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com
This email sent to email@hidden
_______________________________________________
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