#!/bin/bash

source config.sh

DDIR="frames/gamma"
DSTOPT="/dev/shm/gamma-altitude.png"

rm "WS/log.gamma"

DEBUT=$(date +'%s')

for i in $( seq 0 $((NBIMG - 1)) )
do

	dst=$(printf "%s/%05d.png" $DDIR $i)
	tag=$(printf "%03d / %05d" 			\
			$i $(($(date +'%s')-$DEBUT )) )
	echo $dst $tag

	povray -igamma +K$i ${POVOPT} -o${DSTOPT} 2> /dev/null
	
	foo=$(tail -1 WS/log.gamma | awk '{print $3}')
	gamma=$(printf "gamma %5.3f" $foo)
	echo $gamma

	convert   $DSTOPT					\
			-font		Courier-Bold		\
			-fill		$COLTXT_A		\
			-pointsize	32			\
			-annotate +21+25 "${tag}"		\
			-fill		$COLTXT_B		\
			-pointsize	56			\
			-annotate +18+115  "${gamma}"		\
			$dst

	sleep  5

done

echo "Encoding now..." ; echo
exec ./encode.sh   "$DDIR"   "gamma-hf.mp4"

