[cairo] Problem with CAIRO_EXTEND_REPEAT

Travis Griggs tgriggs at cincom.com
Tue Jul 24 12:12:53 PDT 2007

On Jul 23, 2007, at 4:57, Sikamikaniboots wrote:

> Hi
> I'm trying to use gtk printing in my app. It uses cairo to draw.
> I'd like to fill paths with different hatches. I'm using the code  
> below to create a little part of the hatch and to repeat it to fill  
> the path.
> The problem is that when I do it, there's a little space (a thin  
> and transparent line) between each repeat. For example, if I want  
> to repeat a completely black square (see the code below), it gives  
> me this result : http://img96.imageshack.us/img96/8747/ 
> cairopblmcw6.png
> I expected it to draw a completely black area. If I draw a line or  
> anything else instead of a black square, I get the same type of  
> result.
> This result is displayed in the preview window of gtk printing (in  
> fact in evince).
> Is there any way to suppress this line ?
> Thanks.
> The code :
> cairo_t * cr;
> cairo_surface_t *surface;
> surface = cairo_surface_create_similar(cairo_get_target 
> cr = cairo_create(surface);
> cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE);
> cairo_set_line_width(cr, 1);
> cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
> cairo_set_source_rgba(cr, redPS, greenPS, bluePS, alphaPS); //these  
> values give black color
> cairo_paint(cr);
> cairo_stroke (cr);
> cairo_destroy(cr);
> cairo_pattern_t * pattern = cairo_pattern_create_for_surface  
> (surface);
> cairo_surface_destroy(surface);
> cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
> cairo_set_source(m_cairo, pattern);
> //here i create a path in another cairo context (m_cairo)
> //and i fill it with the pattern:
> cairo_fill( m_cairo );

I just replicated this code (I used a simple rectangle for the path),  
using the VW/ST binding for Cairo running on Quartz. It looks fine.  
So that'd point at possible X issues, rather than Cairo issues?

Couple thoughts. You don't need the cairo_stroke, or even the  
linewidth/cap, since you're using paint which fills the whole clip area.

What happens if you turn ANTIALIAS back on? I would guess most/many  
of the Cairo cases leave AA on, so you may be in an area that doesn't  
get used much?

Travis Griggs
"I choose. Therefore, I Am"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20070724/0dcb9269/attachment.html 

More information about the cairo mailing list