summaryrefslogtreecommitdiff
path: root/nekowatchlet/res/makeatlas.sh
blob: 60449aef7f69182ebd1f7cade834a8cdb2ddb3a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

set -e

allfiles=$(echo *.png | sort)
atlasfiles=""
stems=""

for i in $allfiles
do
	echo $i
	if [[ $i =~ ^([a-z]+)[1-9].png ]]
	then
		stem=${BASH_REMATCH[1]}
		output=$stem.png.tmp
		if [[ $atlasfiles != *$output* ]]
		then
			montage $stem?.png -geometry 32x32 $output
			atlasfiles="$atlasfiles $output"
			stems="$stems $stem"
		fi
	fi
done

montage $atlasfiles -geometry 64x32+0+0 -gravity NorthWest -tile 1x atlas.png

rm -f $atlasfiles

echo $stems | tr ' ' '\n' > atlas.txt

exit 0