X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Futils%2Fhp2ps%2FShade.c;h=9e3274bf69f289a68da38a2c837eb5f200b5c833;hb=c883f6969ad957637649f3af1a2b6977555bdd32;hp=0a03decb958ea5a83f56a3846c0e81776d5e1494;hpb=e7d21ee4f8ac907665a7e170c71d59e13a01da09;p=ghc-hetmet.git diff --git a/ghc/utils/hp2ps/Shade.c b/ghc/utils/hp2ps/Shade.c index 0a03dec..9e3274b 100644 --- a/ghc/utils/hp2ps/Shade.c +++ b/ghc/utils/hp2ps/Shade.c @@ -1,7 +1,7 @@ +#include "Main.h" #include #include #include -#include "Main.h" #include "Defines.h" #include "Error.h" #include "Utilities.h" @@ -72,21 +72,59 @@ ShadeOf(ident) -#define N_SHADES 10 +#define N_MONO_SHADES 10 -static floatish shades[ N_SHADES ] = { +static floatish m_shades[ N_MONO_SHADES ] = { 0.00000, 0.20000, 0.60000, 0.30000, 0.90000, 0.40000, 1.00000, 0.70000, 0.50000, 0.80000 }; +#define N_COLOUR_SHADES 27 + +/* HACK: 0.100505 means 100% red, 50% green, 50% blue */ + +static floatish c_shades[ N_COLOUR_SHADES ] = { + 0.000000, 0.000010, 0.001000, 0.001010, 0.100000, + 0.100010, 0.101000, 0.101010, 0.000005, 0.000500, + 0.000510, 0.001005, 0.050000, 0.050010, 0.051000, + 0.051010, 0.100005, 0.100500, 0.100510, 0.101005, + 0.000505, 0.050005, 0.050500, 0.050510, 0.051005, + 0.100505, 0.050505 +}; + static floatish ThinkOfAShade() { - static int thisshade = 0; + static int thisshade = -1; + + thisshade++; + return cflag ? + c_shades[ thisshade % N_COLOUR_SHADES ] : + m_shades[ thisshade % N_MONO_SHADES ] ; +} + +static floatish +extract_colour(shade,factor) + floatish shade; + intish factor; +{ + intish i,j; - floatish x; + i = (int)(shade * factor); + j = i / 100; + return (i - j * 100) / 10.0; +} - x = shades[ thisshade ]; - thisshade = (thisshade + 1) % N_SHADES; - return x; +void +SetPSColour(shade) + floatish shade; +{ + if (cflag) { + fprintf(psfp, "%f %f %f setrgbcolor\n", + extract_colour(shade, (intish)100), + extract_colour(shade, (intish)10000), + extract_colour(shade, (intish)1000000)); + } else { + fprintf(psfp, "%f setgray\n", shade); + } }