diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2020-05-17 21:20:54 +0200 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2020-05-17 21:20:54 +0200 |
commit | 79deed3c44a26642154a9af25e92709036e2b459 (patch) | |
tree | bf3a110824438f51711a6af0a417570a436d2c53 /mapGen/mapGen.sh | |
parent | 52583613b1f926d48ba76038259cde735d06fb43 (diff) | |
download | scripts-79deed3c44a26642154a9af25e92709036e2b459.tar.gz scripts-79deed3c44a26642154a9af25e92709036e2b459.zip |
Added option to magGen.sh to choose output file.
Diffstat (limited to 'mapGen/mapGen.sh')
-rwxr-xr-x | mapGen/mapGen.sh | 17 |
1 files changed, 10 insertions, 7 deletions
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)) |