M gendeck.sh => gendeck.sh +11 -10
@@ 1,5 1,5 @@
#!/bin/sh
-# requirements: xq, find
+# requirements: find, inkscape, imagemagick
function usage {
echo "gendeck.sh <id1> <id2> <id3> <id4>"
@@ 32,8 32,6 @@ if [ ! "$card1" = "" ] && [ ! "$card1" = "" ] && [ ! "$card1" = "" ] && [ ! "$ca
echo "he is trying really hard"
echo "grab a cup of tea - this might take a while"
- echo ...
-
rm -rf dist
# create build folder
@@ 49,13 47,16 @@ if [ ! "$card1" = "" ] && [ ! "$card1" = "" ] && [ ! "$card1" = "" ] && [ ! "$ca
cut -d'/' -f3 | \
cut -d'.' -f1 | \
while read face; do
- sh ./parts/plain/assemble.sh $card1 $face > dist/plain/$card1/$face.svg
- sh ./parts/plain/assemble.sh $card2 $face > dist/plain/$card2/$face.svg
- sh ./parts/plain/assemble.sh $card3 $face > dist/plain/$card3/$face.svg
- sh ./parts/plain/assemble.sh $card4 $face > dist/plain/$card4/$face.svg
+ sh ./parts/plain/assemble.sh $card1 $face dist/plain/$card1/$face.png
+ echo -n .
+ sh ./parts/plain/assemble.sh $card2 $face dist/plain/$card2/$face.png
+ echo -n .
+ sh ./parts/plain/assemble.sh $card3 $face dist/plain/$card3/$face.png
+ echo -n .
+ sh ./parts/plain/assemble.sh $card4 $face dist/plain/$card4/$face.png
done
- echo ...
+ echo
echo "*sweats*"
echo "blahaj is really sorry - but you gotta wait a little longer"
@@ 65,11 66,11 @@ if [ ! "$card1" = "" ] && [ ! "$card1" = "" ] && [ ! "$card1" = "" ] && [ ! "$ca
cut -d'/' -f3 | \
cut -d'.' -f1 | \
while read face; do
- sh ./parts/special/assemble.sh $face $card1 $card2 $card3 $card4 > dist/special/$face.svg
+ sh ./parts/special/assemble.sh $face $card1 $card2 $card3 $card4 dist/special/$face.png
+ echo -n .
done
echo ...
-
echo "blahaj finished your deck"
echo "you can find the output files in the dist folder"
echo "(blahaj sorted them - just for you)"
A genpreview.sh => genpreview.sh +16 -0
@@ 0,0 1,16 @@
+#!/bin/sh
+# requires: imagemagick
+
+out="$1"
+
+function usage {
+ echo "$0 <outfile>"
+ echo "generates a montage png showing off all generated cards in the dist folder"
+ exit 1
+}
+
+if [ "$out" = "" ]; then
+ usage
+fi
+
+montage -geometry +20+20 $(find dist -iname '*.png') $out
M parts/plain/assemble.sh => parts/plain/assemble.sh +17 -20
@@ 1,30 1,27 @@
#!/bin/sh
-# requirements: awk,xq
+# requirements: inkscape, imagemagick
flag="$1"
card="$2"
+to="$3"
# get svg file content
scriptdir=$(dirname $0)
-base="$(cat $scriptdir/../flag-base/$flag.svg)"
-overlay="$(cat $scriptdir/$card.svg)"
+base="$scriptdir/../flag-base/$flag.svg"
+overlay="$scriptdir/$card.svg"
-# extract the svg dimensions from the xml using xq
-base_box=$(echo "$base" | xq -a viewBox -q svg)
-overlay_box=$(echo "$overlay" | xq -a viewBox -q svg)
+tmpdir="$(mktemp -d)"
-# calculate the overlay offset by subtracting
-# the overlay witdth from the base width
-# and the overlay height from the base height
-off_x="$(echo $base_box $overlay_box | awk '{ print ($3 - $7)/2 }')"
-off_y="$(echo $base_box $overlay_box | awk '{ print ($4 - $8)/2 }')"
+# convert base card to png
+basetmp="$tmpdir/base.png"
+inkscape \
+ --export-filename=$basetmp \
+ --export-type=png $base
-# get the inner svg from the overlay
-ov="$(echo "$overlay" | xq -q 'svg' -n)"
-# get the svg content from the base
-bg="$(echo "$base" | xq -q 'svg' -n)"
-# generate offset glu code to be inserted in the base
-glu="<g transform=\"translate($off_x,$off_y)\">$ov</g>"
+# convert overlay to png
+ovtmp="$tmpdir/ov.png"
+inkscape \
+ --export-filename=$ovtmp \
+ --export-type=png $overlay
-echo "$bg" | sed 's/<\/svg>//'
-echo "$glu"
-echo "</svg>"
+magick composite -gravity center png:$ovtmp png:$basetmp $to
+rm -rf $tmpdir
M parts/special/assemble.sh => parts/special/assemble.sh +36 -29
@@ 1,43 1,50 @@
#!/bin/sh
-# requirements: awk,xq
+# requirements: inkscape, imagemagick
card="$1"
flag1="$2"
flag2="$3"
flag3="$4"
flag4="$5"
+to="$6"
# get svg file content
scriptdir=$(dirname $0)
-base="$(cat $scriptdir/$card.svg)"
+base="$scriptdir/$card.svg"
+ov1="$scriptdir/../flags/$flag1.svg"
+ov2="$scriptdir/../flags/$flag2.svg"
+ov3="$scriptdir/../flags/$flag3.svg"
+ov4="$scriptdir/../flags/$flag4.svg"
-# extract the svg dimensions from the xml using xq
-base_box=$(echo "$base" | xq -a viewBox -q svg)
+tmpdir="$(mktemp -d)"
-function gen_ov {
- flag="$1"
- opx="$2"
- opy="$3"
+# convert base card to png
+basetmp="$tmpdir/base.png"
+inkscape \
+ --export-filename=$basetmp \
+ --export-type=png $base
- ov="$(cat $scriptdir/../flags/$flag.svg)"
- box="$(echo "$ov" | xq -a viewBox -q svg)"
- off_x="$(echo $base_box $box $opx | awk '{ print ($3/2 + $7*$9/2 - $7/2 + $7/16) }')"
- off_y="$(echo $base_box $box $opy | awk '{ print ($4/2 + $8*$9/2 - $7/2 + $7/8) }')"
- inner="$(echo "$ov" | xq -q 'svg' -n)"
- echo "<g transform=\"translate($off_x, $off_y)\">"
- echo "$inner"
- echo "</g>"
-}
+# convert overlays to png
+tl="$tmpdir/tl.png"
+tr="$tmpdir/tr.png"
+bl="$tmpdir/bl.png"
+br="$tmpdir/br.png"
+inkscape \
+ --export-filename=$tl \
+ --export-type=png $ov1
+inkscape \
+ --export-filename=$tr \
+ --export-type=png $ov2
+inkscape \
+ --export-filename=$bl \
+ --export-type=png $ov3
+inkscape \
+ --export-filename=$br \
+ --export-type=png $ov4
-bg="$(echo "$base" | xq -q 'svg>g' -n)"
-c1="$(gen_ov $flag1 '-1' '-1')"
-c2="$(gen_ov $flag2 '1' '-1')"
-c3="$(gen_ov $flag3 '-1' '1')"
-c4="$(gen_ov $flag4 '1' '1')"
+mnt="$tmpdir/montage.png"
+montage -background none -geometry +0+0 png:$tl png:$tr png:$bl png:$br png:$mnt
-# print svg to stdout
-echo "$bg" | sed 's/<\/svg>//'
-echo "$c1"
-echo "$c2"
-echo "$c3"
-echo "$c4"
-echo "</svg>"
+magick composite \
+ -gravity center png:$mnt png:$basetmp $to
+
+rm -rf $tmpdir