[cairo] draw rectangle with lines, filling problem

Bill Spitzak spitzak at gmail.com
Thu Sep 22 11:13:52 PDT 2011


Only the line-to calls produce an edge to the filled shape. The moveto 
calls start new filled shapes (or produce nothing if they are just a 
point or 1 line).

You probably want to draw the rectangle with 4 sides to fill it, then 
add your line segments afterwards.

ferraresi.carlo at tiscali.it wrote:
> Hi to all! In my application I need to draw rectangles with not each 
> border (maybe only top and bottom or something else) so I try to draw 
> the single lines of the rectangle, but I have a problem if I want to 
> fill the inside of the rectangles. Cairo fills only an half rectangle, 
> it draws a triangle and not the full space. What's the problem??
> This 
> is my code:
> 
>     cairo_move_to(cr,x1,y1);
>     cairo_set_line_width(cr,
> 2);
>     if(!(lineSuppression & 0x0004))
>             cairo_line_to(cr,x2,
> y1);
>     else
>         cairo_move_to(cr,x1,y2);
> 
>     if(!
> (lineSuppression & 0x0002))
>         cairo_line_to(cr,x2,y2);
>     else
> 
>         cairo_move_to(cr,x2,y2);
> 
>     if(!(lineSuppression & 0x0001))
> 
>         cairo_line_to(cr,x1,y2);
>     else
>         cairo_move_to(cr,x1,
> y2);
> 
>     if(!(lineSuppression & 0x0008))
>         cairo_line_to(cr, x1,
> y1);
>     else
>         cairo_move_to(cr,x1,y1);
> 
>     cairo_fill_preserve
> (cr);
>     cairo_set_source_rgb(cr,0.0,0.8,0.0);
>     cairo_stroke(cr);
> 
> 
> 
> 
> 
> E' nata indoona: chiama, videochiama e messaggia Gratis da smartphone e da PC: scaricalo da http://www.indoona.com/
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list