71 lines
1.3 KiB
Bash
71 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
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}'
|
|
}
|
|
|
|
hashFile () {
|
|
sha256sum "${1}" | awk '{print $1}'
|
|
}
|
|
|
|
uuid () {
|
|
uuidgen | tr "[:upper:]" "[:lower:]"
|
|
}
|
|
|
|
askContinue () {
|
|
echo "${1}"
|
|
echo "Are you ready to continue? (yes/no)"
|
|
read input
|
|
if [ "$input" != "n" ] && [ "$input" != "no" ]
|
|
then
|
|
echo "${2}"
|
|
else
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
axdraw () {
|
|
file=$(realpath "${1}")
|
|
echo "FILE:${file}"
|
|
if [[ "${PEN}" != "" ]]; then
|
|
echo "PEN:${PEN}"
|
|
fi
|
|
echo "START:$(date '+%s')"
|
|
ax "${1}" 2>&1
|
|
echo "END:$(date '+%s')"
|
|
}
|
|
|
|
get_outer_ratio () {
|
|
|
|
AX=$(cat "${1}" | jq -r '.["0"]["0"].x')
|
|
AY=$(cat "${1}" | jq -r '.["0"]["0"].y')
|
|
BX=$(cat "${1}" | jq -r '.["0"]["1"].x')
|
|
BY=$(cat "${1}" | jq -r '.["0"]["1"].y')
|
|
CX=$(cat "${1}" | jq -r '.["0"]["2"].x')
|
|
CY=$(cat "${1}" | jq -r '.["0"]["2"].y')
|
|
DX=$(cat "${1}" | jq -r '.["0"]["3"].x')
|
|
DY=$(cat "${1}" | jq -r '.["0"]["3"].y')
|
|
ACX=$(echo "${CX}-${AX}" | bc)
|
|
DBX=$(echo "${DX}-${BX}" | bc)
|
|
ACY=$(echo "${AY}-${CY}" | bc)
|
|
DBY=$(echo "${DY}-${BY}" | bc)
|
|
echo "scale=4;((${ACY}+${DBY})/2) / ((${ACX}+${DBX})/2)" | bc
|
|
} |