animation/draw.sh

69 lines
1.3 KiB
Bash

#!/bin/bash
###########################
#
# Draws all svgs in a sequence. Starts with a
# fieldguide unless beginning the sequence not
# on the first frame, provided as the second argument.
#
###########################
askContinue () {
echo "Are you ready to continue? (yes/no)"
read input
if [ "$input" != "n" ] && [ "$input" != "no" ]
then
echo "${1}"
else
exit 1
fi
}
if [[ "${1}" == "" ]]; then
echo "Please provide a directory as the first argument"
exit 1
fi
if [ "${2}" == "" ]; then
name=`basename "${1}"`
bash field.sh "${name}"
askContinue "Starting with first frame..."
else
c=0
for svg in "${1}"*.svg ; do
if [ "${c}" != "${2}" ]; then
let "c=c+1"
continue
fi
filename=`basename "${svg}"`
echo "Starting frame: ${filename}"
break
done
askContinue "Continuing with frame ${filename}..."
fi
i=0
#files in dir
for svg in "${1}"*.svg ; do
if [ "${2}" != "" ] && [ "${i}" != "${2}" ]; then
let "i=i+1"
continue
fi
filename=`basename "${svg}"`
name=`echo "${filename}" | cut -d'.' -f1`
num=`echo "${name}" | awk -F'_' '{print $(NF)}'`
echo "Drawing $svg file..."
bash position.sh set
ax guides/guide_marks.svg
number=`mktemp`.svg
node ./numbers/ -n "${num}" -o "${number}"
ax "${number}"
ax "${svg}"
rm -f "${number}"
bash position.sh reset
askContinue "Continuing with next frame..."
done