From ce2b0b941169e19a33d5125314a090a081b297a3 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 7 Nov 2023 15:57:30 +0000 Subject: [PATCH] Add random color generation for title --- thebookofcolors | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/thebookofcolors b/thebookofcolors index 16cf489..13d7fb1 100755 --- a/thebookofcolors +++ b/thebookofcolors @@ -2,8 +2,23 @@ set -e +random_channel_strength() { + shuf -i 0-255 -n 1 +} + +random_rgb_color_pair() { + red="$(random_channel_strength)" + green="$(random_channel_strength)" + blue="$(random_channel_strength)" + printf "$red;$green;$blue|$((255 - $red));$((255 - green));$((255 - blue))" +} + thebookofcolors() { - printf "\e[4;7;36m" + colors=$(random_rgb_color_pair) + foreground="$(echo $colors | cut -d '|' -f 1)" + background="$(echo $colors | cut -d '|' -f 2)" + printf "\e[38;2;${foreground}m" + printf "\e[48;2;${background}m" if test -z "$1"; then printf "The Book of Colors" else