#include void draw_path(cairo_t* cr) { cairo_move_to(cr, 270, 450); cairo_line_to(cr, 250, 450); cairo_line_to(cr, 270, 50); } int main (int argc, char *argv[]) { cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 500, 500); cairo_t *cr = cairo_create (surface); cairo_set_line_width(cr, 20); cairo_set_miter_limit(cr, 4); // the path unclipped, undashed draw_path(cr); cairo_set_source_rgb(cr, 0, 0, 1); cairo_stroke(cr); // clip rectangle cairo_move_to(cr, 110, 200); cairo_line_to(cr, 390, 200); cairo_line_to(cr, 390, 300); cairo_line_to(cr, 110, 300); cairo_close_path(cr); cairo_set_source_rgb(cr, .5, .5, .5); cairo_fill_preserve(cr); cairo_clip(cr); // the original path, clipped but undashed draw_path(cr); cairo_set_source_rgb(cr, 1, 0, 0); cairo_stroke(cr); // the original path, clipped and dashed (with a long dash) - this one fails, // it should overwrite the red with green double dashes[] = {20000.}; cairo_set_dash(cr, dashes, 1, 0); draw_path(cr); cairo_set_source_rgb(cr, 0, 1, 0); cairo_stroke(cr); cairo_destroy (cr); cairo_surface_write_to_png(surface, "hello.png"); cairo_surface_destroy (surface); return 0; }