Provided by: libsharyanto-utils-perl_0.53-1_all
NAME
SHARYANTO::Color::Util - Color-related utilities
VERSION
version 0.53
SYNOPSIS
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
DESCRIPTION
FUNCTIONS
None are exported by default, but they are exportable. mix_2_rgb_colors($rgb1, $rgb2, $pct) => STR 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. rand_rgb_color([$low_limit[, $high_limit]]) => STR Generate a random RGB color. You can specify the limit. Otherwise, they default to the full range (000000 to ffffff). rgb2grayscale($rgb) => RGB Convert $rgb to grayscale RGB value. rgb2sepia($rgb) => RGB Convert $rgb to sepia tone RGB value. reverse_rgb_color($rgb) => RGB Reverse $rgb. rgb_luminance($rgb) => NUM 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_color($rgb, $tint_rgb, $pct) => RGB 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. None are exported by default, but they are exportable.
TODO
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).
AUTHOR
Steven Haryanto <stevenharyanto@gmail.com>
COPYRIGHT AND LICENSE
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.