The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

DESCRIPTION

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.

USAGE

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.

ATTRIBUTES

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

EXPAND

The default is "NO".

RASTERSIZE

(non inheritable)

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

RGB

(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".

HSI

(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:

CALLBACKS

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

CHANGE_CB

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.

DRAG_CB

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.

VALUECHANGED_CB

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:

NOTES

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.

EXAMPLES

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

SEE ALSO

GetColor, IUP::ColorDlg

The original doc: iupcolorbrowser.html