[cairo] Gradient Transformation Problems

Carl Worth cworth at cworth.org
Wed Dec 12 12:40:42 PST 2007


On Wed, 12 Dec 2007 10:10:25 -0800, Me Myself wrote:
> So given any arbitrary X and Y scaling, do you know a formula I
> could use on the gradient pattern points to make them maintain the
> proper results when I manually calculate the points?

As already mentioned, that's not possible.

But what are you trying to achieve here that you are having trouble
with? Do note that you can use a transformation for the gradient, but
not also use that transformation for any subsequent paths, etc.

That would look something like this:

	cairo_matrix_t save;

	cairo_get_matrix (cr, &save);

	cairo_scale (cr, sx, sy); /* or whatever transformation you
				   * want for your gradient */

	cairo_set_source (cr, gradient_pattern);

	cairo_set_matrix (cr, &save);

Note that I'm manually using cairo_get_matrix;cairo_set_matrix to save
and restore just the transformation matrix. I can't use
cairo_save;cairo_restore here since that would also save/restore the
source pattern which would leave the call to cairo_set_source having
no effect.

Would an approach like the above help you achieve what you are wanting
to do?

-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/20071212/4812ced9/attachment.pgp 


More information about the cairo mailing list