[cairo] Position a pattern at the tip of a rectangle

Carl Worth cworth at cworth.org
Tue Aug 18 11:12:43 PDT 2009


Excerpts from thomas's message of Mon Aug 10 04:44:39 -0700 2009:
> I have a pattern which starts at (0,0) and ends at (1,1). I scale it by a
> factor of 200x, to get a pattern from (0,0) to (200,200). Now, I want to
> create a rectangle which exists from, say (300,300) to (500,500), and draw
> the pattern as if it started at the top left of the rectangle. How can
> this be done?

How exactly are you scaling the pattern? Are you doing that with
cairo_pattern_set_matrix after calling cairo_matrix_scale? If so, then
you should just be able to add a call to:

	cairo_matrix_translate (matrix, 300, 300);

before your call to cairo_matrix_scale. (You could call this after
cairo_matrix_scale as well, but then you would want to use coordinates
divided by the scale factor. That may even be easier depending on the
details of what you're doing.)

I hope that helps, and if not, please give use some more details as to
what you are doing so that we can hopefully help.

Have fun with cairo,

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20090818/7786b95e/attachment.pgp 


More information about the cairo mailing list