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: define palette label in rgb value subroutine
[sheet.git]
/
termcol.plp
diff --git
a/termcol.plp
b/termcol.plp
index ead8cb5d9e812522967a4c45bed4f0d2b46e533b..04b6e6e64533f5cad2adedee7531950fd0fff397 100644
(file)
--- a/
termcol.plp
+++ b/
termcol.plp
@@
-233,7
+233,7
@@
sub coltable_hsv {
my $hmax = 2 * $dim * 3; # each face of the rgb cube
my $vmax = $dim - 1;
my $smax = $dim - 1;
my $hmax = 2 * $dim * 3; # each face of the rgb cube
my $vmax = $dim - 1;
my $smax = $dim - 1;
- $rgbval ||= sub {
int $_[0] * 255 / $vmax
};
+ $rgbval ||= sub {
join('', @_), map { int $_ * 255 / $vmax } @_
};
$greyramp ||= [];
my %greymap; # name => value
$greyramp ||= [];
my %greymap; # name => value
@@
-243,7
+243,6
@@
sub coltable_hsv {
for my $r (0 .. $dim - 1) {
for my $g (0 .. $dim - 1) {
for my $b (0 .. $dim - 1) {
for my $r (0 .. $dim - 1) {
for my $g (0 .. $dim - 1) {
for my $b (0 .. $dim - 1) {
- my $index = $r*$dim*$dim + $g*$dim + $b + $offset;
my @rgb = ($r, $g, $b);
my $h = Shiar_Sheet::Colour->new(@rgb)->hue * $hmax;
my @rgb = ($r, $g, $b);
my $h = Shiar_Sheet::Colour->new(@rgb)->hue * $hmax;
@@
-251,14
+250,15
@@
sub coltable_hsv {
my $s = abs(min(@rgb) - max(@rgb));
if (!$s) {
my $s = abs(min(@rgb) - max(@rgb));
if (!$s) {
- $greymap{$index} = $rgbval->($r);
+ my ($index, $l) = $rgbval->(@rgb);
+ $greymap{$index} = $l;
next;
}
$v = $vmax - $v;
$s = $smax - $s - $v;
next;
}
$v = $vmax - $v;
$s = $smax - $s - $v;
- $colmap[$s][$v][$h] = [
$index, map { $rgbval->($_) } @rgb
];
+ $colmap[$s][$v][$h] = [
$rgbval->(@rgb)
];
}
}
}
}
}
}
@@
-289,7
+289,10
@@
sub coltable_hsv {
print "<h2>88-colour space</h2>\n";
print "<table class=mapped>\n";
print coltable_hsv(4,
print "<h2>88-colour space</h2>\n";
print "<table class=mapped>\n";
print coltable_hsv(4,
- sub {(0, 139, 205, 255)[$_[0]]},
+ sub {
+ $_[2] + 4 * ($_[1] + 4 * $_[0]) + 16,
+ map { (0, 139, 205, 255)[$_] } @_
+ },
[map { ($_ + 2 + ($_>0)) * 255/11 } 0 .. 7],
);
print "</table>\n";
[map { ($_ + 2 + ($_>0)) * 255/11 } 0 .. 7],
);
print "</table>\n";
@@
-299,7
+302,10
@@
if ($ENV{PATH_INFO} =~ /256/) {
print "<h2>256-colour space</h2>\n";
print "<table class=mapped>\n";
print coltable_hsv(6,
print "<h2>256-colour space</h2>\n";
print "<table class=mapped>\n";
print coltable_hsv(6,
- sub { $_[0] && $_[0]*40 + 55 },
+ sub {
+ $_[2] + 6 * ($_[1] + 6 * $_[0]) + 16,
+ map { $_ && $_*40 + 55 } @_
+ },
[ map { $_ * 10 + 8 } 0 .. 23 ],
);
print "</table>\n";
[ map { $_ * 10 + 8 } 0 .. 23 ],
);
print "</table>\n";