-make_board() {
- local -n mm=$1
- local -n b=$2
-
- min_horz=${mm[0]}
- if [ $min_horz -gt 0 ]; then
- min_horz=0
- fi
-
- min_vert=${mm[2]}
- if [ $min_vert -gt 0 ]; then
- min_vert=0
- fi
-
- max_horz=${mm[1]}
- total_horz=$(($max_horz - $min_horz))
-
- max_vert=${mm[3]}
-
- cur_vert=${min_vert}
- blank_string=$(printf ".%.0s" $(eval echo '{0..'$total_horz'}'))
- while [[ $cur_vert -le ${max_vert} ]]; do
- if [[ $cur_vert -eq 0 ]]; then
- offset=$((0-${mm[0]}))
- line="${blank_string:0:$offset}o${blank_string:$((offset+1))}"
- b[$cur_vert]=$line
- else
- b[$cur_vert]=$blank_string
- fi
- cur_vert=$((cur_vert+1))
- done
-}
-
-echo "Getting board boundaries"
-IFS="," read -a min_max < <(get_min_max wire_1)
-IFS="," read -a min_max_2 < <(get_min_max wire_2)
-
-# do the minimums first
-for pos in 0 2; do
- if [ ${min_max[$pos]} -gt ${min_max_2[$pos]} ]; then
- min_max[$pos]=${min_max_2[$pos]}
- fi
-done
-
-# now the maximums
-for pos in 1 3; do
- if [ ${min_max[$pos]} -lt ${min_max_2[$pos]} ]; then
- min_max[$pos]=${min_max_2[$pos]}
- fi
-done
-
-echo " ${min_max[@]}"
-
-# we now know exactly how big the grid is, which is handy, as we'll use it to do offsets