[cairo] How cairo_pattern_set_matrix() works?

Silenio Quarti Silenio_Quarti at ca.ibm.com
Fri Mar 18 10:39:29 PST 2005


Owen Taylor <otaylor at redhat.com> wrote on 03/18/2005 01:15:14 PM:

> Silenio Quarti wrote:
> > What cairo_pattern_set_matrix() should do? Should it affect every
> > individual cell or the whole pattern coordinate system? It seems also
> > that the matrix have the inverse effect. If the matrix scaling portion
> > is 0.5, it actually enlarges the image, instead of reducing it.
> > 
> > For example, in the code below I was expecting 4 surfaces/pixmaps
> > of reduced size (30x30) to be drawn completely (one in which corner of 
the
> > rectangle (50,50, 60,60)), but instead the output is partial enlarged
> > images.
> > 
> > Is this the expected behavior?
> 
> The matrix for a pattern defines a mapping from user space to pattern
> space. So, if we set a scale on the pattern matrix of 0.5, that means
> that for every unit we move in user space, we move 0.5 units in pattern
> space ... that is, enlargement.

Ok, that makes sense. So if I change the matrix as follow:

cairo_matrix_translate(matrix, -50, -50);
cairo_matrix_scale(matrix, 2, 2);

shouldn't I get 4 reduced images one in which corner
of the rectangle (50,50,60,60)? With snapshot 0.4.0,
the output is only one image in the top/left corner of the
rectangle. The problem is that only one quarter of the
rectangle is filled. It seems that the pattern cell 
was not affected.

Thanks!
Silenio





More information about the cairo mailing list