NAME
App::Wubot::Util::AgeColor - define colors based on the age of items
VERSION
version 0.5.0
SYNOPSIS
use App::Wubot::Util::AgeColor;
# the 'colormap' defines the colors for specific ages in seconds
my $colormap = { 0 => '6c003f',
60*60*24 => '440066',
60*60*24*7 => '002b66',
60*60*24*30 => '004a00',
60*60*24*365 => '804c00',
};
my $colorer = App::Wubot::Util::AgeColor->new( { colormap => $colormap } );
# get the age color for something that just happened right now, 6c003f
print $colorer->get_age_color( 0 ), "\n";
# get the age color for 1 day old, #440066
print $colorer->get_age_color( 60*60*24 ), "\n";
# get the age color for 12 hours old, #580052
print $colorer->get_age_color( 60*60*12 ), "\n";
# get a smooth gradient of colors between 6c003f and 440066
for my $hours ( 0 .. 24 ) {
print $colorer->get_age_color( $hours * 3600 ), "\n";
}
DESCRIPTION
This library is used to colorize an item or field based on its age in seconds. This helps to very quickly assess the age of an item in the web interface by looking at the color.
A steady stream of items with evenly spaced ages will create a smooth gradient of color.