Create a CGPath equivalent to an NSBezierPath ?

72 views
Skip to first unread message

Erik Stainsby

unread,
Mar 15, 2012, 10:45:50 PM3/15/12
to Quartz-Dev
Is there a technique for creating a CGPathRef equivalent to an NSBezierPath ?
Specifically I'm hoping to use an NSBezierPath for a rounded rect as a template for a CG equivalent.

TIA

Erik Stainsby
erik.s...@roaringsky.ca
-------------------------------------
Consistently place constants on the LHS of an expression: you cannot accidentally assign when you meant to compare.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (Quart...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/quartz-dev/quartz-dev-garchive-50095%40googlegroups.com

This email sent to quartz-dev-g...@googlegroups.com

David Duncan

unread,
Mar 16, 2012, 2:11:37 AM3/16/12
to Erik Stainsby, Quartz-Dev
On Mar 15, 2012, at 7:45 PM, Erik Stainsby wrote:

> Is there a technique for creating a CGPathRef equivalent to an NSBezierPath ?
> Specifically I'm hoping to use an NSBezierPath for a rounded rect as a template for a CG equivalent.

You can always iterate over the elements of the bezier path and construct the equivalent CGPath (there are only 4 types of elements, so the code is actually pretty simple/short).

But if all you want to do is create a rounded rect, its probably easier to just start from first principles in CG. Its an iOS Sample, but the QuartzDemo sample shows you how to build a rounded rect with CG as well as other aspects of Core Graphics.
--
Reality is what, when you stop believing in it, doesn't go away.
Failure is not an option. It is a privilege reserved for those who try.

David Duncan

Erik Stainsby

unread,
Mar 16, 2012, 2:34:02 PM3/16/12
to David Duncan, Quartz-Dev
The category Gus pointed mo to provides a function wrapping that translation of the constituent pieces which you suggest David. Thanks to you both.

Erik Stainsby

Time Dwarf,
Roaring Guy

Reply all
Reply to author
Forward
0 new messages