X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/a4fdefae72afac5a4ad02eabcc23fe762903ad89..4df29062a0012a9864d1038557d9f825b7cf509f:/termcol.plp
diff --git a/termcol.plp b/termcol.plp
index fd2bc9b..e34cead 100644
--- a/termcol.plp
+++ b/termcol.plp
@@ -32,7 +32,7 @@ use Shiar_Sheet::Colour '1.03';
use List::Util qw( min max );
sub colcell {
- my $name = shift or return "
\n";
+ my $name = shift // return " | \n";
my $col = Shiar_Sheet::Colour->new(@_);
my $minhex = $col->rgb24;
my $css = '#' . $col->rgb48;
@@ -226,19 +226,6 @@ for my $term (@termlist) {
- 88-colour space
-<:
-print coltable_hsv(4,
- sub {(0, 139, 205, 255)[$_[0]]},
- [map { ($_ + 2 + ($_>0)) * 255/11 } 0 .. 7],
-);
-
-:>
-<: if ($ENV{PATH_INFO} =~ /256/) { :>
-
-
-
- 256-colour space
<:
sub coltable_hsv {
my ($dim, $rgbval, $greyramp) = @_;
@@ -274,35 +261,47 @@ 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}) {
$out .= '';
$out .= colcell(@$_) for map { $_->[$h] } map { @{$_} } @colmap;
}
- $out .= " \n\n";
$offset += $dim ** 3;
$greymap{$offset++} = $_ for @{$greyramp};
- $out .= ' ';
+ $out .= '';
my $col = 0;
- my $colbreak = keys(%greymap) / 2; # split into 2 rows
+ my $colbreak = scalar map { @$_ } @colmap; # same width as hue rows
for my $num (sort { $greymap{$a} <=> $greymap{$b} } keys %greymap) {
$out .= '' unless $col++ % $colbreak;
$out .= colcell($num, ($greymap{$num}) x 3);
}
- $out .= " \n\n";
return $out;
}
-print coltable_hsv(6,
- sub { $_[0] && $_[0]*40 + 55 },
- [ map { $_ * 10 + 8 } 0 .. 23 ],
-);
+{
+ 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";
+}
:>
-<: } :>
|