Skip navigation.
 
mlCalculating accurate bounds of stroked paths
FROM : Graham Cox
DATE : Tue Jul 08 14:16:06 2008

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_removed>)

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:
http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>

This email sent to <email_removed>