[cairo] Pattern rendering questions

Ryan Schmidt cairo-2008c at ryandesign.com
Thu Aug 21 11:01:58 PDT 2008

On Aug 21, 2008, at 08:36, Ian Britten wrote:

> Each of these was generated using the approach described by Kalle
> Vahlman yesterday.  I didn't include my code, as the basic mechanics
> seem to be working.  I think my questions are more general rendering
> questions, and not necessarily specific to my attempt at fill styles.
> In the first one (diagonal.png):
> I generate a small surface (w, h), stroke a line to it (0,0), (w,h),
> make the pattern, CAIRO_EXTEND_REPEAT, etc, etc.
> - Note the missing pixels, presumably from where the tiles are
>   assembled after the pattern is clipped to the extent of the
>   surface.
>   -> Can anyone suggest any technique which might fill in these
>      missing pixels?

Try drawing the line (0-t,0-t), (w+t,h+t), where t is the thickness  
of the line.

> In the second one (cross.png)
> As with the previous pattern, I generate this one by drawing an X
> from (0,0), (w,h), etc, but at 50% alpha.
> - Note the darker pixels, presumably from where the pattern
>   overlaps, and the alphas of the individual strokes is combined.
>   (Or, maybe it's from where the tiles overlap.  I'm not sure...)
>   -> Can anyone suggest a technique that would result in a
>      consistent alpha for the entire pattern?

The same would probably happen in any graphics library or image  
editor if you draw partially transparent lines on top of one another.  
You probably need to draw the lines at full opacity first, then make  
them partially transparent all at once. Having not written any code  
with cairo, however, I can't suggest how to do that...

More information about the cairo mailing list