[cairo] Polygon fill styles?

Kalle Vahlman kalle.vahlman at gmail.com
Thu Aug 21 08:56:02 PDT 2008

2008/8/20 Ian Britten <britten at caris.com>:
> Kalle Vahlman wrote:
>> The idea is that you first create a small surface (preferrably with
>> create_similar() from the surface you want to draw to) and draw
>> whatever it is you want to repeat to it. Then you use
>> cairo_pattern_create_for_surface() to create a pattern of the surface.
>> To get it repeated, you simply set the extend mode for the pattern
>> with cairo_pattern_set_extend() to CAIRO_EXTEND_REPEAT.
>> Then you draw your polygon, but instead of setting the source to a
>> color like normal solid fills, you set the previously created pattern
>> as the source with cairo_set_source().
> Instead?
> Is the colour (and alpha) in the pattern, or still in my context?
> I'm used to the idea of the pattern (mask) being like 1-bit data,
> with the actual colour only coming into play later, when it's
> applied to a bitmap.  As such, I would normally just make the
> pattern (mask) once, cache it, and reuse it whenever needed again.
> However, each time it is reused, it might be with a different
> colour.
> Can I still take this approach with Cairo?

Ah right, then cairo_mask() should be what you need. But now I
wandered already to an area of cairo I haven't really used so I'll let
you experiment how it behaves ;)

Unless someone else wants to jump in to help :)

Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi

More information about the cairo mailing list