rgb_from_name
Red, Green and Blue value of the named color. These values are integer in 0 .. 255.
my @rgb = Graphics::Toolkit::Color::Name::rgb_from_name('darkblue');
@rgb = Graphics::Toolkit::Color::Name::rgb_from_name('dark_blue'); # same result
@rgb = Graphics::Toolkit::Color::Name::rgb_from_name('DarkBlue'); # still same
hsl_from_name
Hue, saturation and lightness of the named color. These are integer between 0 .. 359 (hue) or 100 (sat.
& light.). A hue of 360 and 0 (degree in a cylindrical coordinate system) is considered to be the same,
this modul deals only with the ladder.
my @hsl = Graphics::Toolkit::Color::Name::hsl_from_name('darkblue');
name_from_rgb
Returns name of color with given rgb value triplet. Returns empty string if color is not stored. When
several names define given color, the shortest name will be selected in scalar context. In array context
all names are given.
say Graphics::Toolkit::Color::Name::name_from_rgb( 15, 10, 121 ); # 'darkblue'
say Graphics::Toolkit::Color::Name::name_from_rgb([15, 10, 121]); # works too
name_from_hsl
Returns name of color with given hsl value triplet. Returns empty string if color is not stored. When
several names define given color, the shortest name will be selected in scalar context. In array context
all names are given.
say scalar Graphics::Toolkit::Color::Name::name_from_hsl( 0, 100, 50 ); # 'red'
scalar Graphics::Toolkit::Color::Name::name_from_hsl([0, 100, 50]); # works too
say for Graphics::Toolkit::Color::Name::name_from_hsl( 0, 100, 50 ); # 'red', 'red1'
names_in_hsl_range
Color names in selected neighbourhood of hsl color space, that look similar. It requires two arguments.
The first one is an array containing three values (hue, saturation and lightness), that define the center
of the neighbourhood (searched area).
The second argument can either be a number or again an array with three values (h,s and l). If its just a
number, it will be the radius r of a ball, that defines the neighbourhood. From all colors inside that
ball, that are equal distanced or nearer to the center than r, one name will returned.
If the second argument is an array, it has to contain the tolerance (allowed distance) in h, s and l
direction. Please note the h dimension is circular: the distance from 355 to 0 is 5. The s and l
dimensions are linear, so that a center value of 90 and a tolerance of 15 will result in a search of in
the range 75 .. 100.
The results contains only one name per color (the shortest).
# all bright red'ish clors
my @names = Graphics::Toolkit::Color::Name::names_in_hsl_range([0, 90, 50], 5);
# approximates to :
my @names = Graphics::Toolkit::Color::Name::names_in_hsl_range([0, 90, 50],[ 3, 3, 3]);
all
A sorted list of all stored color names.
taken
A perlish pseudo boolean tells if the color name (first and only, required argument) is already in use.
add_rgb
Adding a color to the store under an not taken (not already used) name. Arguments are name, red, green
and blue value (integer < 256, see rgb).
Graphics::Toolkit::Color::Name::add_rgb('nightblue', 15, 10, 121 );
Graphics::Toolkit::Color::Name::add_rgb('nightblue', [15, 10, 121]);
add_hsl
Adding a color to the store under an not taken (not already used) name. Arguments are name, hue,
saturation and lightness value (see hsl).
Graphics::Toolkit::Color::Name::add_rgb('lucky', 0, 100, 50 );
Graphics::Toolkit::Color::Name::add_rgb('lucky', [0, 100, 50]);