[cairo] plots of contiguous rectangles

Carl Worth cworth at cworth.org
Wed Aug 8 09:57:14 PDT 2007

On Wed, 8 Aug 2007 18:50:16 +0200, Tamas K Papp wrote:
> How could I get rid of both?

Snapping to device-space integers is what I would recommend.

Something like:

	snap_point (cairo_t *cr, double *x, double *y)
	    cairo_user_to_device (cr, x, y);
	    *x = round (*x);
	    *y = round (*y);
	    cairo_device_to_user (cr, x, y);

	snap_point (cr, &x1, &y1);
	snap_point (cr, &x2, &y2);

	cairo_rectangle (cr, x1, y2, x2 - x1, y2 - y2);

>                              Snapping to integer grids is something I
> want to avoid: I am drawing on vector and bitmap surfaces, and I would
> have to keep tack of which is which.  But if there is not other
> solution, I can try to manage that, I just need to know.

Even if you didn't distinguish between vector and bitmap surfaces,
(which I can understand your reluctance to do), the device-space grid
for a vector surface such as PostScript or PDF will be 1 device-space
unit == 1 point (1/72 inch). Would a maximum error of half of 1/144
inch be a noticeable problem?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20070808/665396ba/attachment.pgp 

More information about the cairo mailing list