#!/bin/sh

# remove gif data, if any
echo clearing animation directory contents
find anim/ -name *.gif -type f \
	| xargs rm -f

# create frames
echo creating frames
ls -1 data/ \
	| sort -n \
	| awk '{print "data/"$1}' \
	| xargs cat \
	| ../scripts/anim.pl

# create animated gif
echo creating animated gif
ls -1 anim/ \
	| grep frame.*\.gif \
	| sort -n \
	| awk '{print "anim/"$1}' \
	| xargs cat \
	| gifsicle --loop --delay 4 -O2 --multifile - > anim/anim.gif

# change duration of first/last frame
#echo modifying frame duration
#gifsicle -b anim/anim.gif -d100 '#0' '#-1'

mv -f anim/anim.gif anim.gif
