[cairo] Two usage questions( matrix and fill with dash stroke)
Carl Worth
cworth at cworth.org
Tue Apr 8 15:11:18 PDT 2008
On Tue, 8 Apr 2008 08:49:24 -0600, "Cong Chen" wrote:
> 1. If I have cairo_matrix_t, any ways that I can get the rotation
> angle, scale size and the translation offset from it?
There's no cairo function to do anything like that directly, (and in
general it's really not a well-defined question).
But if you happen to know something about the matrix you've
constructed. For example if you know that your matrix M is the
multiplication of a translation matrix T, a rotation matrix R, and a
scale matrix S like so:
M = SRT
For example, you could get that by doing:
cairo_translate (cr, tx, ty);
cairo_rotate (cr, rotation);
cairo_scale (cr, sx, sy);
If you know that you've done something like that then you can call
cairo_get_matrix to inspect the matrix directly and then derive the
algebra to pull out the original tx, ty, rotation, sx, and sy values.
But given an arbitrary matrix, I don't think it can necessarily be
decomposed into a set of those three matrices.
> 2. When I use cairo_fill_preserve(), then use cairo_stroke() to stroke
> the shape with a dash stroke, the fill and stroke overlap and looks
> ugly. Any way to make the fill just fill inside the stroke, not overlap
> with it?
You can do some games with cairo_push_group and
CAIRO_OPERATOR_DEST_OUT to subtract a stroke from the fill. It won't
be ridiculously efficient, but it should give you the result you
want. I'll cook up a demonstration later if you'd like.
-Carl
-------------- 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/20080408/6f31bc1f/attachment.pgp
More information about the cairo
mailing list