aboutsummaryrefslogtreecommitdiff
path: root/mapGen/mapGen.sh
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2020-05-17 14:41:53 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2020-05-17 14:41:53 +0200
commit4e7cf6c285f1e932a04e16cf144917333b78e579 (patch)
treed65cf35abcccc73c25e2e16953b888dc8b99a266 /mapGen/mapGen.sh
parent1ce6627eb3c82b110eb24a28fa7697e271c21ffa (diff)
downloadscripts-4e7cf6c285f1e932a04e16cf144917333b78e579.tar.gz
scripts-4e7cf6c285f1e932a04e16cf144917333b78e579.zip
i3blocks: short mem text and fixed exit when cmus not running.
Diffstat (limited to 'mapGen/mapGen.sh')
-rwxr-xr-xmapGen/mapGen.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/mapGen/mapGen.sh b/mapGen/mapGen.sh
new file mode 100755
index 0000000..1be77f7
--- /dev/null
+++ b/mapGen/mapGen.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# mapGen.sh
+#
+# Generate a map with ImageMagick from an input text file
+
+inputFile="$1"
+
+cellSize=8
+
+tilesDir="./tiles"
+
+height="$(wc -l <"$inputFile")"
+width="$(awk '{print length($0)}' "$inputFile" | sort -nr | sed 1q)"
+
+height=$((height*cellSize))
+width=$((width*cellSize))
+
+echo $width $height
+
+convert -size "$width"x"$height" xc:cyan out.jpg
+
+row=0
+col=0
+
+while read line; do
+ echo "$line" | (
+ while read -n1 char; do
+ tileFile="$(find $tilesDir | sed 's|.*/||' | grep "^$char")"
+ 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
+ col=$((col+cellSize))
+ done)
+ row=$((row+cellSize))
+ col=0
+done <"$inputFile"