2 // "$Id: cmap.cxx 7903 2010-11-28 21:06:39Z matt $"
4 // Colormap generation program for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 // This program produces the contents of "fl_cmap.h" as stdout
33 // This table is initialized with color values I got by reading the
34 // colormap on an IRIX 4.3 machine:
36 // "full intensity colors" have been turned down some to make white
37 // background less intense by default. The hope is that this will make
38 // fltk programs more friendly on color-adjusted screens. If you want
39 // pure colors you should get them out of the colormap.
41 //#define III 244 // maximum intensity of the basic colors
43 // that results in errors and unshared colormap entries, so full intensity:
44 #define III 255 // maximum intensity of the basic colors
46 static short cmap
[256][3] = {
51 {III
,III
, 0}, // yellow
53 {III
, 0,III
}, // magenta
55 {III
,III
,III
}, // white
56 // pastel versions of those colors, from SGI's standard color map:
57 { 85, 85, 85}, // 1/3 gray
58 {198,113,113}, // salmon? pale red?
59 {113,198,113}, // pale green
60 {142,142, 56}, // khaki
61 {113,113,198}, // pale blue
62 {142, 56,142}, // purple, orchid, pale magenta
63 { 56,142,142}, // cadet blue, aquamarine, pale cyan
64 // The next location is used for FL_SELECTION_COLOR. It formerly was 2/3 gray
65 // but this is changed to be the Windows blue color. This allows the default
66 // behavior on both X and Windows to match:
68 //{170,170,170}, // old 2/3 gray color
69 // These next 16 are the FL_FREE_COLOR area. In some versions of fltk
70 // these were filled with random colors that a Irix 5.3 machine placed
71 // in these locations. Other versions of fltk filled this with the 1/3
72 // gray above to discourage their use. This newest version uses colors
73 // that NewTek has assigned for their GUI:
75 // The Irix 5.3 colors:
93 // The NewTek colors: (from George Yohng)
111 // The rest of the colormap is a gray ramp and table, filled in below:
114 // This is Fl::background from Fl_get_system_colors.cxx, with modifications:
116 #define FL_GRAY_RAMP 32
117 #define FL_NUM_GRAY 24
118 #define FL_GRAY 49 // old value is 47
119 typedef unsigned char uchar
;
122 void background(uchar r
, uchar g
, uchar b
) {
123 // replace the gray ramp so that color 47 (by default 2/3) is this color
124 if (!r
) r
= 1; else if (r
==255) r
= 254;
125 double powr
= log(r
/255.0)/log((FL_GRAY
-FL_GRAY_RAMP
)/(FL_NUM_GRAY
-1.0));
126 if (!g
) g
= 1; else if (g
==255) g
= 254;
127 double powg
= log(g
/255.0)/log((FL_GRAY
-FL_GRAY_RAMP
)/(FL_NUM_GRAY
-1.0));
128 if (!b
) b
= 1; else if (b
==255) b
= 254;
129 double powb
= log(b
/255.0)/log((FL_GRAY
-FL_GRAY_RAMP
)/(FL_NUM_GRAY
-1.0));
130 for (int i
= 0; i
< FL_NUM_GRAY
; i
++) {
131 double gray
= i
/(FL_NUM_GRAY
-1.0);
132 cmap
[i
+FL_GRAY_RAMP
][0] = uchar(pow(gray
,powr
)*255+.5);
133 cmap
[i
+FL_GRAY_RAMP
][1] = uchar(pow(gray
,powg
)*255+.5);
134 cmap
[i
+FL_GRAY_RAMP
][2] = uchar(pow(gray
,powb
)*255+.5);
141 /* Read colormap colors into internal table */
144 cmwin
= winopen("CM");
145 for (i
=0; i
<256; i
++)
146 getmcolor(i
,&cmap
[i
][0],&cmap
[i
][1],&cmap
[i
][2]);
149 // overwrite the X allocation area with one color so people are
150 // discouraged from using it:
151 //for (i=16; i<32; i++) {cmap[i][0]=cmap[i][1]=cmap[i][2] = 85;}
153 // fill in the gray ramp:
154 background(0xc0, 0xc0, 0xc0); // microsoft colors
155 // background(170, 170, 170); // old fltk colors
156 // copy the 1/3 and 2/3 gray to the closest locations in gray ramp:
157 cmap
[39][0] = cmap
[39][1] = cmap
[39][2] = 85;
158 cmap
[47][0] = cmap
[47][1] = cmap
[47][2] = 170;
160 // fill in the color cube
164 for (g
=0; g
<8; g
++) {
165 cmap
[i
][0] = r
*255/4;
166 cmap
[i
][1] = g
*255/7;
167 cmap
[i
][2] = b
*255/4;
171 for (i
=0; i
<256; i
++) {
172 printf("\t0x%02x%02x%02x00",cmap
[i
][0],cmap
[i
][1],cmap
[i
][2]);
173 if (i
< 255) printf(",\n");
180 // End of "$Id: cmap.cxx 7903 2010-11-28 21:06:39Z matt $".