Re: Calculating accurate bounds of stroked paths [SOLVED]
Re: Calculating accurate bounds of stroked paths [SOLVED]
- Subject: Re: Calculating accurate bounds of stroked paths [SOLVED]
- From: Graham Cox <email@hidden>
- Date: Wed, 9 Jul 2008 16:37:16 +1000
On 9 Jul 2008, at 4:02 pm, Chris Suter wrote:
so you can get a worst case bounds by ignoring the mitre limit.
No you can't. If the stroke width is 'w' then you can outset the
bounds by w/2 to enclose the path for straight edges and angles >= 90
degrees. When there is a more acute angle though the resulting spike
quickly extends beyond this bounds up to the miter limit, at which
point it becomes a bevel join and falls within the bounds again. Thus
to calculate the bounds that will include all such spikes, you do need
to factor in the miter limit.
Thanks to this page I now understand what the miter limit is:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Attributes-Stroke.html
It's the distance 'm' along the widest part of the corner. This is the
hypotenuse of a right-triangle whose other sides are the edge of the
path and the normal to the path, which has the known width 'w'. Thus
the angle 'a' of the corner is equal to 2*sin(w/m), or m = 2w/sin(a).
But it's not necessary to worry about the angle itself for a worst
case calculation, since only the value of m matters - it can never
exceed the programmed miter limit. Thus the path bounds is simply
outset by (miter limit * w/2) to ensure it is just beyond the tip of
any possible spike.
Once I realised exactly what the miter limit actually defines it turns
out the calculation is trivial - understandably so since when stroking
a path the renderer will want to do this quickly and probably not get
too bogged down in lots of trig.
Thanks to everyone who responded, all helped to focus my thoughts.
For the better calculation (rather than worst case), Kai's suggestion
of using the outlined path bounds is a great solution ;-)
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