stylesheet => [qw'light dark'],
});
-my $imgfile = $get{img} // exists $get{img} && 'indi.png';
+my @draw = map { [$_, s/\W+\z//] } grep { $_ } split m(/),
+ $get{img} // exists $get{img} && 'indi.png';
my @termlist;
push @termlist, split /\W+/, $ENV{PATH_INFO} || 'default';
}
sub img_egapal {
- my ($palette) = @_;
+ my ($palette, $imgfile, $reindex) = @_;
return eval {
require Imager;
require MIME::Base64;
my @imgpal = map { Imager::Color->new(ref $_ ? @$_ : $_) } @{$palette};
- state $reindex = $imgfile =~ s/!$//;
- state $img = Imager->new(file => "data/palimage/$imgfile")
+ state $imgcache = {};
+ my $img = $imgcache->{$imgfile}
+ //= Imager->new(file => "data/palimage/$imgfile")
or die Imager->errstr.$/;
+
do {
if ($reindex) {
$img->to_paletted({
print '<tr>', colcell($name, $rgb);
}
- print '<tr><td>', img_egapal(\@{$colours}) if $imgfile;
+ print '<tr><td>', img_egapal(\@{$colours}, @{$_}) for @draw;
print "</table>\n\n";
}
}
}
}
- if ($imgfile) {
+ if (@draw) {
my @palette = map { [ @{$_}[1 .. 3] ] } @greymap, map {@$_} map {@$_} @colmap;
- my $imgdata = img_egapal(\@palette);
my $tablespan = scalar map { @$_ } @colmap;
+ my $imgdata = img_egapal(\@palette, @{ $draw[0] });
$out .= "<tr><td colspan=$tablespan>$imgdata";
}