There are four methods that deal
depth. They are
described in the following sections.
determine if the colormap for the widget is full, use
$isfull = $widget->colormapfull;
colormapfull method returns a 1 if the colormap is full and 0 if it is
The number of cells in the
colormap can be obtained by using the
$count = $widget->cells;
The value returned is a number indicating the number of colors; for example, 64.
You can get the number of bits per pixel
by using the
$depth = $widget->depth; # $depth might contain "16"
can translate a color name to the red, green, and blue values by
rgb method. Send
a color name and it returns a list containing three items that
represent the red, green, and blue numbers.
($red, $green, $blue) = $widget->rgb("color");
$blue each contain an integer from
to 2n-1, where
n is the number of bit planes in your
display. For 8-bit color, the maximum value is 255 (0xFF); for 16-bit
color, it’s 65,535 (0xFFFF).
When specifying a hexadecimal color, feel free to over-specify the value. For instance, if you want the color red, use 0xFFFF00000000. Tk will use it if possible, or will down-convert it to 0xFF0000 for an 8-bit display.
can have your entire application based on one color automatically by