FLTK::Color - A color value (Wow, yeah, I know...)
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.
0xFF008000
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.
set_color_index()
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.
FLTK::NO_COLOR
-fg
FLTK::BLACK
BLACK
BLACK( );
Corner of color cube
Import this function with the :color tag.
:color
BLUE
BLUE( );
CYAN
CYAN( );
DARK_BLUE
DARK_BLUE( );
DARK_CYAN
DARK_CYAN( );
DARK_GREEN
DARK_GREEN( );
DARK_MAGENTA
DARK_MAGENTA( );
DARK_RED
DARK_RED( );
DARK_YELLOW
DARK_YELLOW( );
FREE_COLOR
FREE_COLOR( );
Starting from index 16 is the FREE_COLOR area
GRAY00
GRAY00( );
hex=00, dec=.00, framebox=A, fltk1 = GRAY0, GRAY_RAMP
GRAY05
GRAY05( );
hex=0d, dec=.05, framebox=B
GRAY10
GRAY10( );
hex=1a, dec=.10, framebox=C
GRAY15
GRAY15( );
hex=27, dec=.15, framebox=D
GRAY20
GRAY20( );
hex=34, dec=.20, framebox=E
GRAY25
GRAY25( );
hex=41, dec=.25, framebox=F
GRAY30
GRAY30( );
hex=4f, dec=.31, framebox=G
GRAY33
GRAY33( );
hex=5c, dec=.36, framebox=H, fltk1 = DARK3
GRAY35
GRAY35( );
hex=69, dec=.41, framebox=I
GRAY40
GRAY40( );
hex=76, dec=.46, framebox=J (18%% gray card)
GRAY45
GRAY45( );
hex=83, dec=.51, framebox=K
GRAY50
GRAY50( );
hex=90, dec=.56, framebox=L
GRAY55
GRAY55( );
hex=9e, dec=.62, framebox=M
GRAY60
GRAY60( );
hex=ab, dec=.67, framebox=N, fltk1 = DARK2
GRAY65
GRAY65( );
hex=b8, dec=.72, framebox=O
GRAY66
GRAY66( );
hex=c5, dec=.77, framebox=P, fltk1 = DARK1, INACTIVE_COLOR
GRAY70
GRAY70( );
hex=d2, dec=.82, framebox=Q
GRAY75
GRAY75( );
hex=e0, dec=.88, framebox=R, fltk1 = GRAY, SELECTION_COLOR
GRAY80
GRAY80( );
hex=e5, dec=.90, framebox=S
GRAY85
GRAY85( );
hex=ea, dec=.92, framebox=T, fltk1 = LIGHT1
GRAY90
GRAY90( );
hex=f4, dec=.96, framebox=V, fltk1 = LIGHT2
GRAY95
GRAY95( );
hex=f9, dec=.98, framebox=W
GRAY99
GRAY99( );
hex=ff, dec=1.0, framebox=X, fltk1 = LIGHT3
GREEN
GREEN( );
MAGENTA
MAGENTA( );
NO_COLOR
NO_COLOR( );
Black, empty place holder in Style
NUM_FREE_COLOR
NUM_FREE_COLOR( );
Number of free color slots starting from index FREE_COLOR
RED
RED( );
WHITE
WHITE( );
WINDOWS_BLUE
WINDOWS_BLUE( );
Default selection_color
YELLOW
YELLOW( );
color
my $c = $color->color( $name );
Turn a string into a color. If name is undef, this returns NO_COLOR. Otherwise it returns FLTK::parsecolor(name, strlen(name)).
name
undef
FLTK::parsecolor(name, strlen(name))
my $c = $color->color( $r, $g, $b );
contrast
my $color = $color->contrast( $fg, $bg );
Returns fg if fltk decides it can be seen well when drawn against a bg. Otherwise it returns either FLTK::BLACK or fltk::WHITE.
fg
bg
fltk::WHITE
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.
inactive
my $color = $color->inactive( $fore, $back );
Same as lerp(fg, bg, .5), it grays out the color.
lerp(fg, bg, .5)
my $color = $color->inactive( $fore );
Same as lerp(fg, getbgcolor(), .5). This is for back-compatability only?
lerp(fg, getbgcolor(), .5)
lerp
my $color = $color->lerp( $color1, $color2, $weight );
Return (1-weight)*color1 + weight*color2. weight is clamped to the 0-1 range before use.
(1-weight)*color1 + weight*color2
weight
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.
parsecolor
my $color = $color->parsecolor( $name, $length );
Same as the other one.
my $color = $color->parsecolor( $name );
Turn the first n bytes of name into an FLTK color. This allows you to parse a color out of the middle of a string.
n
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.
set_background
$color->set_background( $color );
FLTK::GRAY75 is replaced with the passed color, and all the other FLTK::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.
FLTK::GRAY75
FLTK::GRAY*
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, and color must be a non-indexed rgb color.
index
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.
r,g,b
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.
FLTK::set_background()
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.
5x8x5
Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
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.
To install FLTK, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FLTK
CPAN shell
perl -MCPAN -e shell install FLTK
For more information on module installation, please visit the detailed CPAN module installation guide.