#include #include /* M_PI */ static void draw (cairo_t *cr, int width, int height) { cairo_pattern_t *pattern; cairo_scale (cr, width, height); pattern = cairo_pattern_create_radial (0.55, 0.55, 0.25, 0.5, 1.0, 0.525); cairo_pattern_add_color_stop_rgba (pattern, 0.0, 0.0, 0.0, 1.0, 0.811); cairo_pattern_add_color_stop_rgba (pattern, 0.64, 0.345, 0.345, 1.0, 0.317); cairo_pattern_add_color_stop_rgba (pattern, 0.84, 0.713, 0.713, 1.0, 0.137); cairo_pattern_add_color_stop_rgba (pattern, 1.0, 1.0, 1.0, 1.0, 0.0); cairo_pattern_set_filter (pattern, CAIRO_FILTER_BILINEAR); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); cairo_arc (cr, 0.5, 0.5, 142.0/150.0, 0.0, M_PI * 2.0); cairo_fill (cr); } int main (void) { cairo_surface_t *surface; cairo_t *cr; cairo_status_t status; surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 256, 256); cr = cairo_create (surface); cairo_surface_destroy (surface); draw (cr, 256, 256); status = cairo_surface_write_to_png (cairo_get_target (cr), "test.png"); cairo_destroy (cr); return status != CAIRO_STATUS_SUCCESS; }