Skip to content

Commit

Permalink
no signal
Browse files Browse the repository at this point in the history
  • Loading branch information
wolandark committed Sep 29, 2024
1 parent 1cf55c2 commit 461e6d6
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ANSI-Printing/No-Signal/array-no-video.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

get_terminal_height() {
tput lines
}

get_terminal_width() {
tput cols
}
draw_vertical_bars() {
local terminal_height=$(get_terminal_height)
local terminal_width=$(get_terminal_width)
local bar_width=$((terminal_width / 8))
local -a bar_color=("\033[47m" "\033[43m" "\033[46m" "\033[42m" "\033[45m" "\033[41m" "\033[44m" "\033[40m")

for ((i = 1; i <= terminal_height; i++)); do
printf "$(printf '%s%%-'"${bar_width}"'s\\033[0m' "${bar_color[@]}")\n" " " " " " " " " " " " " " " " "
done

for kk in {7..0..-1}; do
printf "${bar_color[$kk]}%-${bar_width}s\033[0m" " "
done
printf "\n${bar_color[6]}%-$((terminal_width - 6 ))s\033[0m\n" " "
}
draw_vertical_bars
47 changes: 47 additions & 0 deletions ANSI-Printing/No-Signal/no-video.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

get_terminal_height() {
tput lines
}

get_terminal_width() {
tput cols
}

draw_vertical_bars() {
local terminal_height=$(get_terminal_height)
local terminal_width=$(get_terminal_width)
local bar_width=$((terminal_width / 8))
local first_bar_color="\033[47m"
local second_bar_color="\033[43m"
local third_bar_color="\033[46m"
local fourth_bar_color="\033[42m"
local fifth_bar_color="\033[45m"
local sixth_bar_color="\033[41m"
local seventh_bar_color="\033[44m"
local eight_bar_color="\033[40m"

for ((i = 1; i <= terminal_height; i++)); do
printf "${first_bar_color}%-${bar_width}s\033[0m" " " # print the main bars
printf "${second_bar_color}%-${bar_width}s\033[0m" " "
printf "${third_bar_color}%-${bar_width}s\033[0m" " "
printf "${fourth_bar_color}%-${bar_width}s\033[0m" " "
printf "${fifth_bar_color}%-${bar_width}s\033[0m" " "
printf "${sixth_bar_color}%-${bar_width}s\033[0m" " "
printf "${seventh_bar_color}%-${bar_width}s\033[0m" " "
printf "${eight_bar_color}%-${bar_width}s\033[0m\n" " "
done
printf "${eight_bar_color}%-${bar_width}s\033[0m" " " # print the second row of color blocks
printf "${seventh_bar_color}%-${bar_width}s\033[0m" " "
printf "${sixth_bar_color}%-${bar_width}s\033[0m" " "
printf "${fifth_bar_color}%-${bar_width}s\033[0m" " "
printf "${fourth_bar_color}%-${bar_width}s\033[0m" " "
printf "${third_bar_color}%-${bar_width}s\033[0m" " "
printf "${second_bar_color}%-${bar_width}s\033[0m" " "
printf "${first_bar_color}%-${bar_width}s\033[0m\n" " "
printf "${seventh_bar_color}%-$((terminal_width - 6 ))s\033[0m\n" " " # Print the last full width bar
}

clear && tput reset
draw_vertical_bars

23 changes: 23 additions & 0 deletions ANSI-Printing/No-Signal/tput-no-video.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

cols=$(tput cols)
lines=$(tput lines)
barwidth=$(( cols / 8 ))
colors=( 47 43 46 42 45 41 44 40 )

drawBarSegment() {
printf '\033[%dm%*s' "$1" "$barwidth" " "
}

for (( line = 1; line < lines - 1; line++ )); do
for color in "${colors[@]}"; do
drawBarSegment $color
done
printf '%*s\n' "$(( cols % 8 ))" " "
done

for color in ${colors[@]}; do
lastline="$(drawBarSegment $color)$lastline"
done
printf "%s%*s%s\033[m\n" "$lastline" "$(( cols % 8 ))"

0 comments on commit 461e6d6

Please sign in to comment.