]> git.plutz.net Git - confetti/blobdiff - actions/update_therapy.sh
drawable overlays
[confetti] / actions / update_therapy.sh
index cc95e3965c973da376392d9971fbc1e637dd7445..52daa11ba0e042f921a66738edee62c7c21e16d7 100755 (executable)
@@ -26,7 +26,7 @@ tempfile="$_DATA/temp/$tpy"
 
 # serialize POST array into file
 for key in ${(k)_POST}; do
-  printf %s:%s\\n "$key" "${_POST[$key]//$BR/\\n}"
+  [ "$key" != imagedata ] && printf %s:%s\\n "$key" "${_POST[$key]//$BR/\\n}"
 done >"$tempfile"
 
 if [ -n "$_POST[delete_session]" ]; then
@@ -61,19 +61,16 @@ elif [ -n "$_POST[dotmark.x]" -a -n "$_POST[dotmark.y]" ]; then
   x="$_POST[dotmark.x]"
   y="$_POST[dotmark.y]"
 
-  case "$_POST[color]" in
-    c000) c="#000000";;
-    c001) c="#000088";;
-    c010) c="#008800";;
-    c011) c="#008888";;
-    c100) c="#880000";;
-    c101) c="#880088";;
-    c110) c="#888800";;
-    c111) c="#888888";;
-  esac
+  convert "${tpyfile%.tpy}_${sid}.png" -draw "fill $_POST[color] circle $x,$y $(($x+5)),$y" "${tpyfile%.tpy}_${sid}.png"
 
-  convert "${tpyfile%.tpy}_${sid}.png" -fill "$c" -stroke "$c" -draw "circle $x,$y $(($x+5)),$y" "${tpyfile%.tpy}_${sid}.png"
+elif [ -n "$_POST[imagedata]" ]; then
+  sed -rn 's;^(session[0-9]+)_open:checked$;\1;p' "$tempfile" \
+  | sort -n \
+  | tail -n1 \
+  | read sid
 
+  convert "${tpyfile%.tpy}_${sid}.png" -draw "${_POST[imagedata]}" -transparent white "${tpyfile%.tpy}_${sid}.png"
+  sync
 fi
 
 mv "$tempfile" "$tpyfile"