Next: , Previous: , Up: Part I Goodies   [Contents][Index]


6.4 Color Chooser

It’s also not uncommon that an application lets the user use an arbitrary color (not necessarily already in the colormap). The color chooser shows a form that allows the user to select a new color either using a HSV color wheel and a slider for the intensity or by entering HSV or RGB values directly.

xforms_images/colchooser

To show such a form call

int fl_show_color_chooser(const int *rgb_in, int * rgb_out);

The first argument is a pointer to an array with the 3 RGB values to use for the color to be displayed when the color chooser is shown. If it is NULL white is used. The second argument is another pointer to an array for the 3 RGB values of the selected color to be returned on success. On success the function returns 1 (and sets the rgb_out array), but if the user clicked on the "Cancel" button 0 gets returns (and the rgb_out array is not modified.

Please keep in mind that there’s no 1-to-1 mapping between the HSV and RGB color space, there are a lot more HSV than RGB triples and some colors don’t even have a unique representation in HSV space like, for example, all shades of grey, including white and black.