[cairo] mask repeat

Vladimir Vukicevic vladimir at pobox.com
Fri Feb 29 05:10:14 PST 2008

On Feb 29, 2008, at 5:26 AM, Antoine Azar wrote:

> Hey guys,
> I'm testing extend_pad set for a mask, but trying first to hit the
> case where the mask is repeating. I wrote a code sample that copies a
> source surface onto a dest through a mask, but I can't seem to get
> the mask to repeat. How should I do that? Setting the repeat for a
> source is easy with cairo_pattern_set_extend (cairo_get_source (cr),
> CAIRO_EXTEND_REPEAT);, but I can't find a cairo_get_mask() or
> equivalent. Is it possible at all in Cairo?

It is; cairo_set_source_surface is just a shorthand for  
cairo_pattern_crate_for_surface, setting the pattern matrix to  
translate by the offsets, and calling cairo_set_source.  So you'd do  
something like:

   cairo_pattern_t *mask = cairo_pattern_create_for_surface (surface);
   cairo_pattern_set_extend (mask, CAIRO_EXTEND_REPEAT);

   cairo_mask (cr, mask);
   cairo_pattern_destroy (mask);

     - Vlad

More information about the cairo mailing list