[cairo] [cairo-commit] 3 commits - src/cairo.c src/cairo-path-stroke.c test/get-path-extents.c test/.gitignore test/Makefile.am test/rectilinear-miter-limit.c test/rectilinear-miter-limit-ref.png
Behdad Esfahbod
behdad at behdad.org
Mon Jan 21 17:37:06 PST 2008
On Mon, 2008-01-21 at 19:47 -0500, Carl Worth wrote:
>
> + /* If the miter limit turns right angles into bevels, then we
> + * can't usethis optimization. Remember, the ratio is
> + * 1/sin(ɸ/2). So the cutoff is 1/sin(π/4.0) or ⎷2 or
> + * approximately 1.414213562373095, which we round for safety. */
> + if (stroke_style->miter_limit < 1.415)
> + return CAIRO_INT_STATUS_UNSUPPORTED;
I thought about this on the way back home and though, well, what if the
user exactly sets miter to sqrt(2)? What I mean is, sqrt(2) is one of
the "magic" numbers to use for miter limit as it does a miter up to
right angles, and bevel after. Then I checked math.h and there indeed
is M_SQRT2 defined. So I suggest:
- Somewhere in a portability header:
#ifndef M_SQRT2
#define M_SQRT2 1.414213562373095
#endif
- Change the check to:
if (stroke_style->miter_limit < M_SQRT2)
return CAIRO_INT_STATUS_UNSUPPORTED;
This way if the user sets miter limit exactly to M_SQRT2, we're on the
safe side.
I can push.
--
behdad
http://behdad.org/
"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
More information about the cairo
mailing list