Files

87 lines
3.3 KiB
Bash

#!/usr/bin/env bash
clear
# Define an array of standard 16-color ANSI foreground codes
colors=(
"\e[31m" # Red
"\e[33m" # Yellow
"\e[32m" # Green
"\e[36m" # Cyan
"\e[34m" # Blue
"\e[35m" # Magenta
)
color_count=${#colors[@]}
color_index=0
shuffle_colors() {
local i tmp rand
# Start from the last element and move backwards
for ((i=${#colors[@]}-1; i>0; i--)); do
# Generate a random index between 0 and i (inclusive)
rand=$(( RANDOM % (i + 1) ))
# Swap elements at index 'i' and 'rand'
tmp="${colors[i]}"
colors[i]="${colors[rand]}"
colors[rand]="$tmp"
done
}
# randomize dem color postions
shuffle_colors
# Reset code to clear colors at the end of output
reset="\e[0m"
read -r -d '' ascii_art << 'EOF'
--= =----=
=--= -------=
=--= --------=
=----= --- =---------=
----= =--- ---==++=----:-----=
=-----= - ---- ========----::----=
=------= ----=+===-::::::::=+**++===+#
==-----=----=+**+=:::-======++******+==+##
=------=-=+*:::-=============+*****+==+*##
=------=+=:-++==--+=++===+====+***+===***=
=--------+*===---+===+===+++==+**=+==+**+-
=------=+===--=+++==++++%%*==**====+**+.- -
#=---=+====-=+++=+++*+.%+-==**=-==+**+.. --
#**+--+========++++#%#**=--==**--==+**=..: =-
*****+======+-+++*%%@@%=---==**--+=+*--:..- =
#*****=====+=-=++***#%#-----=**=-+=+*=---:.. %%
%****+====+=--=+++.:+*=-------=*-===**=---:..- %%
#***+=====------=:.-=----------==+=+**+---...: %%%%#%
#**+====:---------=-------------+=+=***=-....: %%##%%##
%***====..:---------------------==+=-****:.....+%#%%#%%%%#
#**+==*=...---------------:.----+==--=***=....##%#######%%
#***+=+*=...--------------:..:--=+=----+***:...#%###%%##%
#**+==+*=..:-------------:...:--++------=***.:+##%#%%%#% =
#***+==+**...:----------:.....:--+=------==**++##%#%%%%% =-
#***#+==+**=.................+*---+=------=#+=##%%##%%%#%=---
%#**#%*===+***-.....---...=+.:*#=----------=##*#%####%%%%#=----
%#### +===****-...: -+##=#%%+---------+###%%%%%%#%%%%%*-----
*===+****-..- %###%%%+------=*######%%%%%%%##%#*------
+===+****-.- %##%%%*-----#########%####%#####*-------
____ ____ __ __ _ ___ ____ ____ ____ ____ __
( _ \( _ \( )( ( \ / __)( __)/ ___)/ ___) ( _ \( )
) __/ ) / )( / /( (__ ) _) \___ \\___ \ ) __/ )(
(__) (__\_)(__)\_)__) \___)(____)(____/(____/ (__) (__)
EOF
# Process the art character-by-character
for (( i=0; i<${#ascii_art}; i++ )); do
char="${ascii_art:$i:1}"
# If the character is a space or a newline, print it raw without wasting a color
if [[ "$char" == " " || "$char" == $'\n' ]]; then
printf "%s" "$char"
else
# Assign a color, print the letter, and rotate the index cycle
printf "%b%s" "${colors[$color_index]}" "$char"
color_index=$(( (color_index + 1) % color_count ))
fi
done
# Always clear the terminal color state back to default at the end
printf "%b\n" "$reset"