Re: Calculating accurate bounds of stroked paths
Re: Calculating accurate bounds of stroked paths
- Subject: Re: Calculating accurate bounds of stroked paths
- From: Matt Gough <email@hidden>
- Date: Tue, 8 Jul 2008 14:27:25 +0200
Graham,
I know this issue has cropped up before (probably on the Quartz list).
Have your searched its archives?
A simple answer to this sort of question involves painting the path
into a bitmap and hunting for the boundary
Matt
On 8 Jul 2008, at 2:16pm, Graham Cox wrote:
I need to know a rect within which all pixels will be painted for a
given path and stroke width. I'd prefer not to make this rect any
larger than it really needs to be. To compute this, I have to factor
in all sorts of bits and pieces such as the angles of the line
joins, miter limits and so on. It's getting so complicated I feel
there has to be an easier way. Surely there's something in Quartz
that can do this?
A close second best would be a rect that was the worst case bounds
for a given stroke width (it wouldn't need to know the actual path,
just its basic bounds), which thus assumed that all angles were
acute enough to trigger the mitre conversion. Even that is proving
hard to figure, as I'm probably not really understand the miter
limit calculation. The docs state:
"The miter limit helps you avoid spikes at the junction of two line
segments connected by a miter join (NSMiterLineJoinStyle). If the
ratio of the miter length—the diagonal length of the miter join—to
the line thickness exceeds the miter limit, the joint is converted
to a bevel join. The default miter limit value is 10, which converts
miters whose angle at the joint is less than 11 degrees."
So what *is it*? A value in degrees? Or a ratio of two sides of a
triangle? What triangle, exactly? How can I tell just how far out I
need to outset the rect to make sure I'm always just outside the
edge of any mitred corner?
thanks for any insight into this, it's getting frustrating. I'm
pretty OK at trig generally, but the definition is a bit vague, so
I'm not sure what I should be using as my starting points (I
possibly mean that literally!).
cheers, Graham_______________________________________________
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
_______________________________________________
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