/* set an srgb color */ int pl_setSRGBcolor(gs_state *pgs, float r, float g, float b) { int code; gs_client_color color; #ifdef DEVICE_DOES_COLOR_CONVERSION return gs_setrgbcolor(pgs, r, g, b); #endif /* make sure we have a crd set up */ code = pl_build_crd(pgs); if ( code < 0 ) return code; code = pl_setSRGB(pgs); if ( code < 0 ) return code; /* set the color */ color.paint.values[0] = r; color.paint.values[1] = g; color.paint.values[2] = b; code = gs_setcolor(pgs, &color); return code; }
/* setpattern */ int gs_setpattern(gs_state * pgs, const gs_client_color * pcc) { int code = gs_setpatternspace(pgs); if (code < 0) return code; return gs_setcolor(pgs, pcc); }
static int test2(gs_state * pgs, gs_memory_t * mem) { gs_client_color cc; gx_tile_bitmap tile; /*const */ byte tpdata[] = { /* Define a pattern that looks like this: ..xxxx .....x .....x ..xxxx .x.... x..... */ 0x3c, 0, 0, 0, 0x04, 0, 0, 0, 0x04, 0, 0, 0, 0x3c, 0, 0, 0, 0x40, 0, 0, 0, 0x80, 0, 0, 0 }; gs_newpath(pgs); gs_moveto(pgs, 100.0, 300.0); gs_lineto(pgs, 500.0, 500.0); gs_lineto(pgs, 200.0, 100.0); gs_lineto(pgs, 300.0, 500.0); gs_lineto(pgs, 500.0, 200.0); gs_closepath(pgs); gs_setrgbcolor(pgs, 0.0, 0.0, 0.0); gs_gsave(pgs); gs_fill(pgs); gs_grestore(pgs); tile.data = tpdata; tile.raster = 4; tile.size.x = tile.rep_width = 6; tile.size.y = tile.rep_height = 6; tile.id = gx_no_bitmap_id; gs_makebitmappattern(&cc, &tile, true, pgs, NULL); /* Note: color space is DeviceRGB */ cc.paint.values[0] = 0.0; cc.paint.values[1] = 1.0; cc.paint.values[2] = 1.0; gs_setpattern(pgs, &cc); gs_eofill(pgs); gs_makebitmappattern(&cc, &tile, false, pgs, NULL); gs_setcolor(pgs, &cc); gs_moveto(pgs, 50.0, 50.0); gs_lineto(pgs, 300.0, 50.0); gs_lineto(pgs, 50.0, 300.0); gs_closepath(pgs); gs_setrgbcolor(pgs, 1.0, 0.0, 0.0); gs_gsave(pgs); gs_fill(pgs); gs_grestore(pgs); gs_setpattern(pgs, &cc); gs_eofill(pgs); return 0; }
static void spectrum(gs_state * pgs, int n) { float den = n; float den1 = n - 1; float den2 = (n * 2 - 1) * n; int a, b, c; for (a = 0; a < n; ++a) for (b = 0; b < n; ++b) for (c = 0; c < n; ++c) { double size = (n * 2 - c * 2 - 1) / den2; gs_client_color cc; cc.paint.values[0] = a / den1; cc.paint.values[1] = b / den1; cc.paint.values[2] = c / den1; gs_setcolor(pgs, &cc); fill_rect1(pgs, a / den + c / den2, b / den + c / den2, size, size); } }