#!/opt/bin/perl use strict; no utf8; use Crossfire::Map; use Storable; use POSIX; use File::Compare; my $USAGE = "usage: gen_palette_from_plt \n"; my @type; my $plt_file = $ARGV[0] || die $USAGE; my $out_file = $ARGV[1] || die $USAGE; open my $plt, $plt_file or die "Couldn't open $plt_file: $!\n"; for (<$plt>) { my ($arch, $color) = split /\s+/; push @type, [$arch, "#$color"] if $arch =~ /\S/; } mkdir "/tmp/$$.palette" or die "Couldn't make /tmp/$$.palette"; for (@type) { my ($name, $color) = @$_; $color =~ s/^#//; system ("convert -size 300x30 xc:\\#$color -pointsize 32 -fill \"red\" -gravity east -draw \"text 0,0 \\\"$name\\\"\" /tmp/$$.palette/$color.png"); } system ("convert -append " . join (' ', map { my $c = $_->[1]; $c =~ s/^#//; "/tmp/$$.palette/$c.png" } @type ) . " $out_file" ); system ("rm -r /tmp/$$.palette");