X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/f0d06e6376cc06a0876f83015fc7731e32b081d9..1f3b44e51107dc97ce2bded07b93325e96835744:/termcol.plp
diff --git a/termcol.plp b/termcol.plp
index 1e5e287..16b3dfe 100644
--- a/termcol.plp
+++ b/termcol.plp
@@ -28,10 +28,11 @@ print
<:
-use Shiar_Sheet::Colour '1.01';
+use Shiar_Sheet::Colour '1.02';
+use List::Util qw( min max );
sub colcell {
- my $name = shift;
+ my $name = shift or return "
\n";
my $col = Shiar_Sheet::Colour->new(@_);
my $minhex = $col->rgb24;
my $css = '#' . $col->rgb48;
@@ -251,15 +252,40 @@ print "\n\n";
256-colour space
<:
+my @colmap; # saturation => value => hue => colcell
for my $r (0 .. 5) {
- print ' ';
for my $g (0 .. 5) {
- print '';
for my $b (0 .. 5) {
my $index = $r*6*6 + $g*6 + $b + 16;
- print colcell($index, map { $_ && $_*40 + 55 } $r, $g, $b);
+ my @rgb = map { $_ && $_*40 + 55 } $r, $g, $b;
+
+ my $h = Shiar_Sheet::Colour->new(@rgb)->hue * 35;
+ my $v = int(max(@rgb) / 255 * 5);
+ my $s = abs(min(@rgb) - max(@rgb)) / 255 * 7;
+ my $grey = !$s;
+
+ $h-- for grep {$h >= $_} 4, 6, 16, 19, 28, 31;
+ $v = 5 - $v;
+ $s = 7 - $s - $v;
+ $s-- if $s;
+
+ if ($grey) {
+ $h = 30; # greyscale hue
+ $s -= 2; # lowest saturation for other hues
+ $v = $s = 0 if $s < 0; # black at full saturation
+ }
+
+ $colmap[$s][$v][$h] = [$index, @rgb];
}
}
+}
+
+{
+ print '';
+ for my $h (0 .. 30) {
+ print '';
+ print colcell(@$_) for map { $_->[$h] } map { @{$_} } @colmap;
+ }
print " \n";
}
print "\n";
|