[cairo] cairo_in_fill w/rotate?

Mark Olesen markjolesen at gmail.com
Sun Feb 7 09:03:25 CET 2016


The tricks of cairo. The save/restore worked fine. Thanks for the help.

On Sat, Feb 6, 2016 at 12:10 AM, Uli Schlachter <psychon at znc.in> wrote:

> Am 06.02.2016 um 06:15 schrieb Mark Olesen:
> > Is cairo_in_fill supposed to work with rotation?
> > The following code gets hits on the un-rotated rectangle.
> > It's like the rotation is ignored. Thanks in advance.
> >
> [...]
> >     cairo_new_path(cr);
> >     cairo_rotate(cr, 45.0); // ROTATION SEEMS TO BE IGNORED
> >     cairo_rectangle(cr, 0.0, 0.0, 100.0, 100.0);
> >
> >     // only gets hits on un-rotated rectangle
> >     l_hit = cairo_in_fill(cr, (*event).x, (*event).y);
> >     printf("rect hit=%d %lf %lf\n", l_hit, (*event).x, (*event).y);
> >
> >     cairo_destroy(cr);
> >
> >     return 1;
> > }
> [...]
>
> cairo_in_fill() gets a point in user coordinates. That means that the
> point is
> rotated, too, before the hit test. Either undo the rotation with
> cairo_rectangle(cr, -45.0) (what a weird angle....) or via:
>
> cairo_save(cr);
> cairo_rotate(cr, 45);
> cairo_rectangle(cr, 0, 0, 100, 100);
> cairo_restore(cr);
>
> l_hit = cairo_in_fill(cr, x, y);
>
> Cheers,
> Uli
> --
> - Captain, I think I should tell you I've never
>   actually landed a starship before.
> - That's all right, Lieutenant, neither have I.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20160207/cecdd28c/attachment.html>


More information about the cairo mailing list