[Cairo] mouse pointer and cairo

Carl Worth cworth at east.isi.edu
Sat Oct 11 11:31:25 PDT 2003


On Oct 11, Thomas Hunger wrote:
 > I wonder what would be the best way to calculate the intersection between my 
 > mouse pointer and a cairo-shape (line, rect).

We'll want to add some functions to Cairo to support this. PostScript
provides operators for this and we could start with correspondingly
named functions:

	int
	cairo_in_stroke (cairo_t *cr, double x, double y);

	int
	cairo_in_fill (cairo_t *cr, double x, double y);

We'll have to decide our own semantics for these operations.
PostScript returns true if the pixel containing the given point would
be painted by stroke or fill. But that may or may not be the
definition we want when doing anti-aliased graphics. The other obvious
choice would be to compute geometrically correct containment without
reference to the device pixel grid.

I'd be glad for some guidance from those with relevant user-interface
design experience.

The PostScript versions of these operators also allow the user to test
for intersection with an arbitrary region instead of a point, (the
region is specified as a userpath). This might be another reason to
expose a cairo_path_t object.

Comments?

-Carl




More information about the cairo mailing list