GNU Astronomy Utilities

12.3.30 Color functions (color.h)

The available pre-defined colors in Gnuastro are shown and discussed in Vector graphics colors. This part of Gnuastro is currently in charge of mapping the color names to the color IDs and to return the red-green-blue fractions of each color. On a terminal that supports 24-bit (true color), you can see the full list of color names and a demo of each color with this command:

$ astconvertt --listcolors

For each color we have a separate macro that starts with GAL_COLOR_, and ends with the color name in all-caps.

Macro: GAL_COLOR_*

The integer identifiers for each of the named colors in Gnuastro. Except for the first one (GAL_COLOR_INVALID), we currently have 140 colors from the extended web colors. The full list of colors and a demo can be visually inspected on the command-line with the astconvertt --listcolors command and is also shown in Vector graphics colors. The macros have the same names, just in full-caps.

The functions below can be used to interact with the pre-defined colors:

gal_color_name_to_id (char *name)

Given the name of a color, return the identifier. The name matching is not case-sensitive.

char *
gal_color_id_to_name (uint8_t color)

Given the ID of a color, return its name.

gal_color_in_rgb (uint8_t color, float *f)

Given the identifier of a color, write the color’s red-green-blue fractions in the space that f points to. It is up to the caller to have the space for three 32-bit floating point numbers to be already allocated before calling this function.