[cairo] Problem with CAIRO_EXTEND_REPEAT

Sikamikaniboots sikamikaniboots at yahoo.fr
Fri Jul 27 01:07:53 PDT 2007


I think there was a problem with my previous email... sorry...
>> > 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 
>> > (m_cairo),CAIRO_CONTENT_COLOR_ALPHA,5,5);
>> > 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.
You're right. I leave it there since my first version of this code was 
drawing a line instead of using paint.
> 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?
I've tried to turn it on and it doesn't change anything (maybe the 
borders of the black squares are a little less sharp but I'm not even sure).


More information about the cairo mailing list