#!/usr/bin/env perl use strict; if ($ARGV[0] eq "" || $ARGV[0] =~ /^--?[hH](elp)?$/) { die ("USAGE: perl mergeface.pl x y name number\n\n" ."x and y are the number of tiles in x and y direction\n" ."name is the part before the .base.xyz.png\n" ."number is the yz of the .xyz.png\n") } my ($x, $y, $name, $nr) = @ARGV; my $xsize = $x * 32; my $ysize = $y * 32; my @chars; my @tuples; my $c = 1; for (my $i = 0; $i < $y; $i++) { for (my $j = 0; $j < $x; $j++) { push @chars, $c < 10 ? $c++ : chr $c++ + 55; push @tuples, "$j,$i"; } } #print join "\n", @chars; #print join "\n", @tuples; $x *= 32; $y *= 32; my $cmd = "convert -size $x\170$y xc:none "; $c = 0; for my $tuple (@tuples) { ($x, $y) = split /,/, $tuple; $x *= 32; $y *= 32; $cmd .= "-draw \"image over $x,$y 0,0 \'$name.base.".$chars[$c++]."$nr.png\'\" " if $chars[$c]; } $cmd .= "$name.base.x$nr.png\n"; system($cmd);