| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
|
| 5 |
if ($ARGV[0] eq "" || $ARGV[0] =~ /^--?[hH](elp)?$/) { |
| 6 |
die ("USAGE: perl mergeface.pl x y name number\n\n" |
| 7 |
."x and y are the number of tiles in x and y direction\n" |
| 8 |
."name is the part before the .base.xyz.png\n" |
| 9 |
."number is the yz of the .xyz.png\n") |
| 10 |
} |
| 11 |
|
| 12 |
my ($x, $y, $name, $nr) = @ARGV; |
| 13 |
my $xsize = $x * 32; |
| 14 |
my $ysize = $y * 32; |
| 15 |
|
| 16 |
my @chars; |
| 17 |
my @tuples; |
| 18 |
|
| 19 |
my $c = 1; |
| 20 |
for (my $i = 0; $i < $y; $i++) { |
| 21 |
for (my $j = 0; $j < $x; $j++) { |
| 22 |
push @chars, $c < 10 ? $c++ : chr $c++ + 55; |
| 23 |
push @tuples, "$j,$i"; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
#print join "\n", @chars; |
| 28 |
#print join "\n", @tuples; |
| 29 |
|
| 30 |
$x *= 32; |
| 31 |
$y *= 32; |
| 32 |
my $cmd = "convert -size $x\170$y xc:none "; |
| 33 |
|
| 34 |
$c = 0; |
| 35 |
for my $tuple (@tuples) { |
| 36 |
($x, $y) = split /,/, $tuple; |
| 37 |
$x *= 32; |
| 38 |
$y *= 32; |
| 39 |
$cmd .= "-draw \"image over $x,$y 0,0 \'$name.base.".$chars[$c++]."$nr.png\'\" " |
| 40 |
if $chars[$c]; |
| 41 |
} |
| 42 |
|
| 43 |
$cmd .= "$name.base.x$nr.png\n"; |
| 44 |
|
| 45 |
system($cmd); |