git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d29916e
)
termcol: unsaturated colours from h/s/v table in greyscale ramp
author
Mischa POSLAWSKY
<perl@shiar.org>
Sat, 31 Oct 2015 20:54:09 +0000
(21:54 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Sat, 31 Oct 2015 21:02:28 +0000
(22:02 +0100)
termcol.plp
patch
|
blob
|
history
diff --git
a/termcol.plp
b/termcol.plp
index 5a4e83eed9b4b285bdfdb2edcdd55f3fad308da0..b5f08b250be523a47c0551acdf258d1bb62fec10 100644
(file)
--- a/
termcol.plp
+++ b/
termcol.plp
@@
-252,7
+252,10
@@
print "</table>\n\n";
<div class="section">
<h2>256-colour space</h2>
<:
<div class="section">
<h2>256-colour space</h2>
<:
-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) {
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 $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;
$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];
}
}
$colmap[$s][$v][$h] = [$index, @rgb];
}
}
@@
-291,9
+292,11
@@
for my $r (0 .. 5) {
print "\n";
print '<table>';
print "\n";
print '<table>';
-for my $row (0, 12) {
- print '<tr>';
- 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 '<tr>' unless $col++ % $colbreak;
+ print colcell($num, ($greymap{$num}) x 3);
}
print "</table>\n";
print "\n";
}
print "</table>\n";
print "\n";