[cairo] Repeatedly drawing the same object

David Björkevik david at bjorkevik.se
Wed Jun 24 12:02:29 PDT 2009


Adam Richard wrote:
> Hi,
> 
> I'm wondering what's the best way to draw a fixed shape many times at 
> several different locations on the surface.  I don't want a repeated 
> pattern filling up an area, as the CAIRO_EXTEND_REPEAT option allows; 
> rather, I want to create a "stamp" which I can then use to draw the same 
> image many times at various different positions, so that each "stamp" is 
> as fast as possible.

(...)

> I notice in the tutorial, where it discusses selecting a source:
> 
> http://cairographics.org/tutorial/#L2preparesource
> 
> there's a mention of using a surface as a source using 
> cairo_push_group() and cairo_pop_group(), and it says you can save a 
> source and then select it repeatedly with cairo_set_source.  So maybe 
> that's the fastest way to do it?  I've tried setting the source once and 
> then moving its position with translate() on each iteration, but that 
> didn't seem to work.

You're on the right track, but try manipulating the pattern matrix
instead, using cairo_pattern_set_matrix.

/David


More information about the cairo mailing list