#!/bin/bash

# creating the pics

counter=0
for commit in `git rev-list --reverse HEAD`;
do
        counter=$(($counter + 1))

        git log -1 $commit

        git checkout $commit

        rm -f ../naplouzenetek.pdf
        lyx -e pdf ../naplouzenetek.lyx

        convert -density 30 ../naplouzenetek.pdf ./naplouzenetek.png

        # getting the filenames for the images
        num_of_pngs=$((`ls naplouzenet*png | wc -l` - 1))

        #uglyhack, dontcare
        for i in `seq 0 $num_of_pngs`;
        do
                echo -n naplouzenetek-$i.png >> .naplotmp
                echo -n " " >> .naplotmp
        done

        files=`cat .naplotmp`
        rm .naplotmp

        montage -monitor -background "#000000" -density 600 -tile $1 $files pics/$counter.jpg  

        rm naplouzenetek*.png
done

git checkout master

# creating the animgif
# getting the filenames for the images
num_of_pngs=`ls pics/*jpg | wc -l`

#uglyhack, dontcare
for i in `seq 1 $num_of_pngs`;
do
        echo -n pics/$i.jpg >> .naplotmp
        echo -n " " >> .naplotmp
done

files=`cat .naplotmp`
rm .naplotmp

convert -delay 30 -loop 0 $files pics/anim.gif  




