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.
$colorbrowser = IUP::ColorBrowser->new( RGB=>"100 100 0" );
Returns: the identifier of the created element, or undef if an error occurs.
undef
NOTE: You can pass to new() other ATTRIBUTE=>'value' or CALLBACKNAME=>\&func pairs relevant to this element - see IUP::Manual::02_Elements.
new()
ATTRIBUTE=>'value'
CALLBACKNAME=>\&func
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.
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".
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:
ACTIVE, BGCOLOR, FONT, X, Y, POSITION, MINSIZE, MAXSIZE, WID, TIP, SIZE, ZORDER, VISIBLE
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.
sub drag_cb_handler { my ($self, $r, $g, $b) = @_; #... }
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.
sub drag_cb_handler { my ($self) = @_; #... }
The following common callbacks are also accepted:
MAP_CB, UNMAP_CB, GETFOCUS_CB, KILLFOCUS_CB, ENTERWINDOW_CB, LEAVEWINDOW_CB, K_ANY, HELP_CB
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:
0-basic/colorbrowser.pl - IUP::ColorBrowser example
GetColor, IUP::ColorDlg
The original doc: iupcolorbrowser.html
To install IUP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IUP
CPAN shell
perl -MCPAN -e shell install IUP
For more information on module installation, please visit the detailed CPAN module installation guide.