Re: cairo_in_fill w/rotate?

Uli Schlachter <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
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.
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.