shithub: atlas

ref: 174e947152b19130e4c0d54c96e3b04654adbe41
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