From: Matteo Nastasi Date: Sun, 10 May 2020 11:00:41 +0000 (+0200) Subject: grand folder refactoring X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=34412208161ef2fa5fcfcc66a6e0ec698e375ede;p=brisk-img.git grand folder refactoring --- diff --git a/bin/borderizer.sh b/bin/borderizer.sh index f69874f..c78ba64 100755 --- a/bin/borderizer.sh +++ b/bin/borderizer.sh @@ -1,24 +1,27 @@ #!/bin/bash -if [ $# -ne 3 -o "$1" = "-h" -o "$1" = "--help" ]; then - echo "$0 " +if [ $# -ne 2 -o "$1" = "-h" -o "$1" = "--help" ]; then + echo "$0 " exit 1 fi fold=$1 -tmpl=$2 -sfx=$3 +deck=$2 +template="${fold}/${deck}_src/border_template.png" -w=$(identify -format "%w" ${fold}/00${sfx}.png) -h=$(identify -format "%h" ${fold}/00${sfx}.png) +w=$(identify -format "%w" ${fold}/00.png) +h=$(identify -format "%h" ${fold}/00.png) -wt=$(identify -format "%w" "${tmpl}") -ht=$(identify -format "%h" "${tmpl}") +wt=$(identify -format "%w" "$template") +ht=$(identify -format "%h" "$template") x=$(((wt - w) / 2)) y=$(((ht - h) / 2)) +dest_dir="${fold}/${deck}_tmp" + for card in $(seq 0 39); do - convert "$tmpl" $(printf "%s/%02d%s.png" "$fold" "$((seed * 10 + card))" "$sfx") \ - -geometry +${x}+${y} -composite $(printf "%s/%02d_bord%s.png" "$fold" "$((seed * 10 + card))" "$sfx") + convert "$template" $(printf "%s/%02d.png" "$fold" "$((seed * 10 + card))") \ + -geometry +${x}+${y} -composite $(printf "%s/%02d.png" "$dest_dir" "$((seed * 10 + card))") done +cp "${fold}/${deck}_src/cover.png" "${dest_dir}/40.png" diff --git a/bin/sprite_main.sh b/bin/sprite_main.sh index 238d556..649f809 100755 --- a/bin/sprite_main.sh +++ b/bin/sprite_main.sh @@ -1,6 +1,13 @@ #!/bin/bash -./bin/borderizer.sh briskin5/single_cards_xx briskin5/single_cards_xx/with_border_template.png "" -./bin/spriter.sh briskin5/single_cards_xx "_bord" briskin5/img/cards_xx -./bin/borderizer.sh briskin5/single_cards_yy briskin5/single_cards_yy/with_border_template.png "" -./bin/spriter.sh briskin5/single_cards_yy "_bord" briskin5/img/cards_yy +declare -A folders + +folders=( [single_cards_xx]="xx nb" [single_cards_yy]="yy" ) + +for folder in ${!folders[@]}; do + for deck in ${folders[$folder]}; do + ./bin/borderizer.sh "briskin5/$folder" $deck + ./bin/spriter.sh "briskin5/$folder" $deck + done +done + diff --git a/bin/spriter.sh b/bin/spriter.sh index f8df9dd..6c27dc0 100755 --- a/bin/spriter.sh +++ b/bin/spriter.sh @@ -5,24 +5,28 @@ # set -x -if [ $# -ne 3 -o "$1" = "-h" -o "$1" = "--help" ]; then - echo "$0 " +if [ $# -ne 2 -o "$1" = "-h" -o "$1" = "--help" ]; then + echo "$0 " exit 1 fi fold=$1 -sfx=$2 -fou=$3 +deck=$2 -w=$(identify -format "%w" ${fold}/00${sfx}.png) -h=$(identify -format "%h" ${fold}/00${sfx}.png) +fold_in="${fold}/${deck}_tmp" +fold_ou="${fold}/${deck}_out" -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 +# sfx=$2 -convert -size ${w}x${h} xc:none ${fou}${sfx}_empty.png -convert -size ${h}x${w} xc:none ${fou}${sfx}_empty_ea.png -cp ${fou}${sfx}_empty_ea.png ${fou}${sfx}_empty_we.png -cssname="${fou}${sfx}.css" +w=$(identify -format "%w" ${fold_in}/00.png) +h=$(identify -format "%h" ${fold_in}/00.png) + +convert -size $((w * 9))x$((h * 5)) xc:none ${fold_in}/${deck}_bg.png +convert -size $((h * 9))x$((w * 5)) xc:none ${fold_in}/${deck}_oriz_bg.png + +convert -size ${w}x${h} xc:none ${fold_ou}/${deck}_empty.png +convert -size ${h}x${w} xc:none ${fold_ou}/${deck}_empty_ea.png +cp ${fold_ou}/${deck}_empty_ea.png ${fold_ou}/${deck}_empty_we.png +cssname="${fold_ou}/cards_${deck}.css" rm -f $cssname touch $cssname @@ -31,7 +35,7 @@ for direction in "" "_ea" "_we"; do if [ "$direction" != "" ]; then horiz_sfx="_oriz" fi - argz="${fou}${sfx}${horiz_sfx}_bg.png" + argz="${fold_in}/${deck}${horiz_sfx}_bg.png" for seed in 0 1 2 3 4; do for card in $(seq 0 9); do @@ -47,7 +51,7 @@ for direction in "" "_ea" "_we"; do if [ "$card_id" = "40" ]; then card_id="cover" fi - card_url=$(echo "$fou" | sed 's@.*/\([^/]\+/[^/]\+$\)@\1@g') + card_url=$(echo "$fold_ou" | sed 's@.*/\([^/]\+/[^/]\+$\)@\1@g') cat <> $cssname img[data-card-id="${card_id}${direction}"] { background: url('${card_url}${direction}.png') -${x}px -${y}px; @@ -55,18 +59,24 @@ img[data-card-id="${card_id}${direction}"] { 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 [ "$card_id" = "40" ]; then + fin_no=$(printf "%s/%s_src/cover${direction}.png" "$fold_in" "$deck" "$((seed * 10 + card))") + fin=$(printf "%s/%02d%s.png" "$fold_in" "$((seed * 10 + card))" "$direction") 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 + cp "$fin_no" "$fin" fi + else + fin_no=$(printf "%s/%02d.png" "$fold_in" "$((seed * 10 + card))") + fin=$(printf "%s/%02d%s.png" "$fold_in" "$((seed * 10 + card))" "$direction") + fi + 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 argz="$argz $fin -geometry +${x}+${y} -composite " @@ -75,10 +85,10 @@ EOF fi done done - # full color: argz="$argz ${fou}${sfx}.png" - argz="$argz +dither -colors 255 ${fou}${sfx}${direction}.png" + # full color: argz="$argz ${fold_ou}${deck}.png" + argz="$argz +dither -colors 255 ${fold_ou}/${deck}${direction}.png" convert $argz - echo "Created ${fou}${sfx}${direction}.png" + echo "Created ${fold_ou}/${deck}${direction}.png" done -rm ${fold}/[0-3][0-9]${sfx}*.png ${fou}${sfx}_bg.png ${fou}${sfx}_oriz_bg.png +# rm ${fold}/[0-3][0-9]${deck}*.png ${fold_ou}${deck}_bg.png ${fold_ou}${deck}_oriz_bg.png diff --git a/briskin5/single_cards_xx/nb_src/cover_ea.png b/briskin5/single_cards_xx/nb_src/cover_ea.png deleted file mode 100644 index 0cf3b46..0000000 Binary files a/briskin5/single_cards_xx/nb_src/cover_ea.png and /dev/null differ diff --git a/briskin5/single_cards_xx/nb_src/cover_we.png b/briskin5/single_cards_xx/nb_src/cover_we.png deleted file mode 100644 index 0cf3b46..0000000 Binary files a/briskin5/single_cards_xx/nb_src/cover_we.png and /dev/null differ diff --git a/briskin5/single_cards_xx/xx_src/cover_ea.png b/briskin5/single_cards_xx/xx_src/cover_ea.png deleted file mode 100644 index f15762d..0000000 Binary files a/briskin5/single_cards_xx/xx_src/cover_ea.png and /dev/null differ diff --git a/briskin5/single_cards_xx/xx_src/cover_we.png b/briskin5/single_cards_xx/xx_src/cover_we.png deleted file mode 100644 index acdd1be..0000000 Binary files a/briskin5/single_cards_xx/xx_src/cover_we.png and /dev/null differ diff --git a/briskin5/single_cards_yy/yy_src/cover_ea.png b/briskin5/single_cards_yy/yy_src/cover_ea.png deleted file mode 100644 index 3d9c91d..0000000 Binary files a/briskin5/single_cards_yy/yy_src/cover_ea.png and /dev/null differ diff --git a/briskin5/single_cards_yy/yy_src/cover_we.png b/briskin5/single_cards_yy/yy_src/cover_we.png deleted file mode 100644 index c7c804e..0000000 Binary files a/briskin5/single_cards_yy/yy_src/cover_we.png and /dev/null differ