[cairo] mask repeat

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Fri Feb 29 03:39:55 PST 2008

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?

How about this Python example?

   import cairo

   # prepare mask as pattern
   tmp = cairo.ImageSurface(cairo.FORMAT_A8, 16, 16)
   cr2 = cairo.Context(tmp)
   cr2.set_source_rgba(0, 0, 0, 0.5)
   cr2.rectangle(2, 2, 9, 9)
   cr2.rectangle(5, 5, 9, 9)

   pat = cairo.SurfacePattern(tmp)

   # paint using prepared mask
   dst = cairo.ImageSurface(cairo.FORMAT_RGB24, 32, 32)
   cr = cairo.Context(dst)
   cr.set_source_rgb(1, 1, 1)




More information about the cairo mailing list