animation/draw.sh

72 lines
1.5 KiB
Bash
Raw Normal View History

2021-08-07 16:14:59 +00:00
#!/bin/bash
2021-09-16 14:42:59 +00:00
###########################
#
# Draws all svgs in a sequence. Starts with a
# fieldguide unless beginning the sequence not
# on the first frame, provided as the second argument.
#
###########################
2021-09-16 15:05:07 +00:00
source ./common.sh
2021-09-09 00:53:03 +00:00
if [[ "${1}" == "" ]]; then
echo "Please provide a directory as the first argument"
exit 1
fi
2021-08-07 16:14:59 +00:00
2021-11-29 16:43:08 +00:00
FRAMES=$(realpath "${1}")/
2021-11-29 16:41:57 +00:00
2021-11-29 03:00:10 +00:00
END=-1
if [[ "${3}" != "" ]]; then
END=${3}
fi
2021-11-29 03:18:09 +00:00
if [[ "${2}" == "" ]] || [[ $2 -eq 0 ]]; then
2021-11-29 16:30:51 +00:00
echo "Drawing focus field..."
name=`basename "${1}"`
2021-09-16 14:42:59 +00:00
bash field.sh "${name}"
2021-11-29 16:30:51 +00:00
askContinue "Start with first frame?" "Starting with first frame..."
else
c=0
2021-11-29 16:41:57 +00:00
for svg in "${FRAMES}"*.svg ; do
2021-11-29 16:35:13 +00:00
if [[ ${c} -lt ${2} ]]; then
2021-11-29 16:38:24 +00:00
c=$((c+1))
continue
fi
filename=`basename "${svg}"`
break
done
2021-11-29 16:30:51 +00:00
askContinue "Start with ${filename}" "Continuing with frame ${filename}..."
fi
2021-08-07 16:14:59 +00:00
i=0
2021-08-07 16:14:59 +00:00
#files in dir
2021-11-29 16:41:57 +00:00
for svg in "${FRAMES}"*.svg ; do
2021-11-29 16:38:24 +00:00
if [[ "${2}" != "" ]] && [[ ${2} -ne 0 ]] && [[ ${i} -lt ${2} ]]; then
i=$((i+1))
continue
fi
2021-08-07 16:14:59 +00:00
filename=`basename "${svg}"`
name=`echo "${filename}" | cut -d'.' -f1`
num=`echo "${name}" | awk -F'_' '{print $(NF)}'`
echo "Drawing $svg file..."
2021-08-10 22:07:06 +00:00
bash position.sh set
ax guides/guide_marks.svg
2021-08-07 16:14:59 +00:00
number=`mktemp`.svg
node ./numbers/ -n "${num}" -o "${number}"
ax "${number}"
2021-08-10 22:55:13 +00:00
ax "${svg}"
2021-08-07 16:14:59 +00:00
rm -f "${number}"
2021-08-10 22:07:06 +00:00
bash position.sh reset
2021-11-29 03:00:10 +00:00
if [[ $END -gt -1 ]] && [[ $END -eq $i ]]; then
echo "Reached final frame $i, exiting..."
exit
fi
2021-11-29 16:30:51 +00:00
askContinue "Finished frame ${filename}" "Continuing with next frame..."
2021-08-07 16:14:59 +00:00
done