[cairo] Extents not affected by CTM

Chris Wilson chris at chris-wilson.co.uk
Tue Jan 27 09:40:49 PST 2009


On Tue, 2009-01-27 at 10:22 -0700, rvinyard at cs.nmsu.edu wrote:
> Just checking to see it is expected behavior of cairo_fill_extents(),
> cairo_path_extents() and cairo_stroke_extents() that they are (mostly)
> uneffected by the CTM.

[snip]

> Any suggestions on how I can get the extents after the CTM is applied? I
> thought about applying the CTM to the extents, but that wouldn't always
> yield proper extents for cases where rotation is involved with
> non-rectangular paths.

The trick here is that the CTM is being used twice. Once to transform
the path into device space and then the second time to transform the
extents back into user space.

So in order to query the device-space extents (i.e. with the CTM
applied), construct the path using your transformation matrix and then
set the identity matrix for querying the extents. Like:

cairo_set_matrix (cr, &ctm);
... build path ...
cairo_save (cr);
cairo_identity_matrix (cr);
cairo_fill_extents (cr, ...);
cairo_restore (cr);

Hope this helps, and you continue to have fun using cairo.
-ickle



More information about the cairo mailing list