.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Graphics::Toolkit::Color::Value 3pm" .TH Graphics::Toolkit::Color::Value 3pm "2023-01-30" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Graphics::Toolkit::Color::Value \- check, convert and measure color values .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Graphics::Toolkit::Color::Value; # import nothing \& use Graphics::Toolkit::Color::Value \*(Aq:all\*(Aq; # 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 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A set of helper routines to handle \s-1RGB\s0 and \s-1HSL\s0 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. .SH "ROUTINES" .IX Header "ROUTINES" .SS "check_rgb" .IX Subsection "check_rgb" Carp error message if \s-1RGB\s0 value triplet is not valid (or out of value range). .SS "check_hsl" .IX Subsection "check_hsl" Carp error message if \s-1HSL\s0 value triplet is not valid (or out of value range). .SS "trim_rgb" .IX Subsection "trim_rgb" Change \s-1RGB\s0 triplet to the nearest valid values. .SS "trim_hsl" .IX Subsection "trim_hsl" Change \s-1HSL\s0 triplet to the nearest valid values. .SS "hsl_from_rgb" .IX Subsection "hsl_from_rgb" Converting an rgb value triplet into the corresponding hsl .PP 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. .SS "rgb_from_hsl" .IX Subsection "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. .PP .Vb 4 \& 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], \*(Aqreal\*(Aq); .Ve .SS "hex_from_rgb" .IX Subsection "hex_from_rgb" Converts a red green blue triplet into format: '#RRGGBB'. .SS "rgb_from_hex" .IX Subsection "rgb_from_hex" Converts '#RRGGBB' or '#RGB' hex values into regular \s-1RGB\s0 triple of 0..255. .SS "distance_rgb" .IX Subsection "distance_rgb" Distance in (linear) rgb color space between two coordinates. .PP .Vb 1 \& my $d = distance_rgb([1,1,1], [2,2,2]); # approx 1.7 .Ve .SS "distance_hsl" .IX Subsection "distance_hsl" Distance in (cylindrical) hsl color space between two coordinates. .PP .Vb 1 \& my $d = distance_rgb([1,1,1], [356, 3, 2]); # approx 6 .Ve .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2022 Herbert Breunung. .PP This program is free software; you can redistribute it and/or modify it under same terms as Perl itself. .SH "AUTHOR" .IX Header "AUTHOR" Herbert Breunung,