[cairo] Repeatedly drawing the same object

Adam Richard adam.richard at caris.com
Thu Jun 25 04:23:44 PDT 2009


Thanks - setting the pattern's matrix to a Cairo::translation_matrix(-x, 
-y) on each iteration did work the same as resetting the source each time.

David Björkevik wrote:
> 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