1Graphics::Toolkit::ColoUrs:e:rVaClounet(r3i)buted Perl DGorcaupmheinctsa:t:iToonolkit::Color::Value(3)
2
3
4

NAME

6       Graphics::Toolkit::Color::Value - check, convert and measure color
7       values
8

SYNOPSIS

10           use Graphics::Toolkit::Color::Value;         # import nothing
11           use Graphics::Toolkit::Color::Value ':all';  # import all routines
12           use Graphics::Toolkit::Color::Value ':rgb';  # import RGB related routines
13           use Graphics::Toolkit::Color::Value ':hsl';  # import HSL related routines
14
15           check_rgb( 256, 10, 12 ); # throws error 255 is the limit
16           my @hsl = hsl_from_rgb( 20, 50, 70 ); # convert from RGB to HSL space
17

DESCRIPTION

19       A set of helper routines to handle RGB and HSL values: bound checks,
20       conversion, measurement. Most subs expect three numerical values, or
21       sometimes two triplet. This module is supposed to be used by
22       Graphics::Toolkit::Color and not directly.
23

ROUTINES

25   check_rgb
26       Carp error message if RGB value triplet is not valid (or out of value
27       range).
28
29   check_hsl
30       Carp error message if HSL value triplet is not valid (or out of value
31       range).
32
33   trim_rgb
34       Change RGB triplet to the nearest valid values.
35
36   trim_hsl
37       Change HSL triplet to the nearest valid values.
38
39   hsl_from_rgb
40       Converting an rgb value triplet into the corresponding hsl
41
42       Red, Green and Blue are integer in 0 .. 255.  Hue is an integer between
43       0 .. 359 (hue) and saturation and lightness are 0 .. 100 (percentage).
44       A hue of 360 and 0 (degree in a cylindrical coordinate system) is
45       considered to be the same, this modul deals only with the ladder.
46
47   rgb_from_hsl
48       Converting an hsl value triplet into the corresponding rgb (see
49       rgb_from_name and hsl_from_name). Please not that back and forth
50       conversion can lead to drifting results due to rounding.
51
52           my @rgb = rgb_from_hsl( 0, 90, 50 );
53           my @rgb = rgb_from_hsl( [0, 90, 50] ); # works too
54           # for real (none integer results), any none zero value works as second arg
55           my @rgb = rgb_from_hsl( [0, 90, 50], 'real');
56
57   hex_from_rgb
58       Converts a red green blue triplet into format: '#rrggbb' (lower case
59       hex digits).
60
61   rgb_from_hex
62       Converts '#rrggbb' or '#rgb' (CSS short format) hex values into regular
63       RGB triple of 0..255 integer.
64
65   distance_rgb
66       Distance (real) in (linear) rgb color space between two coordinates.
67
68           my $d = distance_rgb([1,1,1], [2,2,2]);  # approx 1.7
69
70   distance_hsl
71       Distance (real) in (cylindrical) hsl color space between two
72       coordinates.
73
74           my $d = distance_rgb([1,1,1], [356, 3, 2]); # approx 6
75

SEE ALSO

77       •   Color::Library
78
80       Copyright 2022-23 Herbert Breunung.
81
82       This program is free software; you can redistribute it and/or modify it
83       under same terms as Perl itself.
84

AUTHOR

86       Herbert Breunung, <lichtkind@cpan.org>
87
88
89
90perl v5.38.0                      2023-07-24Graphics::Toolkit::Color::Value(3)
Impressum