SHARYANTO::Color::Util - Color-related utilities
version 0.56
use SHARYANTO::Color::Util qw( mix_2_rgb_colors rand_rgb_color rgb2grayscale rgb2sepia reverse_rgb_color rgb_luminance ); say mix_2_rgb_colors('#ff0000', '#ffffff'); # pink (red + white) say mix_2_rgb_colors('ff0000', 'ffffff', 0.75); # pink with a whiter shade say rand_rgb_color(); say rand_rgb_color('000000', '333333'); # limit range say rgb2grayscale('0033CC'); # => 555555 say rgb2sepia('0033CC'); # => 4d4535 say reverse_rgb_color('0033CC'); # => ffcc33 say rgb_luminance('d090aa'); # => ffcc33
None are exported by default, but they are exportable.
Mix 2 RGB colors. $pct is a number between 0 and 1, by default 0.5 (halfway), the closer to 1 the closer the resulting color to $rgb2.
$pct
$rgb2
Generate a random RGB color. You can specify the limit. Otherwise, they default to the full range (000000 to ffffff).
Convert $rgb to grayscale RGB value.
$rgb
Convert $rgb to sepia tone RGB value.
Reverse $rgb.
Calculate standard/objective luminance from RGB value using this formula:
(0.2126*R) + (0.7152*G) + (0.0722*B)
where R, G, and B range from 0 to 1. Return a number from 0 to 1.
Tint $rgb with $tint_rgb. $pct is by default 0.5. It is similar to mixing, but the less luminance the color is the less it is tinted with the tint color. This has the effect of black color still being black instead of becoming tinted.
$tint_rgb
mix_rgb_colors() to mix several RGB colors. Args might be $rgb1, $rgb2, ... or $rgb1, $part1, $rgb2, $part2, ... (e.g. 'ffffff', 1, 'ff0000', 1, '00ff00', 2).
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2013 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install SHARYANTO::Color::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SHARYANTO::Color::Util
CPAN shell
perl -MCPAN -e shell install SHARYANTO::Color::Util
For more information on module installation, please visit the detailed CPAN module installation guide.