factorized script to produce the 3 set of images starting just from north images
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Thu, 30 Apr 2020 11:03:18 +0000 (13:03 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Thu, 30 Apr 2020 11:35:11 +0000 (13:35 +0200)
bin/sprite_main.sh
bin/spriter.sh

index 664f0d8..76aaa57 100755 (executable)
@@ -1,13 +1,14 @@
 #!/bin/bash
 ./bin/borderizer.sh briskin5/img briskin5/img/with_border_template.png ""
 ./bin/spriter.sh briskin5/img "_bord" briskin5/img/cards_xx
-geeqie briskin5/img/cards_xx_bord.png
 
+# geeqie briskin5/img/cards_xx_bord.png
 
-./bin/borderizer.sh briskin5/img briskin5/img/with_border_template_side.png "_ea"
-./bin/spriter.sh briskin5/img "_bord_ea" briskin5/img/cards_xx
-geeqie briskin5/img/cards_xx_bord_ea.png
 
-./bin/borderizer.sh briskin5/img briskin5/img/with_border_template_side.png "_we"
-./bin/spriter.sh briskin5/img "_bord_we" briskin5/img/cards_xx
-geeqie briskin5/img/cards_xx_bord_we.png
+# ./bin/borderizer.sh briskin5/img briskin5/img/with_border_template_side.png "_ea"
+# ./bin/spriter.sh briskin5/img "_bord_ea" briskin5/img/cards_xx
+# geeqie briskin5/img/cards_xx_bord_ea.png
+
+# ./bin/borderizer.sh briskin5/img briskin5/img/with_border_template_side.png "_we"
+# ./bin/spriter.sh briskin5/img "_bord_we" briskin5/img/cards_xx
+# geeqie briskin5/img/cards_xx_bord_we.png
index 981b77b..bc53357 100755 (executable)
@@ -2,6 +2,8 @@
 #
 #  Max height in play area 121 px
 #
+# set -x
+
 
 if [ $# -ne 3 -o "$1" = "-h" -o "$1" = "--help" ]; then
     echo "$0 <folder_in> <suffix> <file_out_without_extension>"
@@ -15,19 +17,49 @@ w=$(identify -format "%w" ${fold}/00${sfx}.png)
 h=$(identify -format "%h" ${fold}/00${sfx}.png)
 
 convert -size $((w * 9))x$((h * 5)) xc:none ${fou}${sfx}_bg.png
+convert -size $((h * 9))x$((w * 5)) xc:none ${fou}${sfx}_oriz_bg.png
+
+for direction in "" "_ea" "_we"; do
+    horiz_sfx=""
+    if [ "$direction" != "" ]; then
+        horiz_sfx="_oriz"
+    fi
+    argz="${fou}${sfx}${horiz_sfx}_bg.png"
 
-argz="${fou}${sfx}_bg.png"
+    for seed in 0 1 2 3 4; do
+        for card in $(seq 0 9); do
+            if [ "$direction" = "" ]; then
+                x=$(((seed * 2 + card / 5) * w)) 
+                y=$(((card % 5) * h))
+            else
+                x=$(((seed * 2 + card / 5) * h)) 
+                y=$(((card % 5) * w))
+            fi
 
-for seed in 0 1 2 3 4; do
-    for card in $(seq 0 9); do
-        x=$(((seed * 2 + card / 5) * w)) 
-        y=$(((card % 5) * h))
-        argz="$argz $(printf "%s/%02d%s.png" "$fold" "$((seed * 10 + card))" "$sfx") -geometry +${x}+${y} -composite "
-        if [ $seed -eq 4 ]; then
-            break
-        fi
+            fin_no=$(printf "%s/%02d%s.png" "$fold" "$((seed * 10 + card))" "$sfx")
+            fin=$(printf "%s/%02d%s%s.png" "$fold" "$((seed * 10 + card))" "$sfx" "$direction")
+            if [ $seed -lt 4 ]; then
+                if [ "$direction" == "" ]; then
+                    :
+                elif [ "$direction" == "_ea" ]; then
+                    convert -rotate 270 "$fin_no" "$fin"
+                elif [ "$direction" == "_we" ]; then
+                    convert -rotate 90 "$fin_no" "$fin"                
+                else
+                    exit 1
+                fi
+            fi
+            
+            argz="$argz $fin -geometry +${x}+${y} -composite "
+            if [ $seed -eq 4 ]; then
+                break
+            fi
+        done
     done
+    # full color: argz="$argz ${fou}${sfx}.png"
+    argz="$argz +dither -colors 255 ${fou}${sfx}${direction}.png"
+    convert $argz
+    echo "Created ${fou}${sfx}${direction}.png"
 done
 
-argz="$argz ${fou}${sfx}.png"
-convert $argz
+rm ${fou}${sfx}_bg.png ${fou}${sfx}_oriz_bg.png ${fold}/[0-3][0-9]${sfx}*.png