[cairo] Question about cairo_fill_preserve

Behdad Esfahbod behdad at behdad.org
Fri Jan 4 12:34:56 PST 2008


On Fri, 2008-01-04 at 15:26 -0500, Meryl Silverburgh wrote:
> 
>         cairo_move_to(cr, 1002, 0);
>         cairo_line_to(cr, 1002, 131);
> 
> 
>         cairo_move_to(cr, 1002, 131);
>         cairo_line_to(cr, 0, 131);
> 
>         
> 
>         cairo_move_to(cr, 0, 131);
>         cairo_line_to(cr, 0, 0);
> 
> 
> 
>         cairo_move_to(cr, 0, 0);
>         cairo_line_to(cr, 0, 125);
> 
> 
> 
>         cairo_move_to(cr, 0, 125);
>         cairo_line_to(cr, 1002, 125);
> 
> 
>         cairo_move_to(cr, 1002, 125);
>         cairo_line_to(cr, 1002, 0);

You are creating 5 line segments, no closed shape.  Try:

  cairo_move_to(cr, 0, 0);
  cairo_line_to(cr, 1000, 0);
  cairo_line_to(cr, 1000, 130);
  cairo_line_to(cr, 0, 130);
  cairo_close_path(cr);

of it's equivalent:

  cairo_rectangle(cr, 0, 0, 1000, 130);

Note that the 1000 and 130 in the cairo_rectangle() call are width and
height, not a corner.

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list