You can perform such conversions using the Imager::Color module. eg.
#!/usr/bin/perl
use Imager::Color;
use strict;
# define HSV colour option within the object initiation
#
my $hsv = Imager::Color->new(
hsv => [ 120, 0.5, 1 ] # hue, v, s
);
my @rgb = $hsv->rgba;
Update
Alternatively, if you want to roll your own conversion tool, the following code could be used, based on the converstion algorithm documentation at http://www.cs.rit.edu/~ncs/color/t_convert.html. eg.
#!/usr/bin/perl
use POSIX;
use strict;
sub hsv2rgb {
my ( $h, $s, $v ) = @_;
if ( $s == 0 ) {
return $v, $v, $v;
}
$h /= 60;
my $i = floor( $h );
my $f = $h - $i;
my $p = $v * ( 1 - $s );
my $q = $v * ( 1 - $s * $f );
my $t = $v * ( 1 - $s * ( 1 - $f ) );
if ( $i == 0 ) {
return $v, $t, $p;
}
elsif ( $i == 1 ) {
return $q, $v, $t;
}
elsif ( $i == 2 ) {
return $p, $v, $t;
}
elsif ( $i == 3 ) {
return $p, $q, $v;
}
elsif ( $i == 4 ) {
return $t, $p, $v;
}
else {
return $v, $p, $q;
}
}
perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print' | [reply] [d/l] [select] |
Thanks mate,
Should solve my problem
| [reply] |
case 1 is wrong! should be:
elsif ( $i == 1 ) {
return $q, $v, $p;
| [reply] |