cairo_surface_t *pdf; cairo_t *cr; cairo_pattern_t *pat; double x0 = 100, /* parameters like cairo_rectangle */ y0 = 100, rect_width = 50, rect_height = 50, radius = 20; double x1,y1; double w = 100, h=100; double dx0=20, dx1=20, dx2=dx0+w, dy0=20+h, dy1=20, dy2=20; x1=x0+rect_width; y1=y0+rect_height; pdf = cairo_pdf_surface_create("test.pdf", 500, 800); cr = cairo_create(pdf); cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); cairo_set_line_width (cr, 10); pat = cairo_pattern_create_linear (dx2, dy2,dx0, dy0); //0.5 bei beiden für eine Trennung der Farben //1.0, 0 für einen gleitenden Übergang cairo_pattern_add_color_stop_rgba (pat, 0, 1, 1, 1, 1); cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1); cairo_set_source (cr, pat); cairo_move_to (cr, dx0, dy0); cairo_curve_to (cr, dx0, dy0, dx1, dy1, dx2, dy2); cairo_stroke(cr); cairo_move_to(cr, dx0, dy0-1); cairo_line_to(cr, dx0, dy0+200); cairo_stroke(cr); cairo_set_line_width (cr, 1); cairo_set_source_rgba(cr, 1,0,0,1); cairo_move_to(cr, dx0, dy0); cairo_arc(cr, dx0, dy0,3,0,2*M_PI); cairo_stroke(cr); cairo_move_to(cr, dx1, dy1); cairo_arc(cr, dx1, dy1,3,0,2*M_PI); cairo_stroke(cr); cairo_move_to(cr, dx2, dy2); cairo_arc(cr, dx2, dy2,3,0,2*M_PI); cairo_stroke(cr); cairo_show_page(cr); cairo_surface_destroy(pdf); cairo_destroy(cr);