huge longrun improvements
This commit is contained in:
@@ -36,27 +36,36 @@
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Let the rain fall
|
||||
# ------------------------------------------------------------------------------
|
||||
# Usage: rain [OPTIONS]
|
||||
# Options:
|
||||
# -s, --speed NUM Set the drop delay in seconds (default: 0.050).
|
||||
# Lower values = faster rain.
|
||||
# -c, --color COLOR Set the color theme (default: white).
|
||||
# -h, --help Display this help message and exit.
|
||||
# Available Colors:
|
||||
# green : The classic Matrix digital rain
|
||||
# blue : Deep ocean blue gradients
|
||||
# red : Crimson/Blood rain
|
||||
# yellow : Amber and gold tones
|
||||
# cyan : Electric cyan/turquoise
|
||||
# white : Greyscale and white (original style)
|
||||
rain()
|
||||
{
|
||||
show_usage() {
|
||||
echo -e "Usage: rain [OPTIONS]"
|
||||
echo -e ""
|
||||
echo -e "Options:"
|
||||
echo -e " -s, --speed NUM Set the drop delay in seconds (default: 0.050)."
|
||||
echo -e " Lower values = faster rain."
|
||||
echo -e " -c, --color COLOR Set the color theme (default: white)."
|
||||
echo -e " -h, --help Display this help message and exit."
|
||||
echo -e ""
|
||||
echo -e "Available Colors:"
|
||||
echo -e " \e[32mgreen\e[0m : The classic Matrix digital rain"
|
||||
echo -e " \e[34mblue\e[0m : Deep ocean blue gradients"
|
||||
echo -e " \e[31mred\e[0m : Crimson/Blood rain"
|
||||
echo -e " \e[33myellow\e[0m : Amber and gold tones"
|
||||
echo -e " \e[36mcyan\e[0m : Electric cyan/turquoise"
|
||||
echo -e " white : Greyscale and white (original style)"
|
||||
echo -e ""
|
||||
echo -e "Example: rain --color green --speed 0.03"
|
||||
printf "Usage: rain [OPTIONS]\n"
|
||||
printf "Options:\n"
|
||||
printf "\t-s, --speed NUM Set the drop delay in seconds (default: 0.050).\n"
|
||||
printf "\t Lower values = faster rain.\n"
|
||||
printf "\t-c, --color COLOR Set the color theme (default: white).\n"
|
||||
printf "\t-h, --help Display this help message and exit.\n\n"
|
||||
printf "Available Colors:\n"
|
||||
printf "\t\e[32mgreen\e[0m\t: The classic Matrix digital rain\n"
|
||||
printf "\t\e[34mblue\e[0m\t: Deep ocean blue gradients\n"
|
||||
printf "\t\e[31mred\e[0m\t: Crimson/Blood rain\n"
|
||||
printf "\t\e[33myellow\e[0m\t: Amber and gold tones\n"
|
||||
printf "\t\e[36mcyan\e[0m\t: Electric cyan/turquoise\n"
|
||||
printf "\twhite\t: Greyscale and white (original style)\n\n"
|
||||
printf "Example: rain --color green --speed 0.03\n"
|
||||
}
|
||||
|
||||
local step_duration=0.050
|
||||
@@ -69,7 +78,7 @@ rain()
|
||||
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
|
||||
step_duration="$2"; shift
|
||||
else
|
||||
echo -e "\e[31mError: --speed requires a numeric value.\e[0m"
|
||||
disp E "--speed requires a numeric value."
|
||||
show_usage && return 1
|
||||
fi
|
||||
;;
|
||||
@@ -77,7 +86,7 @@ rain()
|
||||
if [[ -n "$2" && ! "$2" =~ ^- ]]; then
|
||||
base_color="$2"; shift
|
||||
else
|
||||
echo -e "\e[31mError: --color requires a color name.\e[0m"
|
||||
disp E "--color requires a color name."
|
||||
show_usage && return 1
|
||||
fi
|
||||
;;
|
||||
@@ -85,7 +94,7 @@ rain()
|
||||
show_usage && return 0
|
||||
;;
|
||||
*)
|
||||
echo -e "\e[31mUnknown option: $1\e[0m"
|
||||
disp E "Unknown option: $1"
|
||||
show_usage && return 1
|
||||
;;
|
||||
esac
|
||||
@@ -168,7 +177,7 @@ rain()
|
||||
drop_length=${rains[idx + 4]}
|
||||
for ((y = Y; y < Y + drop_length; y++)); do
|
||||
((y < 1 || y > term_height)) && continue
|
||||
echo -ne "\e[${y};${X}H${drop_color}${rain_drop}"
|
||||
printf "\e[${y};${X}H${drop_color}${rain_drop}"
|
||||
done
|
||||
done
|
||||
}
|
||||
@@ -177,9 +186,9 @@ rain()
|
||||
trap sigwinch WINCH
|
||||
# No echo stdin and hide the cursor
|
||||
stty -echo
|
||||
echo -ne "\e[?25l"
|
||||
printf "\e[?25l"
|
||||
printf "\e[2J"
|
||||
|
||||
echo -ne "\e[2J"
|
||||
local rains=()
|
||||
local num_rains=0
|
||||
sigwinch
|
||||
|
||||
Reference in New Issue
Block a user