View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
kmx > IUP > IUP::ColorBrowser



Annotate this POD


New  2
Open  1
View/Report Bugs


IUP::ColorBrowser - [GUI element] color selector via cylindrical projection of the RGB cube


Creates an element for selecting a color. The selection is done using a cylindrical projection of the RGB cube. The transformation defines a coordinate color system called HSI, that is still the RGB color space but using cylindrical coordinates.

H is for Hue, and it is the angle around the RGB cube diagonal starting at red (RGB=255 0 0).

S is for Saturation, and it is the normal distance from the color to the diagonal, normalized by its maximum value at the specified Hue. This also defines a point at the diagonal used to define I.

I is for Intensity, and it is the distance from the point defined at the diagonal to black (RGB=0 0 0). I can also be seen as the projection of the color vector onto the diagonal. But I is not linear, see Notes below.

NOTE: For a dialog that simply returns the selected color, you can use function GetColor or IUP::ColorDlg.


CREATION - new() method

 $colorbrowser = IUP::ColorBrowser->new( RGB=>"100 100 0" );

Returns: the identifier of the created element, or undef if an error occurs.

NOTE: You can pass to new() other ATTRIBUTE=>'value' or CALLBACKNAME=>\&func pairs relevant to this element - see IUP::Manual::02_Elements.


For more info about concept of attributes (setting/getting values etc.) see IUP::Manual::03_Attributes. Attributes specific to this element:


The default is "NO".


(non inheritable)

The initial size is "181x181". Set to undef to allow the automatic layout use smaller values.


(non inheritable)

The color selected in the control, in the "r g b" format; r, g and b are integers ranging from 0 to 255. Default: "255 0 0".


(non inheritable)

The color selected in the control, in the "h s i" format; h, s and i are floating point numbers ranging from 0-360, 0-1 and 0-1 respectively.

The following common attributes are also accepted:


For more info about concept of callbacks (setting callback handlers etc.) see IUP::Manual::04_Callbacks. Callbacks specific to this element:


Called when the user releases the left mouse button over the control, defining the selected color.

Callback handler prototype:

 sub change_cb_handler {
   my ($self, $r, $g, $b) = @_;

$self: reference to the element (IUP::ColorBrowser) that activated the event

$r, $g, $b: color value.


Called several times while the color is being changed by dragging the mouse over the control.

Callback handler prototype:

 sub drag_cb_handler {
   my ($self, $r, $g, $b) = @_;

$self: reference to the element (IUP::ColorBrowser) that activated the event

$r, $g, $b: color value.


Called after the value was interactively changed by the user. It is called whenever a CHANGE_CB or a DRAG_CB would also be called, it is just called after them.

Callback handler prototype:

 sub drag_cb_handler {
   my ($self) = @_;

$self: reference to the element (IUP::ColorBrowser) that activated the event

The following common callbacks are also accepted:


When the control has the focus the keyboard can be used to change the color value. Use the arrow keys to move the cursor inside the SI triangle, and use Home(0), PageUp, PageDn and End(180) keys to move the cursor inside the Hue circle.

The Hue in the HSI coordinate system defines a plane that it is a triangle in the RGB cube. But the maximum saturation in this triangle is different for each Hue because of the geometry of the cube. In ColorBrowser this point is fixed at the center of the I axis. So the I axis is not completely linear, it is linear in two parts, one from 0 to 0.5, and another from 0.5 to 1.0. Although the selected values are linear specified you can notice that when Hue is changed the gray scale also changes, visually compacting values above or below the I=0.5 line according to the selected Hue.


The element IUP::ColorBrowser is used in the following sample scripts:


GetColor, IUP::ColorDlg

The original doc: iupcolorbrowser.html

syntax highlighting: