git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
termcol: hsv method in Colour module
[sheet.git]
/
termcol.plp
diff --git
a/termcol.plp
b/termcol.plp
index 267d5a74a7821f4bfd5a54aba6c420a0c2b55589..748625cae0636f5b67ec90a2405fb3b72a4873ae 100644
(file)
--- a/
termcol.plp
+++ b/
termcol.plp
@@
-45,7
+45,7
@@
print
<div class="section">
<:
use 5.010;
<div class="section">
<:
use 5.010;
-use Shiar_Sheet::Colour '1.0
3
';
+use Shiar_Sheet::Colour '1.0
4
';
use List::Util qw( min max );
my $palettes = do 'termcol.inc.pl';
use List::Util qw( min max );
my $palettes = do 'termcol.inc.pl';
@@
-159,9
+159,7
@@
sub coltable_hsv {
for my $b (0 .. $dim - 1) {
my @rgb = ($r, $g, $b);
for my $b (0 .. $dim - 1) {
my @rgb = ($r, $g, $b);
- my $h = Shiar_Sheet::Colour->new(@rgb)->hue * $hmax;
- my $v = max(@rgb);
- my $s = abs(min(@rgb) - max(@rgb));
+ my ($h, $s, $v) = Shiar_Sheet::Colour->new(@rgb)->hsv;
if (!$s) {
if (@greymap) {
if (!$s) {
if (@greymap) {
@@
-169,11
+167,12
@@
sub coltable_hsv {
next;
}
next;
}
- $h =
$hmax
; # greyscale hue
+ $h =
1
; # greyscale hue
$s = 1; # lowest saturation for other hues
$v = $s = $vmax if !$v; # black at full saturation
}
$s = 1; # lowest saturation for other hues
$v = $s = $vmax if !$v; # black at full saturation
}
+ $h *= $hmax;
$v = $vmax - $v;
$s = $smax - $s - $v;
$v = $vmax - $v;
$s = $smax - $s - $v;