From: Mischa POSLAWSKY Date: Sat, 31 Oct 2015 20:54:09 +0000 (+0100) Subject: termcol: unsaturated colours from h/s/v table in greyscale ramp X-Git-Tag: v1.9~97 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/998b07a3af8a02fce9a73544b848c40ce7fdb197?hp=d29916edd5f2af73164483662b5e49fdc6e3e697 termcol: unsaturated colours from h/s/v table in greyscale ramp --- diff --git a/termcol.plp b/termcol.plp index 5a4e83e..b5f08b2 100644 --- a/termcol.plp +++ b/termcol.plp @@ -252,7 +252,10 @@ print "\n\n";

256-colour space

<: -my @colmap; # saturation => value => hue => colcell +my @colmap; # saturation => value => hue => [name, r,g,b] +my %greymap; # name => value +$greymap{232 + $_} = $_*10 + 8 for 0 .. 23; + for my $r (0 .. 5) { for my $g (0 .. 5) { for my $b (0 .. 5) { @@ -262,18 +265,16 @@ for my $r (0 .. 5) { my $h = Shiar_Sheet::Colour->new(@rgb)->hue * 33; my $v = int(max(@rgb) / 255 * 5); my $s = abs(min(@rgb) - max(@rgb)) / 255 * 7; - my $grey = !$s; + + if (!$s) { + $greymap{$index} = $rgb[0]; + next; + } $v = 5 - $v; $s = 7 - $s - $v; $s-- if $s; - if ($grey) { - $h = 33; # 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]; } } @@ -291,9 +292,11 @@ for my $r (0 .. 5) { print "\n"; print ''; -for my $row (0, 12) { - print ''; - print colcell(232+$_, ($_*10 + 8) x 3) for $row .. $row+11; +my $col = 0; +my $colbreak = keys(%greymap) / 2; # split into 2 rows +for my $num (sort { $greymap{$a} <=> $greymap{$b} } keys %greymap) { + print '' unless $col++ % $colbreak; + print colcell($num, ($greymap{$num}) x 3); } print "
\n"; print "\n";