static void render_simple ( cairo_t *cr, int width, int height, MetaGradientType type, gboolean with_alpha) { GdkPixbuf *pixbuf; GdkRGBA from, to; gdk_rgba_parse (&from, "blue"); gdk_rgba_parse (&to, "green"); pixbuf = meta_gradient_create_simple (width, height, &from, &to, type); if (with_alpha) { const unsigned char alphas[] = { 0xff, 0xaa, 0x2f, 0x0, 0xcc, 0xff, 0xff }; if (!gdk_pixbuf_get_has_alpha (pixbuf)) { GdkPixbuf *new_pixbuf; new_pixbuf = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0); g_object_unref (G_OBJECT (pixbuf)); pixbuf = new_pixbuf; } meta_gradient_add_alpha (pixbuf, alphas, G_N_ELEMENTS (alphas), META_GRADIENT_HORIZONTAL); draw_checkerboard (cr, width, height); } gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); cairo_rectangle (cr, 0, 0, width, height); cairo_fill (cr); g_object_unref (G_OBJECT (pixbuf)); }
int test_check(struct pldraw *pldraw, char * const *opts, int opts_n) { const struct plep_point origin = { .x = 0, .y = 0 }; struct plep *plep = pldraw_get_plep(pldraw); pldraw_color_t draw_col; unsigned long dim; int wfid; int n; int m; assert(pldraw != NULL); assert(g_initialised); if (opts_n > 0) { if (str2ul(&dim, opts[0]) < 0) { LOG("Invalid square dimension: %s", opts[0]); return -1; } } else { dim = pldraw_get_xres(pldraw) / 40; } if (opts_n > 1) { if (pldraw_str2col(pldraw, &draw_col, opts[1])) return -1; } else { draw_col = g_black; } if (opts_n > 2) { const char *wfid_str = opts[2]; wfid = plep_get_wfid(plep, wfid_str); if (wfid < 0) { LOG("Invalid waveform: %s", wfid_str); return -1; } LOG("waveform name: %s", wfid_str); } else { wfid = g_clear_wf; } if (dim == 0) return -1; n = 1 + ((pldraw_get_xres(pldraw) - 1) / dim); m = 1 + ((pldraw_get_yres(pldraw) - 1) / dim); draw_checkerboard(pldraw, &origin, dim, 0, n, m, draw_col); return plep_update_screen(plep, wfid); } int test_fill(struct pldraw *pldraw, char * const *opts, int opts_n) { struct plep *plep; pldraw_color_t col; int wfid; assert(pldraw != NULL); assert(g_initialised); plep = pldraw_get_plep(pldraw); if (opts_n < 1) col = g_white; else if (pldraw_str2col(pldraw, &col, opts[0])) return -1; if (opts_n > 1) { const char *wfid_str = opts[1]; wfid = plep_get_wfid(plep, wfid_str); if (wfid < 0) { LOG("Invalid waveform: %s", wfid_str); return -1; } LOG("waveform name: %s", wfid_str); } else { wfid = g_clear_wf; } pldraw_fill_screen(pldraw, col); return plep_update_screen(plep, wfid); } int test_sweep(struct pldraw *pldraw, char * const *opts, int opts_n) { struct plep *plep; unsigned long sleep_us = 10000; int i; assert(pldraw != NULL); plep = pldraw_get_plep(pldraw); if (opts_n >= 1) { unsigned long sleep_ms; if (str2ul(&sleep_ms, opts[0]) < 0) { LOG("Invalid sleep value: %s", opts[0]); return -1; } sleep_us = sleep_ms * 1000; } for (i = 0; i < 0xFF; ++i) { const pldraw_color_t col = pldraw_get_color(pldraw, i, i, i); pldraw_fill_screen(pldraw, col); plep_update_screen(plep, g_clear_wf); usleep(sleep_us); } return 0; } int test_none(struct pldraw *pldraw, char * const *opts, int opts_n) { pldraw = NULL; LOG("That's all folks!"); return 0; }