2021-09-16 15:05:07 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-12-08 04:11:13 +00:00
|
|
|
if [ -f ".env" ]; then
|
|
|
|
source .env
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${DB_FILE}" != "" ]]; then
|
|
|
|
FULL_DATABASE=`realpath "${DB_FILE}"`
|
|
|
|
else
|
|
|
|
FULL_DATABASE=`realpath "./draw.sqlite"`
|
|
|
|
fi
|
|
|
|
|
|
|
|
db () {
|
|
|
|
sqlite3 "${FULL_DATABASE}" "${1}"
|
|
|
|
}
|
|
|
|
|
|
|
|
dbSetup () {
|
|
|
|
cat "./sql/setup.sql" | sqlite3 "${FULL_DATABASE}"
|
|
|
|
}
|
|
|
|
|
|
|
|
hashStr () {
|
|
|
|
echo -n "${1}" | sha256sum | awk '{print $1}'
|
|
|
|
}
|
|
|
|
|
2021-12-08 05:18:45 +00:00
|
|
|
hashFile () {
|
|
|
|
sha256sum "${1}" | awk '{print $1}'
|
|
|
|
}
|
|
|
|
|
2021-12-08 04:11:13 +00:00
|
|
|
uuid () {
|
|
|
|
uuidgen | tr "[:upper:]" "[:lower:]"
|
|
|
|
}
|
|
|
|
|
2021-09-16 15:05:07 +00:00
|
|
|
askContinue () {
|
2021-11-29 16:30:51 +00:00
|
|
|
echo "${1}"
|
2021-09-16 15:05:07 +00:00
|
|
|
echo "Are you ready to continue? (yes/no)"
|
|
|
|
read input
|
|
|
|
if [ "$input" != "n" ] && [ "$input" != "no" ]
|
|
|
|
then
|
2021-11-29 16:30:51 +00:00
|
|
|
echo "${2}"
|
2021-09-16 15:05:07 +00:00
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-12-08 04:11:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
axdraw () {
|
|
|
|
file=$(realpath "${1}")
|
|
|
|
echo "FILE:${file}"
|
|
|
|
if [[ "${PEN}" != "" ]]; then
|
|
|
|
echo "PEN:${PEN}"
|
|
|
|
fi
|
|
|
|
echo "START:$(date '+%s')"
|
2021-12-08 23:48:25 +00:00
|
|
|
ax "${1}" 2>&1
|
2021-12-08 04:11:13 +00:00
|
|
|
echo "END:$(date '+%s')"
|
2023-03-13 20:35:39 +00:00
|
|
|
}
|
|
|
|
|
2023-03-14 11:14:59 +00:00
|
|
|
get_frame_axis () {
|
|
|
|
cat "${1}" | jq -r '.["'${2}'"]["'${3}'"].'${4}
|
|
|
|
}
|
|
|
|
|
|
|
|
get_outer_ratio_frame () {
|
|
|
|
AX=$(get_frame_axis ${1} ${2} 0 x)
|
|
|
|
AY=$(get_frame_axis ${1} ${2} 0 y)
|
|
|
|
BX=$(get_frame_axis ${1} ${2} 1 x)
|
|
|
|
BY=$(get_frame_axis ${1} ${2} 1 y)
|
|
|
|
CX=$(get_frame_axis ${1} ${2} 2 x)
|
|
|
|
CY=$(get_frame_axis ${1} ${2} 2 y)
|
|
|
|
DX=$(get_frame_axis ${1} ${2} 3 x)
|
|
|
|
DY=$(get_frame_axis ${1} ${2} 3 y)
|
2023-03-13 20:35:39 +00:00
|
|
|
ACX=$(echo "${CX}-${AX}" | bc)
|
|
|
|
DBX=$(echo "${DX}-${BX}" | bc)
|
|
|
|
ACY=$(echo "${AY}-${CY}" | bc)
|
|
|
|
DBY=$(echo "${DY}-${BY}" | bc)
|
2023-03-14 12:22:13 +00:00
|
|
|
echo "scale=4;((${ACX}+${DBX})/2) / ((${ACY}+${DBY})/2)" | bc
|
2023-03-14 11:14:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_outer_ratio () {
|
|
|
|
A=$(get_outer_ratio_frame "${1}" 0)
|
|
|
|
B=$(get_outer_ratio_frame "${1}" 1)
|
|
|
|
C=$(get_outer_ratio_frame "${1}" 2)
|
|
|
|
D=$(get_outer_ratio_frame "${1}" 3)
|
|
|
|
echo "scale=4;(${A}+${B}+${C}+${D})/4" | bc
|
2021-09-16 15:05:07 +00:00
|
|
|
}
|