X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/032b7eb4897d7517e94c7fe2e1d414be8d925c9f..a8d6bfee7b0542db16ff7da26d06760e95fa4d14:/termcol.plp?ds=sidebyside
diff --git a/termcol.plp b/termcol.plp
index 9262bf3..ead8cb5 100644
--- a/termcol.plp
+++ b/termcol.plp
@@ -233,6 +233,8 @@ sub coltable_hsv {
my $hmax = 2 * $dim * 3; # each face of the rgb cube
my $vmax = $dim - 1;
my $smax = $dim - 1;
+ $rgbval ||= sub { int $_[0] * 255 / $vmax };
+ $greyramp ||= [];
my %greymap; # name => value
my @colmap; # saturation => value => hue => [name, r,g,b]
@@ -261,7 +263,7 @@ sub coltable_hsv {
}
}
- my $out = '
';
+ my $out = '';
$out .= sprintf '', 3 * @{$_} for @colmap;
my $huerow = $colmap[0][0]; # first {$_} map { @{$_} } @colmap;
for my $h (grep { $huerow->[$_] } 0 .. $#{$huerow}) {
@@ -279,25 +281,28 @@ sub coltable_hsv {
$out .= '' unless $col++ % $colbreak;
$out .= colcell($num, ($greymap{$num}) x 3);
}
- $out .= "
\n\n";
return $out;
}
{
print "88-colour space
\n";
+ print "\n";
print coltable_hsv(4,
sub {(0, 139, 205, 255)[$_[0]]},
[map { ($_ + 2 + ($_>0)) * 255/11 } 0 .. 7],
);
+ print "
\n";
}
if ($ENV{PATH_INFO} =~ /256/) {
print "256-colour space
\n";
+ print "\n";
print coltable_hsv(6,
sub { $_[0] && $_[0]*40 + 55 },
[ map { $_ * 10 + 8 } 0 .. 23 ],
);
+ print "
\n";
}
:>