From 79deed3c44a26642154a9af25e92709036e2b459 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Sun, 17 May 2020 21:20:54 +0200 Subject: Added option to magGen.sh to choose output file. --- mapGen/mapGen.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'mapGen/mapGen.sh') diff --git a/mapGen/mapGen.sh b/mapGen/mapGen.sh index bf4bac3..0d77637 100755 --- a/mapGen/mapGen.sh +++ b/mapGen/mapGen.sh @@ -4,13 +4,12 @@ # # Generate a map with ImageMagick from an input text file # -# Usage: mapGen.sh [-s SIZE] [-f TILE_FOLDER] SOURCE_FILE - -usageMsg="Usage: mapGen.sh [-s SIZE] [-f TILE_FOLDER] SOURCE_FILE" +# Usage: mapGen.sh [-s SIZE] [-f TILE_FOLDER] [-o OUTPUT_FILE] SOURCE_FILE +usageMsg="Usage: mapGen.sh [-s SIZE] [-f TILE_FOLDER] [-o OUTPUT_FILE] SOURCE_FILE" cellSize=8 - tilesDir="./tiles" +outputFile="out.jpg" while echo "$1" | grep '^-' >/dev/null; do case "$1" in @@ -24,6 +23,10 @@ while echo "$1" | grep '^-' >/dev/null; do tilesDir="$2" shift 2 ;; + "-o") + [ -z "$2" ] && echo "Missing argument for -o. $usageMsg" >&2 && exit 1 + outputFile="$2" + shift 2 esac done @@ -42,7 +45,7 @@ width=$((width*cellSize)) echo $width $height -convert -size "$width"x"$height" xc:cyan out.jpg +convert -size "$width"x"$height" xc:cyan "$outputFile" row=0 col=0 @@ -53,8 +56,8 @@ while read line; do tileFile="$(find $tilesDir | sed 's|.*/||' | grep "^$char" | shuf | sed 1q)" tileFile="${tilesDir}/${tileFile}" echo "$tileFile" | wc -l | grep 1 >/dev/null || continue - convert out.jpg "$tileFile" -geometry +"$col"+"$row" -composite out.jpg || - convert out.jpg -fill red -draw "point $col,$row" out.jpg + convert "$outputFile" "$tileFile" -geometry +"$col"+"$row" -composite "$outputFile" || + convert "$outputFile" -fill red -draw "point $col,$row" "$outputFile" col=$((col+cellSize)) done) row=$((row+cellSize)) -- cgit v1.2.1