[cairo] Question about cairo_fill_preserve
Meryl Silverburgh
silverburgh.meryl at gmail.com
Fri Jan 4 12:26:01 PST 2008
hi,
I have a question about cairo_fill_preserve.
If I use cairo_line_to(), and cairo_move_to() to draw something like this:
| |
---------
| |
---------
I see it when i use 'cairo_stroke_preserve()'
But what if I want to fill the bottom rectangle , i try using
cairo_fill_preserve(), but nothing appear.
Here is my example (based on the hello.c in cairo)
#include <cairo.h>
int
main (int argc, char *argv[])
{
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1240, 180);
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 0.8, 0.0, 0.0);
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);
/* works */
/* cairo_stroke_preserve(cr); */
/* nothing shows up */
cairo_close_path (cr);
cairo_fill_preserve(cr);
cairo_destroy (cr);
cairo_surface_write_to_png (surface, "hello.png");
cairo_surface_destroy (surface);
return 0;
}
More information about the cairo
mailing list