table of contents
- bookworm 1.08-1
Graphics::Toolkit::Color::Value(3pm) | User Contributed Perl Documentation | Graphics::Toolkit::Color::Value(3pm) |
NAME¶
Graphics::Toolkit::Color::Value - check, convert and measure color values
SYNOPSIS¶
use Graphics::Toolkit::Color::Value; # import nothing use Graphics::Toolkit::Color::Value ':all'; # import all routines check_rgb( 256, 10, 12 ); # throws error 255 is the limit my @hsl = hsl_from_rgb( 20, 50, 70 ); # convert from RGB to HSL space
DESCRIPTION¶
A set of helper routines to handle RGB and HSL values: bound checks, conversion, measurement. Most subs expect three numerical values, or sometimes two triplet. This module is supposed to be used by Graphics::Toolkit::Color and not directly.
ROUTINES¶
check_rgb¶
Carp error message if RGB value triplet is not valid (or out of value range).
check_hsl¶
Carp error message if HSL value triplet is not valid (or out of value 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 = rgb_from_hsl( 0, 90, 50 ); my @rgb = rgb_from_hsl( [0, 90, 50] ); # works too # for real (none integer results), any none zero value works as second arg my @rgb = rgb_from_hsl( [0, 90, 50], 'real');
hex_from_rgb¶
Converts a red green blue triplet into format: '#RRGGBB'.
rgb_from_hex¶
Converts '#RRGGBB' or '#RGB' hex values into regular RGB triple of 0..255.
distance_rgb¶
Distance in (linear) rgb color space between two coordinates.
my $d = distance_rgb([1,1,1], [2,2,2]); # approx 1.7
distance_hsl¶
Distance in (cylindrical) hsl color space between two coordinates.
my $d = 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>
2023-01-30 | perl v5.36.0 |