// test file to demonstrate bug with color in pdf output. // by Johan Engelen, 2010 #include #include #include int main (void) { cairo_surface_t *surface; cairo_t *cr; const char *filename; cairo_pattern_t *pattern; filename = "pdfcolorbug.pdf"; surface = cairo_pdf_surface_create (filename, 200, 100); cr = cairo_create (surface); // 1st object cairo_set_source_rgba(cr, 1, 1, 0, 1); cairo_move_to(cr, 10, 10); cairo_line_to(cr, 50, 50); cairo_stroke(cr); // 2nd object cairo_move_to(cr, 80, 10); cairo_line_to(cr, 100, 50); cairo_line_to(cr, 100, 10); cairo_close_path(cr); if (true) { pattern = cairo_pattern_create_linear(80,10,100,50); cairo_pattern_add_color_stop_rgba(pattern, 0, 1, 0, 0, 1); cairo_pattern_add_color_stop_rgba(pattern, 1, 0, 0, 1, 1); cairo_set_source(cr, pattern); cairo_pattern_destroy(pattern); } else { cairo_set_source_rgba(cr, 1, 0, 0, 1); } cairo_fill_preserve(cr); cairo_set_source_rgba(cr, 0, 0, 0, 1); cairo_stroke(cr); // 3rd object cairo_set_source_rgba(cr, 0, 0, 0, 1); cairo_move_to(cr, 150, 10); cairo_line_to(cr, 190, 50); cairo_stroke(cr); cairo_destroy (cr); cairo_surface_destroy (surface); return 0; }