From: Mischa POSLAWSKY Date: Sun, 20 Dec 2015 23:51:02 +0000 (+0100) Subject: termcol: distinct image palette in cga order X-Git-Tag: v1.9~56 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/40affe00ed4dbe9612e6c53c35444b7ecae7b079 termcol: distinct image palette in cga order Correct image palette regardless of reorder option. --- diff --git a/termcol.plp b/termcol.plp index 6cc6fea..b3bb7b5 100644 --- a/termcol.plp +++ b/termcol.plp @@ -127,13 +127,11 @@ for my $term (@termlist) { print "\n\n"; } - if (my $colours = $info->{list}) { - if (my $reorder = $info->{ansiorder} and $get{v}) { - $colours = [ map { $colours->[$_] =~ s/:|$/:$_/r } @{$reorder} ]; - } + if (my $palette = $info->{list}) { + my $colours = colorder($palette, $get{v} && $info->{ansiorder}); my $rows = 8; - my $columns = ceil(@{$colours} / $rows); + my $columns = ceil(@{$palette} / $rows); print '', "\n"; printf "\n", $caption; @@ -149,11 +147,21 @@ for my $term (@termlist) { } } - print "
%s
", img_egapal(\@{$colours}, @{$_}) for @draw; + for (@draw) { + my $imgpal = colorder($palette, $info->{ansiorder}); + print "
", img_egapal($imgpal, @{$_}); + } print "
\n\n"; } } +sub colorder { + my ($palette, $reorder) = @_; + return [ map { $palette->[$_] =~ s/:|$/:$_/r } @{$reorder} ]; + if $reorder; + return $palette; +} + sub coltable_hsv { my ($dim, $rgbval, $greyramp) = @_;