Update FLTK colormap (src/fl_cmap.h) w/o changing colors

- update comments, including filenames
- update build instructions for developers in util/cmap.cxx
- update CMakeLists.txt (comments only)
This commit is contained in:
Albrecht Schlosser 2026-01-03 16:28:02 +01:00
parent 775239c2fc
commit 869df69ff2
4 changed files with 58 additions and 22 deletions

View File

@ -4,7 +4,7 @@
// This file must be generated by "util/cmap.cxx".
// See instructions in this file.
//
// Copyright 1998-2022 by Bill Spitzak and others.
// Copyright 1998-2026 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@ -273,5 +273,5 @@
0xffdaff00, // 254
0xffffff00 // 255
//
// End of fl_cmap.h - generated by cmap.cxx
// End of src/fl_cmap.h - generated by util/cmap.cxx
//

View File

@ -24,8 +24,10 @@
# cmap - colormap generation program
#######################################################################
# This program produces the contents of "fl_cmap.h"
# It's used during the build process to generate src/fl_cmap.h
# This program produces the contents of "src/fl_cmap.h".
# It can be used to modify the built-in colormap in src/fl_cmap.h.
# This utility must be built and executed manually. See instructions
# in util/cmap.cxx .
add_executable(cmap cmap.cxx)
@ -72,5 +74,5 @@ endif(FLTK_BUILD_PDF_DOCS)
# Install rules (if any tools need to be installed)
#######################################################################
# Currently no utilities are installed as they are build-time tools only
# If you need to install any utilities, add install() commands here
# Currently no utilities are installed as they are build-time tools only.
# If you need to install any utilities, add install() commands here.

View File

@ -3,7 +3,8 @@ Utility programs used to build the FLTK library.
Contents:
cmap.cxx generate src/fl_cmap.h
cmap.cxx generate the built-in colormap (src/fl_cmap.h)
code_snapshot.cxx PDF documentation tool to generate a png image from a
Doxygen `@code` segment with international characters
@ -13,7 +14,11 @@ Build System:
automatically during the build process when needed. Some utilities
are only built when specific features are enabled:
- the PDF documentation helper is only built when FLTK_BUILD_PDF_DOCS=ON
- The colormap generator `bin/cmap` is only built manually if needed
to generate a new colormap (src/fl_cmap.h).
See instructions in util/cmap.cxx.
- The PDF documentation helper is only built when FLTK_BUILD_PDF_DOCS=ON.
To add a new utility, edit util/CMakeLists.txt and follow the existing
patterns for conditional building and target configuration.

View File

@ -1,7 +1,7 @@
//
// Colormap generation program for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2022 by Bill Spitzak and others.
// Copyright 1998-2026 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@ -15,23 +15,51 @@
//
//
// This program produces the contents of "fl_cmap.h" on stdout
// This program produces the contents of "fl_cmap.h" on stdout. If you
// need to change the built-in FLTK colormap, change this source file
// accordingly and proceed as follows:
//
// Compile, link, run and delete the program 'cmap' (for instance on a
// Linux system) to generate fl_cmap.h:
// (1) Build the program `bin/cmap`
//
// $ `MAKE` cmap # see below for details
//
// or
//
// $ cmake --build . --target cmap
//
// in your CMake build directory (replace `MAKE` with your build tool,
// for instance `make` or `ninja` or whatever you chose to build FLTK).
//
// (2) Run the program from the build folder:
//
// $ bin/cmap > output.h
//
// (3) Compare `output.h` with the existing file in the source folder
// `[fltk-source-dir]/src/fl_cmap.h`. Take care that the result (diff)
// is plausible.
//
// (4) Replace `[fltk-source-dir]/src/fl_cmap.h` in the FLTK source tree
// with the created file `output.h`.
//
// (5) Build and test FLTK, check if the new color map is as intended.
//
// (6) Finally check in *both* modified file with `git commit` and push
// your changes to the main repository with `git push`.
//
// Note: the created executable `bin/cmap` is temporary and may be deleted
// at any time. It is not intended to be `installed` with the FLTK library.
//
// gcc -o cmap cmap.cxx -lm && ./cmap > ../src/fl_cmap.h && rm -f ./cmap
#include <stdio.h>
#include <math.h>
#include <time.h>
// This table is initialized with color values I got by reading the
// colormap on an IRIX 4.3 machine:
// This table is initialized with color values taken from the colormap
// on an IRIX 4.3 machine:
// "full intensity colors" have been turned down some to make white
// background less intense by default. The hope is that this will make
// fltk programs more friendly on color-adjusted screens. If you want
// FLTK programs more friendly on color-adjusted screens. If you want
// pure colors you should get them out of the colormap.
// #define III 244 // maximum intensity of the basic colors
@ -63,15 +91,15 @@ static short cmap[256][3] = {
{142, 56,142}, // purple, orchid, pale magenta
{ 56,142,142}, // cadet blue, aquamarine, pale cyan
// The next location (15) is used for FL_SELECTION_COLOR. It formerly was
// 2/3 gray but this is changed to be the Windows blue color. This allows
// the default behavior on both X and Windows to match:
// The next location (index 15) is used for FL_SELECTION_COLOR. It formerly
// was 2/3 gray but this is changed to be the Windows blue color. This
// allows the default behavior on both X and Windows to match:
// {170,170,170}, // old 2/3 gray color
{ 0, 0,128}, // 15 = FL_SELECTION_COLOR
// These next 16 (index 16 - 31) are the FL_FREE_COLOR area. In some
// versions of fltk these were filled with random colors that a Irix 5.3
// versions of FLTK these were filled with random colors that a Irix 5.3
// machine placed in these locations.
// This version uses colors that NewTek has assigned for their GUI
@ -101,7 +129,8 @@ static short cmap[256][3] = {
#define FL_GRAY_RAMP 32
#define FL_NUM_GRAY 24
#define FL_GRAY 49 // old value is 47
#define FL_GRAY 49 // old value is 47
typedef unsigned char uchar;
void background(uchar r, uchar g, uchar b) {
@ -191,7 +220,7 @@ int main() {
// write final comment
printf("//\n");
printf("// End of fl_cmap.h - generated by cmap.cxx\n");
printf("// End of src/fl_cmap.h - generated by util/cmap.cxx\n");
printf("//\n");
return 0;