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 (from parent 1:
a6bdc11
)
termcol: greyscales in hue row if no grey ramp specified
author
Mischa POSLAWSKY
<perl@shiar.org>
Sun, 1 Nov 2015 20:04:17 +0000
(21:04 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Tue, 5 Jan 2016 00:05:07 +0000
(
01:05
+0100)
termcol.plp
patch
|
blob
|
history
diff --git
a/termcol.plp
b/termcol.plp
index e544bf700262ceb10e263a0d11f5d52be024f9f6..0c5d3e4d27819484ea19e4c54a047b2939bfea43 100644
(file)
--- a/
termcol.plp
+++ b/
termcol.plp
@@
-114,7
+114,6
@@
sub coltable_hsv {
my $vmax = $dim - 1;
my $smax = $dim - 1;
$rgbval ||= sub { join('', @_), map { int $_ * 255 / $vmax } @_ };
my $vmax = $dim - 1;
my $smax = $dim - 1;
$rgbval ||= sub { join('', @_), map { int $_ * 255 / $vmax } @_ };
- $greyramp ||= [];
my %greymap; # name => value
my @colmap; # saturation => value => hue => [name, r,g,b]
my %greymap; # name => value
my @colmap; # saturation => value => hue => [name, r,g,b]
@@
-130,9
+129,15
@@
sub coltable_hsv {
my $s = abs(min(@rgb) - max(@rgb));
if (!$s) {
my $s = abs(min(@rgb) - max(@rgb));
if (!$s) {
- my ($index, $l) = $rgbval->(@rgb);
- $greymap{$index} = $l;
- next;
+ if ($greyramp) {
+ my ($index, $l) = $rgbval->(@rgb);
+ $greymap{$index} = $l;
+ next;
+ }
+
+ $h = $hmax; # greyscale hue
+ $s = 1; # lowest saturation for other hues
+ $v = $s = $vmax if !$v; # black at full saturation
}
$v = $vmax - $v;
}
$v = $vmax - $v;
@@
-151,15
+156,19
@@
sub coltable_hsv {
$out .= colcell(@$_) for map { $_->[$h] } map { @{$_} } @colmap;
}
$out .= colcell(@$_) for map { $_->[$h] } map { @{$_} } @colmap;
}
- $offset += $dim ** 3;
- $greymap{$offset++} = $_ for @{$greyramp};
+ if ($greyramp) {
+ $offset += $dim ** 3;
+ $greymap{$offset++} = $_ for @{$greyramp};
+ }
- $out .= '<tbody>';
- my $col = 0;
- my $colbreak = scalar map { @$_ } @colmap; # same width as hue rows
- for my $num (sort { $greymap{$a} <=> $greymap{$b} } keys %greymap) {
- $out .= '<tr>' unless $col++ % $colbreak;
- $out .= colcell($num, ($greymap{$num}) x 3);
+ if (%greymap) {
+ $out .= '<tbody>';
+ my $col = 0;
+ my $colbreak = scalar map { @$_ } @colmap; # same width as hue rows
+ for my $num (sort { $greymap{$a} <=> $greymap{$b} } keys %greymap) {
+ $out .= '<tr>' unless $col++ % $colbreak;
+ $out .= colcell($num, ($greymap{$num}) x 3);
+ }
}
return $out;
}
return $out;