1Chart::Color::Value(3)User Contributed Perl DocumentationChart::Color::Value(3)
2
3
4

NAME

6       Chart::Color::Value - check, convert and measure color values
7

SYNOPSIS

9           my @names = Chart::Color::Value::all_names();
10           my @rgb  = Chart::Color::Value::rgb_from_name('darkblue');
11           my @hsl  = Chart::Color::Value::hsl_from_name('darkblue');
12           my @hsl2 = Chart::Color::Value::hsl_from_rgb( 5 ,10, 100);
13           my $d = Chart::Color::Value::distance_hsl( \@hsl, \@hsl2);
14
15           Chart::Color::Value::add_rgb('lucky', [0, 100, 50]);
16

DESCRIPTION

18       RGB and HSL values of named colors from the X11 and HTML standard and
19       Pantone report. Allows also reverse search, storage and conversion of
20       color values.
21
22       This module is supposed to be used by Chart::Color and not directly by
23       the user (for the most part). It converts a stored color name into its
24       values (rgb, hsl or both) and back. One color can have multiple names.
25       Also nearby (similar) colors can be searched. Own colors can be (none
26       permanently) stored for later reference by name. For this a name has to
27       be chosen, that is not already taken. Independently of that can any
28       color be converted from rgb to hsl and back.
29

ROUTINES

31   check_rgb
32       Return error message if RGB value triplet is not valid (in range).
33
34   check_hsl
35       Return error message if HSL value triplet is not valid (in range).
36
37   trim_rgb
38       Change RGB triplet to the nearest valid values.
39
40   trim_hsl
41       Change HSL triplet to the nearest valid values.
42
43   hsl_from_rgb
44       Converting an rgb value triplet into the corresponding hsl
45
46       Red, Green and Blue are integer in 0 .. 255.  Hue is an integer between
47       0 .. 359 (hue) and saturation and lightness are 0 .. 100 (percentage).
48       A hue of 360 and 0 (degree in a cylindrical coordinate system) is
49       considered to be the same, this modul deals only with the ladder.
50
51   rgb_from_hsl
52       Converting an hsl value triplet into the corresponding rgb (see
53       rgb_from_name and hsl_from_name). Please not that back and forth
54       conversion can lead to drifting results due to rounding.
55
56           my @rgb = Chart::Color::Value::rgb_from_hsl(0, 90, 50);
57           my @rgb = Chart::Color::Value::rgb_from_hsl([0, 90, 50]); # works too
58           # for real (none integer results), any none zero value works as second arg
59           my @rgb = Chart::Color::Value::rgb_from_hsl([0, 90, 50], 'real');
60
61   distance_rgb
62       Distance in (linear) rgb color space between two coordinates.
63
64           my $d = Chart::Color::Value::distance_rgb([1,1,1], [2,2,2]);  # approx 1.7
65
66   distance_hsl
67       Distance in (cylindrical) hsl color space between two coordinates.
68
69           my $d = Chart::Color::Value::distance_rgb([1,1,1], [356, 3, 2]); # approx 6
70
72       Copyright 2022 Herbert Breunung.
73
74       This program is free software; you can redistribute it and/or modify it
75       under same terms as Perl itself.
76

AUTHOR

78       Herbert Breunung, <lichtkind@cpan.org>
79
80
81
82perl v5.36.0                      2022-08-01            Chart::Color::Value(3)
Impressum