X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=bin%2Fspriter.sh;h=e9f4026c1e6006d0dde95f22ae3b36f21b2f98b5;hb=a0a60175da199e687e19998d4d3fe35f82682d31;hp=981b77bd455b63cf965e6b1d672e99da730bfc27;hpb=5340c7d531e490786bb97dc19348297481b61f7b;p=brisk-img.git diff --git a/bin/spriter.sh b/bin/spriter.sh index 981b77b..e9f4026 100755 --- a/bin/spriter.sh +++ b/bin/spriter.sh @@ -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 " @@ -15,19 +17,64 @@ 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 + +convert -size ${w}x${h} xc:none ${fou}${sfx}_empty.png +convert -size ${h}x${w} xc:none ${fou}${sfx}_empty_eawe.png + +cssname="${fou}${sfx}.css" +rm -f $cssname +touch $cssname + +for direction in "" "_ea" "_we"; do + horiz_sfx="" + if [ "$direction" != "" ]; then + horiz_sfx="_oriz" + fi + argz="${fou}${sfx}${horiz_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 -argz="${fou}${sfx}_bg.png" + card_id=$(printf "%02d" "$((seed * 10 + card))") + cat <> $cssname +img[data-card-id="${card_id}${direction}"] { + background: url('img/cards_xx${direction}.png') -${x}px -${y}px; +} -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 +EOF + + 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 ${fold}/[0-3][0-9]${sfx}*.png ${fou}${sfx}_bg.png ${fou}${sfx}_oriz_bg.png