diff options
| author | Simon Tatham <anakin@pobox.com> | 2008-04-07 17:13:29 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2008-04-07 17:13:29 +0000 |
| commit | 0564211167adbea5a5ad1c83ad6f244956ed5b72 (patch) | |
| tree | d790294de7314cfb8328169ac7a77c10792f3a64 /ps.c | |
| parent | 30da25262d14155909acf6e445691e6f1365cca2 (diff) | |
| download | puzzles-0564211167adbea5a5ad1c83ad6f244956ed5b72.zip puzzles-0564211167adbea5a5ad1c83ad6f244956ed5b72.tar.gz puzzles-0564211167adbea5a5ad1c83ad6f244956ed5b72.tar.bz2 puzzles-0564211167adbea5a5ad1c83ad6f244956ed5b72.tar.xz | |
Revise the printing colour framework so that we can explicitly
request either of hatching or halftoning, and also choose which to
supply as a fallback when printing in colour.
[originally from svn r7976]
Diffstat (limited to 'ps.c')
| -rw-r--r-- | ps.c | 34 |
1 files changed, 16 insertions, 18 deletions
@@ -35,12 +35,13 @@ static void ps_fill(psdata *ps, int colour) int hatch; float r, g, b; - print_get_colour(ps->drawing, colour, &hatch, &r, &g, &b); + print_get_colour(ps->drawing, colour, ps->colour, &hatch, &r, &g, &b); - if (ps->colour) { - ps_printf(ps, "%g %g %g setrgbcolor fill\n", r, g, b); - } else if (hatch == HATCH_SOLID || hatch == HATCH_CLEAR) { - ps_printf(ps, "%d setgray fill\n", hatch == HATCH_CLEAR); + if (hatch < 0) { + if (ps->colour) + ps_printf(ps, "%g %g %g setrgbcolor fill\n", r, g, b); + else + ps_printf(ps, "%g setgray fill\n", r); } else { /* Clip to the region. */ ps_printf(ps, "gsave clip\n"); @@ -77,20 +78,17 @@ static void ps_setcolour_internal(psdata *ps, int colour, char *suffix) int hatch; float r, g, b; - print_get_colour(ps->drawing, colour, &hatch, &r, &g, &b); + print_get_colour(ps->drawing, colour, ps->colour, &hatch, &r, &g, &b); - if (ps->colour) { - if (r != g || r != b) - ps_printf(ps, "%g %g %g setrgbcolor%s\n", r, g, b, suffix); - else - ps_printf(ps, "%g setgray%s\n", r, suffix); - } else { - /* - * Stroking in hatched colours is not permitted. - */ - assert(hatch == HATCH_SOLID || hatch == HATCH_CLEAR); - ps_printf(ps, "%d setgray%s\n", hatch == HATCH_CLEAR, suffix); - } + /* + * Stroking in hatched colours is not permitted. + */ + assert(hatch < 0); + + if (ps->colour) + ps_printf(ps, "%g %g %g setrgbcolor%s\n", r, g, b, suffix); + else + ps_printf(ps, "%g setgray%s\n", r, suffix); } static void ps_setcolour(psdata *ps, int colour) |