Last active
May 6, 2026 19:57
-
-
Save MatthewLymer/9e328942838534c76eb3cadd477bc75a to your computer and use it in GitHub Desktop.
Bash Gradient
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| width=80 | |
| echo 'Truecolor gradient:' | |
| for ((i=0; i<width; i++)); do | |
| r=$((255 * i / width)) | |
| b=$(( 255 * (width - i) / width )) | |
| mid=$((2 * i - width)) | |
| if ((mid < 0)); then mid=$((-mid)); fi | |
| g=$(( 255 * (width - mid) / width )) | |
| printf '\033[48;2;%d;%d;%dm ' "$r" "$g" "$b" | |
| done | |
| printf '\033[0m\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment