diff --git a/README.md b/README.md new file mode 100644 index 0000000..46878d0 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# Animation Scripts + +This repository contains scripts and other tools for 2D digital to analog anamation. + + +## fourcell.sh + +Example: + +``` +bash fourcell.sh example.calibration.json dir/of/images output/dir +``` \ No newline at end of file diff --git a/common.sh b/common.sh index 900e4a0..61238dd 100644 --- a/common.sh +++ b/common.sh @@ -51,4 +51,21 @@ axdraw () { 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 } \ No newline at end of file diff --git a/fourcell.sh b/fourcell.sh index aab6ec1..f702a3c 100644 --- a/fourcell.sh +++ b/fourcell.sh @@ -3,7 +3,7 @@ #set -e if [[ "${1}" == "" ]]; then - echo "Please provide a calibration JSON" + echo "Please provide a template JSON" fi if [[ "${2}" == "" ]]; then diff --git a/template_ratio.sh b/template_ratio.sh new file mode 100644 index 0000000..18383db --- /dev/null +++ b/template_ratio.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source ./common.sh + +get_outer_ratio "${1}" \ No newline at end of file diff --git a/white_fourcell.sh b/white_fourcell.sh index fcd0f2b..45af295 100644 --- a/white_fourcell.sh +++ b/white_fourcell.sh @@ -1,4 +1,7 @@ #!/bin/bash + +source ./common.sh + #iWidth 323 = oWidth 404 #iHeight 242 = oHeight 374 @@ -7,6 +10,11 @@ SCALE=$(echo "scale=$DIGITS; 323/404" | bc) OUTER=$(echo "scale=$DIGITS; 374/404" | bc) RATIO=$(echo "scale=$DIGITS; 242/323" | bc) +# current ratio 1.088 +# template ratio 1.291 + + + if [[ "${1}" != "" ]]; then DPI=${1} else