int fl_color_chooser(const char*, double& r, double& g, double&
b);
int fl_color_chooser(const char*, uchar& r, uchar& g, uchar&
b);
The double version takes r,g,b values in the range 0.0 to 1.0. The
uchar version takes r,g,b values in the range 0 to 255.
fl_color_chooser() pops up a window to let the user pick an
arbitrary rgb color. They can pick the hue and saturation in the "hue
box" on the left (hold down Ctrl to just change the saturation), and
the brighness using the vertical slider. Or they can type the 8-bit
numbers into the rgb Fl_Value_Input fields, or
drag the mouse across them to adjust them. The pull-down menu lets
the user set the input fields to show rgb, hsv, or 8-bit rgb (0 to
255).
This returns non-zero if the user picks ok, and updates the r,g,b
values. If the user picks cancel or closes the window this returns
zero and leaves r,g,b unchanged.
If you use the color chooser on an 8-bit screen, it will allocate
all the available X colors, leaving you no space to exactly represent
the color the user picks! You can however use fl_rectf() to fill a region with a
simulated color using dithering.
fl_show_colormap() pops up a panel of the 256 colors you
can access with fl_color() and lets the
user pick one of them. It returns the new color index, or the old one
if the user types Esc or clicks outside the window.
class Fl_Color_Chooser : public Fl_Group
A widget for selecting an rgb color. You can place any number of
these into a panel of your own design. This widget contains the hue
box, value slider, and rgb input fields from the above diagram (it
does not have the color chips or the Cancel or OK buttons). The
callback is done every time the user changes the rgb value. It is
not done if they move the hue control in a way that produces the
same rgb value, such as when saturation or value is zero.
Fl_Color_Chooser::Fl_Color_Chooser(int,int,int,int,const
char* = 0);
Constructor. Recommended dimensions are 200x95. The color
is initialized to black.
double Fl_Color_Chooser::hue() const;
Return the current hue. 0 <= hue < 6. Zero is red, one is
yellow, 2 is green, etc. This value is convienent for the internal
calculations. Some other systems consider hue to run from zero to
one, or from zero to 360.
double Fl_Color_Chooser::saturation() const;
Returns the saturation. 0 <= saturation <= 1.
double Fl_Color_Chooser::value() const;
Returns the value/brightness. 0 <= value <= 1.
double Fl_Color_Chooser::r() const;
double Fl_Color_Chooser::g() const;
double Fl_Color_Chooser::b() const;
Returns the current r,g,b values. 0 <= value <= 1.
int Fl_Color_Chooser::rgb(double, double,
double);
Sets the current rgb color values. Does not do the callback. Does
not clamp (but out of range values will produce psychedelic effects in
the hue selector).
int Fl_Color_Chooser::hsv(double,double,double);
Set the hsv values. The passed values are clamped (or for hue,
modulus 6 is used) to get legal values. Does not do the callback.
static void Fl_Color_Chooser::hsv2rgb(double, double,
double, double&, double&, double&);
static void Fl_Color_Chooser::rgb2hsv(double, double, double, double&,
double&, double&);
These static functions can be used to convert rgb from and to
hsv.
#include <FL/fl_show_colormap.H>
int fl_show_colormap(int oldcol);