#include #include #define M_PI 3.14159265358979323846 static double width, height; static char path_output[512]; static cairo_t *cr; static cairo_surface_t *surface; struct rgb { double r, g, b; } values[] = { {0, .7, .9}, {.5, .9, .5}, {1., 1., .4}, {1., .8, .5}, {1., .6, .65}, {1., .4, .9}, }; #define NVALUES 6 int start = 0; void lain_rainbow(cairo_t * cr) { unsigned ii, jj; double dy, dx, x0, y0, x1, y1, red, green, blue; /* Outer black border */ red = green = blue = 1.; cairo_set_line_width(cr, 0); cairo_set_source_rgba(cr, red, green, blue, 1.); cairo_rectangle(cr, 0, 0, width, height); cairo_fill(cr); /* Colors */ x1 = width; dx = width / 36; y1 = dy = height / 36; x0 = 0; y0 = 0; for (ii = start, jj = 0; jj < 36; jj++, ii++) { cairo_rectangle(cr, x0, y0, x1, y1); cairo_set_source_rgba(cr, values[ii % NVALUES].r, values[ii % NVALUES].g, values[ii % NVALUES].b, 1.); cairo_fill(cr); y0 += dy; x1 += dx; y1 += dy; } } int main(int argc, char **argv) { int n; width = 3840; height = 2160; sprintf (path_output, "stage1-00.png"); if (argc == 2) { n = 0; sscanf(argv[1], "%d", &n); start = n; sprintf (path_output, "stage1-%02d.png", n); } surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); cr = cairo_create(surface); lain_rainbow(cr); cairo_surface_write_to_png (surface, path_output); cairo_surface_destroy(surface); cairo_destroy(cr); return 0; }