allow true color for matrix and rain

This commit is contained in:
fatalerrors
2026-06-02 16:47:58 +02:00
parent 7c14c67ad0
commit c4c52cfb48

View File

@@ -42,6 +42,32 @@ _rain_build_colors()
local base_color="$1"
RAIN_ENGINE_COLORS=()
local use_truecolor=0
_rainbow_supports_truecolor && use_truecolor=1
if (( use_truecolor )); then
# 24-bit gradient from a near-black shade to a vivid hue.
# 20 steps provide smooth depth variation across simultaneous drops.
local steps=20
local r1 g1 b1 r2 g2 b2
case "${base_color}" in
green) r1=0; g1=12; b1=2; r2=50; g2=255; b2=90 ;;
blue) r1=0; g1=5; b1=25; r2=60; g2=140; b2=255 ;;
red) r1=15; g1=0; b1=0; r2=255; g2=40; b2=40 ;;
yellow) r1=25; g1=18; b1=0; r2=255; g2=240; b2=50 ;;
cyan) r1=0; g1=18; b1=18; r2=50; g2=255; b2=240 ;;
*) r1=40; g1=40; b1=45; r2=220; g2=220; b2=255 ;;
esac
local i r g b
for ((i = 0; i < steps; i++)); do
r=$(( r1 + (r2 - r1) * i / (steps - 1) ))
g=$(( g1 + (g2 - g1) * i / (steps - 1) ))
b=$(( b1 + (b2 - b1) * i / (steps - 1) ))
RAIN_ENGINE_COLORS+=("\e[38;2;${r};${g};${b}m")
done
else
# Fallback: 256-colour palettes.
case $base_color in
green)
for i in {22..28} {34..40} {46..48}; do RAIN_ENGINE_COLORS+=("\e[38;5;${i}m"); done ;;
@@ -57,6 +83,7 @@ _rain_build_colors()
RAIN_ENGINE_COLORS=("\e[37m" "\e[37;1m")
for i in {244..255}; do RAIN_ENGINE_COLORS+=("\e[38;5;${i}m"); done ;;
esac
fi
}
_rain_build_chars()