Advertisement
metalx1000

Draw Grid in Terminal (buildings)

Jan 8th, 2025
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.44 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2024  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation version 3 of the License.
  9.  
  10. #This program is distributed in the hope that it will be useful,
  11. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #GNU General Public License for more details.
  14.  
  15. #You should have received a copy of the GNU General Public License
  16. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. ######################################################################
  18.  
  19. clear
  20.  
  21. function draw_grid() {
  22.   start_x=$1
  23.   width=$(($start_x + $2))
  24.  
  25.   start_y=$3
  26.   height=$(($start_y + $4))
  27.  
  28.   # hide cursor
  29.   printf "\033[?25l"
  30.   for x in $(seq $start_x 2 $width); do
  31.     for y in $(seq $start_y $height); do
  32.       printf "\033[${y};${x}H█"
  33.       sleep .001
  34.     done
  35.   done
  36.  
  37.   for x in $(seq $start_x $width); do
  38.     for y in $(seq $start_y 2 $height); do
  39.       printf "\033[${y};${x}H█"
  40.       sleep .001
  41.     done
  42.   done
  43.  
  44.   # show cursor
  45.   printf "\n\033[?25h"
  46. }
  47.  
  48. draw_grid 4 40 10 15
  49. printf "\033[34m" # blue
  50. draw_grid 72 40 10 6
  51. printf "\033[31m" # red
  52. draw_grid 40 40 2 14
  53. printf "\033[0m" # reset color
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement