#!/bin/bash

DDIR="frames/TMP"
TMPI="/dev/shm/essai-go.png"

source ./configuration.sh

> WS/essai.log

rm frames/TMP/*.png

log_event "start essai"

for pass in $(seq 0 599)
do
	image=$(printf "%s/ES%03d.png" $DDIR $pass)
	txt=$(printf "%04d" $pass | tr '01' 'ol')

	rm essai.png
	make    KESSAI=$pass   essai.png 

	normclock=$(  tail -1 WS/essai.log  | awk '{ print $2 }'  )
	anglecam=$(   tail -1 WS/essai.log  | awk '{ print $3 }'  )
	distance=$(   tail -1 WS/essai.log  | awk '{ print $4 }'  )

	txtnc=$(printf "normclock %7.3f"  $normclock)
	txtan=$(printf "anglecam  %7.3f"  $anglecam)
	txtdi=$(printf "distance  %7.3f"   $distance)

	convert essai.png 			\
		-font Courier-Bold		\
		-pointsize 32			\
		-fill $COLTEXT_A		\
		-annotate +24+37 "$txt"		\
		-fill $COLTEXT_B		\
		-annotate +26+39 "$txt"		\
		-gravity north-east		\
		-fill Gray80			\
		-pointsize 16			\
		-annotate +30+30 "$txtnc"	\
		-annotate +30+50 "$txtan"	\
		-annotate +30+70 "$txtdi"	\
		$image

	sleep 48

done

# log_event "encoding essai..."

encodage $DDIR/'ES%03d.png' essai.mp4

log_event "essai [done]"


