Class Color

(back to index)

Color constants and functions

Function index



FLTK manages colors via a fixed palette indexed by small integers. Color provides named colors and functions for manipulating them.

Here are the named colors:

Detailed reference

Color:gray_ramp(integer i): Color

Returns a gray color. Returns black for zero, returns white for Color.num_gray (which is 24) minus 1. To get the closest to an 8-bit gray value 'I' use Color.gray_ramp(I*Color.num_gray/256).

Color:find_color_cube(integer r, integer g, integer b): Color

Returns a color out of the color cube. r must be in the range 0 to Color.num_red (5) minus 1. g must be in the range 0 to Color.num_green (8) minus 1. b must be in the range 0 to Color.num_blue (5) minus 1. To get the closest color to a 8-bit set of R,G,B values use Color.find_color_cube(R*Color.num_red/256, G*Color.num_green/256, B*Color.num_blue/256).

Color:inactive(Color c): Color

Returns the Color substituted for c when it's drawn in an inactive widget.

Color:contrast(Color fg, Color bf): Color

Returns a color that has sufficient contrast. This isn't documented in the FLTK manual.

Color:average(Color c1, Color c2, number weight): Color

Find the closest Color to the average of c1 and c2, giving c1 a weight of weight.

Color:set_color(integer r, integer g, integer b): void

Sets an entry in the fl_color index table. You can set it to any 8-bit RGB color. (The color is not actually allocated until the FLTK function fl_color(i) is used.)

Color:get_color(Color c): integer r, integer g, integer b

Returns the RGB value for the given FLTK Color.

doctool generated at Sun Aug 12 22:23:18 2001