Fl::Color - Easily Imported Color-related Functions and Static Values
use Fl qw[:enum]; # Import with all enums! use Fl qw[:color]; # Import just the stuff in here
This file contains type definitions, general enumerations, and several functions which can be inported with the :color tag.
:color
Colors are either 8-bit indexes into a virtual colormap or 24-bit RGB color values. (See Fl::Draw for the default colormap)
Color indices occupy the lower 8 bits of the value, while RGB colors occupy the upper 24 bits, for a byte organization of RGBI.
Fl_Color => 0xrrggbbii | | | | | | | +--- index between 0 and 255 | | +----- blue color component (8 bit) | +------- green component (8 bit) +--------- red component (8 bit)
Here's a list of built-in colors:
The default foreground color used for labels and text.
The default background color for text, list, and valuator widgets.
The inactive foreground color.
The default selection/highlight color.
The following functions are also imported with the :color tag.
my $inactive_red = fl_inactive(FL_RED);
Returns the inactive, dimmed version of the given color.
my $fg = FL_RED; my $bg = FL_BLACK; my $color = fl_contrast($fg, $bg);
Returns a color that contrasts with the background color.
This will be the foreground color if it contrasts sufficiently with the background color. Otherwise, returns FL_WHITE or FL_BLACK depending on which color provides the best contrast.
FL_WHITE
FL_BLACK
my $average = fl_color_average(FL_RED, FL_BLUE, .14);
Returns the weighted average color between the two given colors.
The red, green and blue values are averages using the following formula:
color = color1 * weight + color2 * (1 - weight)
Thus, a weight value of 1.0 will return the first color, while a value of 0.0 will return the second color.
my $light_red = fl_lighter(FL_RED);
Returns a lighter version of the specified color.
my $dark_red = fl_darker(FL_RED);
Returns a darker version of the specified color.
my $color = fl_rgb_color(100, 200, 180);
Returns the 24-bit color value closest to r, b, g.
my $gray = fl_rgb_color(13);
Returns the 24-bit color value closest to g (grayscale).
my $gray = fl_gray_ramp(20 / 255);
Returns a gray color value scaled from black to white.
my ($r, $g, $b) = (200, 180, 0); my $color = fl_color_cube($r, $b, $g);
Returns a color out of the color cube.
$r must be in the range 0 to FL_NUM_RED - 1, $g must be in the range 0 to FL_NUM_GREEN - 1, $b must be in the range 0 to FL_NUM_BLUE - 1.
$r
$g
$b
To get the closest color to a 8-bit set of R,G,B values use:
fl_color_cube(R * (FL_NUM_RED - 1) / 255, G * (FL_NUM_GREEN - 1) / 255, B * (FL_NUM_BLUE - 1) / 255);
my $new_color = fl_show_colormap(FL_RED);
Pops up a window to let the user pick a colormap entry. The provided color is highlighted when the grid is shown.
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Sanko Robinson <sanko@cpan.org>
To install Fl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fl
CPAN shell
perl -MCPAN -e shell install Fl
For more information on module installation, please visit the detailed CPAN module installation guide.