The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Tk::ColorPicker - Frame based megawidget for selecting a color.

SYNOPSIS

  use Tk::ColorPicker;
  my $pick = $widow->ColorPicker->pack;

DESCRIPTION

Tk::ColorPicker lets you edit a color in RGB, CMY and HSV space. It has a facility to pick a screen color with your mouse. It offers a history of previous selected colors. It can work in color depths of 4, 8, 12 or 16 bits per channel. You can switch color depth on the fly.

OPTIONS

Switch: -colordepth

Default value 8 bits per color channel. Can be 4, 8, 12 or 16;

Switch: -depthselect

Default value 0. If set a row of radiobuttons is diplayed allowing you to switch color depth.

Switch: -historycolumns

Default value 6. Number of columns in the history tab.

Switch: -historyfile

Undefined by default. Here you set the filename from where the history is saved and loaded.

Switch: -indborderwidth

Default value 2. Borderwidth of indicator labels in the recent tab.

Switch: -indicatorwidth

Default value 4. Width of the indicator labels in the recent tab.

Switch: -indrelief

Default value 'sunken'. Relief of the indicator labels in the recent tab.

Switch: -maxhistory

Default value 32.Specifies the maximum number of entries in the history list.

Switch: -sliderheight

Default value 200. Sets the length of all channel sliders.

Switch: -updatecall

Set this callback to reflect changes to the outside. Gets the current color as parameter.

METHODS

colorDepth($hexcolor)

Returns the color depth of $hexcolor.

compoundColor

Returns a hex color string based on the Red, Green and Blue channels.

convertDepth($string, ?<I$depth>?)

Converts the depth of $string to $depth. If $depth is not specified, -colordepth is used

hex2rgb($hex)

Converts $hex to Red, Green Blue values.

hexString($num, ?$depth?>)

Returns the hexadecimal notation of $num. If $depth is not specified, -colordepth is used

historyAdd($color)

Adds color to the History list. Saves the list and updates the history tab.

historyClear

Clears the history list.

historyLoad

Loads the history file if it is specified.

historyNew($color)

Adds $color to the history list

historyReset

Clears the history list. Then saves and updates.

historySave

Saves the history list.

historyUpdate

Updates the history tab.

maxChannelValue

Returns the maximum values for the Red, Green, Blue, Cyan, Magenta and Yellow channels, based on -colordepth.

put($color)

Changes all sliders to match $color

rgb2hex($red, $green, $blue, ?$depth?)

Converts the red, green and blue values to a hexstring. If depth is not specified, -colordepth is used.

validate(?$color?)

Returns true if $color is a valid hexcolor.

LICENSE

Same as Perl.

AUTHOR

Hans Jeuken (hanje at cpan dot org)

BUGS

Switching color depth straight after initialization gives unwanted results.

Cancelling a pick operation only works in the context of Tk::ColorEntry.