shithub: atlas

ref: 9273e8bdb036058c8deba9c0495f2aab765fd835
dir: /atlasc/

View raw version
#!/bin/rc
rfork e

atlas -o /tmp/atlas.off $* > /tmp/atlas

echo 'static u8int atlas_texture[] = {'
hx /tmp/atlas | awk -F'  ' '{print $2, $3}' | sed 's/ *$/,/g;s/^/	0x/g;s/ /, 0x/g'
echo '};'
echo
echo 'static struct {'
echo '	int x, y, w, h;'
echo '}atlas[] = {'
cat /tmp/atlas.off | while(a=`{read}) { echo '	['`{basename $a(1) | sed 's/\..*//g' | tr '[a-z]' '[A-Z]'}^'] = {'$a(2)^, $a(3)^, $a(4)^, $a(5)^'},' }
echo '};'

echo 'enum {' >[1=2]
cat /tmp/atlas.off | while(a=`{read}) { echo '	'`{basename $a(1) | sed 's/\..*//g' | tr '[a-z]' '[A-Z]'}^',' } >[1=2]
echo '};' >[1=2]

rm -f /tmp/atlas.off /tmp/atlas