17 static int shademapmax = 0;
18 static int shademapindex = 0;
21 * Set the shade to be used for "ident" to "shade".
25 ShadeFor(ident, shade)
30 shademapmax = (nidents > TWENTY ? nidents : TWENTY) * 2;
31 /* Assume nidents read is indication of the No of
32 idents in the .aux file (*2 for good luck) */
33 /* NB *2 is needed as .aux and .hp elements may differ */
34 shademap = xmalloc(shademapmax * sizeof(struct shade));
37 if (shademapindex < shademapmax) {
38 shademap[ shademapindex ].ident = copystring(ident);
39 shademap[ shademapindex ].shade = shade;
42 Disaster("shade map overflow");
47 * Get the shade to be used for "ident" if there is one.
48 * Otherwise, think of a new one.
51 static floatish ThinkOfAShade PROTO((void)); /* forward */
60 for (i = 0; i < shademapindex; i++) {
61 if (strcmp(shademap[i].ident, ident) == 0) { /* got it */
62 return(shademap[i].shade);
66 shade = ThinkOfAShade();
68 ShadeFor(ident, shade);
75 #define N_MONO_SHADES 10
77 static floatish m_shades[ N_MONO_SHADES ] = {
78 0.00000, 0.20000, 0.60000, 0.30000, 0.90000,
79 0.40000, 1.00000, 0.70000, 0.50000, 0.80000
82 #define N_COLOUR_SHADES 27
84 /* HACK: 0.100505 means 100% red, 50% green, 50% blue */
86 static floatish c_shades[ N_COLOUR_SHADES ] = {
87 0.000000, 0.000010, 0.001000, 0.001010, 0.100000,
88 0.100010, 0.101000, 0.101010, 0.000005, 0.000500,
89 0.000510, 0.001005, 0.050000, 0.050010, 0.051000,
90 0.051010, 0.100005, 0.100500, 0.100510, 0.101005,
91 0.000505, 0.050005, 0.050500, 0.050510, 0.051005,
98 static int thisshade = -1;
102 c_shades[ thisshade % N_COLOUR_SHADES ] :
103 m_shades[ thisshade % N_MONO_SHADES ] ;
107 extract_colour(shade,factor)
113 i = (int)(shade * factor);
115 return (i - j * 100) / 10.0;
123 fprintf(psfp, "%f %f %f setrgbcolor\n",
124 extract_colour(shade, (intish)100),
125 extract_colour(shade, (intish)10000),
126 extract_colour(shade, (intish)1000000));
128 fprintf(psfp, "%f setgray\n", shade);