cairo_pattern_t *pat; snippet_normalize (cr, width, height); pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 1.0); cairo_pattern_add_color_stop (pat, 1, 1, 0, 0, 1); cairo_pattern_add_color_stop (pat, 0, 0, 0, 1, 1); cairo_set_pattern (cr, pat); // test rectangle - make sure the gradient is set correctly cairo_rectangle (cr, 0, 0, 0.1, 1); cairo_fill (cr); cairo_select_font (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_scale_font (cr, 0.4); cairo_move_to (cr, 0.1, 0.6); cairo_show_text (cr, "cairo");