From 0c1f19f10a9700a06a7ac8e83d43acc39be54e8b Mon Sep 17 00:00:00 2001 From: jadedctrl Date: Sun, 26 Mar 2017 16:03:29 -0500 Subject: [PATCH] Complete rendering support --- render.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 render.sh diff --git a/render.sh b/render.sh new file mode 100644 index 0000000..0ac2e30 --- /dev/null +++ b/render.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +file=$1 + +height=$(lib/json.sh -s height $file) +width=$(lib/json.sh -s width $file) +heighti=0 + +while [ $heighti -ne $height ] +do + heighti=$((heighti+1)) + widthi=0 + while [ $widthi -ne $width ] + do + widthi=$((widthi+1)) + piece=$(lib/json.sh -s ${widthi},${heighti}/piece $file) + team=$(lib/json.sh -s ${widthi},${heighti}/team $file) + text=$(lib/json.sh -s ${team}/pieces/${piece}/text $file) + if [ -z $text ] + then + text=" " + fi + if [ $(echo "$heighti % 2" | bc) -eq 1 ] + then + if [ $(echo "$widthi % 2" | bc) -eq 1 ] + then + printf "$(tput setab 7) $text" + else + printf "$(tput setab 0) $text" + fi + else + if [ $(echo "$widthi % 2" | bc) -eq 0 ] + then + printf "$(tput setab 7) $text" + else + printf "$(tput setab 0) $text" + fi + fi + done + printf "\033[m\n" +done + +printf '\033[m\n'