<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) {
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];
}
}
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";