X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/9c63114c622c6ef782de884c5788ef2bdd27c4db..f0cd021d19083c1a3b5e88523148579231c7e26b:/termcol.plp diff --git a/termcol.plp b/termcol.plp index 7a51fbd..267d5a7 100644 --- a/termcol.plp +++ b/termcol.plp @@ -21,7 +21,7 @@ push @termlist, split /\W+/, $ENV{PATH_INFO} || 'default'; my %termgroup = ( default => [qw( ansi xkcd ansi88 )], - more => [qw( ansi legacy ansi256 )], + more => [qw( ansi mirc legacy ansi256 )], msx => [qw( msx1 msx2 arnejmp )], ansi => [qw( cga xterm tango app html )], legacy => [qw( c64 msx2 mac2 risc arnegame cpc )], @@ -151,9 +151,8 @@ sub coltable_hsv { my $smax = $dim - 1; $rgbval ||= sub { join('', @_), map { int $_ * 255 / $vmax } @_ }; - my %greymap; # name => value + my @greymap = @{$greyramp || []}; # [name, r, g=l, b] my @colmap; # saturation => value => hue => [name, r,g,b] - my $offset = 16 * ($dim > 3); for my $r (0 .. $dim - 1) { for my $g (0 .. $dim - 1) { @@ -165,9 +164,8 @@ sub coltable_hsv { my $s = abs(min(@rgb) - max(@rgb)); if (!$s) { - if ($greyramp) { - my ($index, $l) = $rgbval->(@rgb); - $greymap{$index} = $l; + if (@greymap) { + push @greymap, [ $rgbval->(@rgb) ]; next; } @@ -192,23 +190,18 @@ sub coltable_hsv { $out .= colcell(@$_) for map { $_->[$h] } map { @{$_} } @colmap; } - if ($greyramp) { - $offset += $dim ** 3; - $greymap{$offset++} = $_ for @{$greyramp}; - } - - if (%greymap) { + if (@greymap) { $out .= ''; my $col = 0; my $colbreak = scalar map { @$_ } @colmap; # same width as hue rows - for my $num (sort { $greymap{$a} <=> $greymap{$b} } keys %greymap) { + for my $cell (sort { $a->[1] <=> $b->[1] || $a->[0] <=> $b->[0] } @greymap) { $out .= '' unless $col++ % $colbreak; - $out .= colcell($num, ($greymap{$num})); + $out .= colcell(@{$cell}); } } if ($imgfile) { - my @palette = map { [ @{$_}[1 .. 3] ] } map {@$_} map {@$_} @colmap; + my @palette = map { [ @{$_}[1 .. 3] ] } @greymap, map {@$_} map {@$_} @colmap; my $imgdata = img_egapal(\@palette); my $tablespan = scalar map { @$_ } @colmap; $out .= "$imgdata";