NAME
FLTK::Color - A color value (Wow, yeah, I know...)
Description
FLTK::Color is a typedef for a 32-bit integer containing r,g,b bytes and an "index" in the lowest byte (the first byte on a little-endian machine such as an x86). For instance 0xFF008000
is 255 red, zero green, and 128 blue. If rgb are not zero then the low byte is ignored, or may be treated as "alpha" by some code.
If the rgb is zero, the N is the color "index". This index is used to look up an FLTK::Color in an internal table of 255 colors shown here. All the indexed colors may be changed by using set_color_index()
. However FLTK uses the ones between 32 and 255 and assummes they are not changed from their default values.
A Color of zero (FLTK::NO_COLOR
) will draw black but is ambiguous. It is returned as an error value or to indicate portions of a Style that should be inherited, and it is also used as the default label color for everything so that changing color zero can be used by the -fg
switch. You should use FLTK::BLACK
(56) to get black.
Functions
BLACK
BLUE
CYAN
DARK_BLUE
DARK_CYAN
DARK_GREEN
DARK_MAGENTA
DARK_RED
DARK_YELLOW
FREE_COLOR
FREE_COLOR( );
-
Starting from index 16 is the FREE_COLOR area
Import this function with the
:color
tag.
GRAY00
GRAY00( );
-
hex=00, dec=.00, framebox=A, fltk1 = GRAY0, GRAY_RAMP
Import this function with the
:color
tag.
GRAY05
GRAY10
GRAY15
GRAY20
GRAY25
GRAY30
GRAY33
GRAY35
GRAY40
GRAY45
GRAY50
GRAY55
GRAY60
GRAY65
GRAY66
GRAY66( );
-
hex=c5, dec=.77, framebox=P, fltk1 = DARK1, INACTIVE_COLOR
Import this function with the
:color
tag.
GRAY70
GRAY75
GRAY75( );
-
hex=e0, dec=.88, framebox=R, fltk1 = GRAY, SELECTION_COLOR
Import this function with the
:color
tag.
GRAY80
GRAY85
GRAY90
GRAY95
GRAY99
GREEN
MAGENTA
NO_COLOR
NUM_FREE_COLOR
NUM_FREE_COLOR( );
-
Number of free color slots starting from index FREE_COLOR
Import this function with the
:color
tag.
RED
WHITE
WINDOWS_BLUE
YELLOW
color
my $c = $color->color( $name );
-
Turn a string into a color. If
name
isundef
, this returnsNO_COLOR
. Otherwise it returnsFLTK::parsecolor(name, strlen(name))
.Import this function with the
:color
tag. my $c = $color->color( $r, $g, $b );
-
Import this function with the
:color
tag.
contrast
my $color = $color->contrast( $fg, $bg );
-
Returns
fg
if fltk decides it can be seen well when drawn against abg
. Otherwise it returns eitherFLTK::BLACK
orfltk::WHITE
.Import this function with the
:color
tag.
get_color_index
$color->get_color_index( $color );
-
Return the rgb form of
color
. If it is an indexed color that entry is returned. If it is an rgb color it is returned unchanged.Import this function with the
:color
tag.
inactive
my $color = $color->inactive( $fore, $back );
-
Same as
lerp(fg, bg, .5)
, it grays out the color.Import this function with the
:color
tag. my $color = $color->inactive( $fore );
-
Same as
lerp(fg, getbgcolor(), .5)
. This is for back-compatability only?Import this function with the
:color
tag.
lerp
my $color = $color->lerp( $color1, $color2, $weight );
-
Return
(1-weight)*color1 + weight*color2
.weight
is clamped to the 0-1 range before use.Import this function with the
:color
tag.
nearest_index
my $color = $color->nearest_index( $color );
-
Find an indexed color in the range 56-127 that is closest to this color. If this is an indexed color it is returned unchanged.
Import this function with the
:color
tag.
parsecolor
my $color = $color->parsecolor( $name, $length );
-
Same as the other one.
Import this function with the
:color
tag. my $color = $color->parsecolor( $name );
-
Turn the first
n
bytes ofname
into an FLTK color. This allows you to parse a color out of the middle of a string.Recognized values are:
"" turns into NO_COLOR
"0"-"99" decimal fltk color number, only works for indexed color range
"0xnnn" hex value of any fltk color number
"rgb" or "#rgb" three hex digits for rgb
"rrggbb" or "#rrggbb" 2 hex digits for each of rgb
"rrggbbaa" or "#rrggbbaa" fltk color number in hex
"rrrgggbbb" or "#rrrgggbbb" 3 hex digits for each of rgb
"rrrrggggbbbb" or "#rrrrggggbbbb" 4 hex digits for each of rgb
17 "web safe colors" as defined by CSS 2.1
If FLTK is compiled to use X11, then XParseColor() is tried
all other strings return NO_COLOR.
Import this function with the
:color
tag.
set_background
$color->set_background( $color );
-
FLTK::GRAY75
is replaced with the passed color, and all the otherFLTK::GRAY*
colors are replaced with a color ramp (or sometimes a straight line) so that using them for highlighted edges of raised buttons looks correct.Import this function with the
:color
tag.
set_color_index
$color->set_color_index( $index, $color );
-
Set one of the indexed colors to the given rgb color.
index
must be in the range 0-255, andcolor
must be a non-indexed rgb color.Import this function with the
:color
tag.
split_color
my @rgb = $color->split_color( $color );
-
Set
r,g,b
to the 8-bit components of this color. If it is an indexed color they are looked up in the table, otherwise they are simply copied out of the color number.Import this function with the
:color
tag.
Functions
Symbolic names for some of the indexed colors.
The 24-entry "gray ramp" is modified by FLTK::set_background()
so that the color FLTK::GRAY75
is the background color, and the others are a nice range from black to a lighter version of the gray. These are used to draw box edges. The gray levels are chosen to be evenly spaced, listed here is the actual 8-bit and decimal gray level assigned by default. Also listed here is the letter used for FLTK::FrameBox and the old fltk1.1 names used for these levels.
The remiander of the colormap is a 5x8x5
color cube. This cube is used to dither images on 8-bit screens X colormaps to reduce the number of colors used.
Author
Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
License and Legal
Copyright (C) 2008-2010 by Sanko Robinson <sanko@cpan.org>
This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.
When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.