NAME
Chart::Color::Value - check, convert and measure color values
SYNOPSIS
my @names = Chart::Color::Value::all_names();
my @rgb = Chart::Color::Value::rgb_from_name('darkblue');
my @hsl = Chart::Color::Value::hsl_from_name('darkblue');
my @hsl2 = Chart::Color::Value::hsl_from_rgb( 5 ,10, 100);
my $d = Chart::Color::Value::distance_hsl( \@hsl, \@hsl2);
Chart::Color::Value::add_rgb('lucky', [0, 100, 50]);
DESCRIPTION
RGB and HSL values of named colors from the X11 and HTML standard and Pantone report. Allows also reverse search, storage and conversion of color values.
This module is supposed to be used by Chart::Color and not directly by the user (for the most part). It converts a stored color name into its values (rgb, hsl or both) and back. One color can have multiple names. Also nearby (similar) colors can be searched. Own colors can be (none permanently) stored for later reference by name. For this a name has to be chosen, that is not already taken. Independently of that can any color be converted from rgb to hsl and back.
ROUTINES
check_rgb
Return error message if RGB value triplet is not valid (in range).
check_hsl
Return error message if HSL value triplet is not valid (in range).
trim_rgb
Change RGB triplet to the nearest valid values.
trim_hsl
Change HSL triplet to the nearest valid values.
hsl_from_rgb
Converting an rgb value triplet into the corresponding hsl
Red, Green and Blue are integer in 0 .. 255. Hue is an integer between 0 .. 359 (hue) and saturation and lightness are 0 .. 100 (percentage). 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.
rgb_from_hsl
Converting an hsl value triplet into the corresponding rgb (see rgb_from_name and hsl_from_name). Please not that back and forth conversion can lead to drifting results due to rounding.
my @rgb = Chart::Color::Value::rgb_from_hsl(0, 90, 50);
my @rgb = Chart::Color::Value::rgb_from_hsl([0, 90, 50]); # works too
# for real (none integer results), any none zero value works as second arg
my @rgb = Chart::Color::Value::rgb_from_hsl([0, 90, 50], 'real');
distance_rgb
Distance in (linear) rgb color space between two coordinates.
my $d = Chart::Color::Value::distance_rgb([1,1,1], [2,2,2]); # approx 1.7
distance_hsl
Distance in (cylindrical) hsl color space between two coordinates.
my $d = Chart::Color::Value::distance_rgb([1,1,1], [356, 3, 2]); # approx 6
COPYRIGHT & LICENSE
Copyright 2022 Herbert Breunung.
This program is free software; you can redistribute it and/or modify it under same terms as Perl itself.
AUTHOR
Herbert Breunung, <lichtkind@cpan.org>