Last active
February 20, 2022 23:11
-
-
Save LucaFilipozzi/178c9bd7d4a74d6189ff56b33ab13495 to your computer and use it in GitHub Desktop.
truecolor and font test
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
#!/usr/bin/env -S gawk -f | |
# based on: | |
# - https://unix.stackexchange.com/a/404415 | |
# - https://gist.github.com/XVilka/8346728 | |
function abs(x) { | |
return x < 0 ? -x : x; | |
} | |
BEGIN { | |
# test visual distinction | |
printf "regular \033[1mbold\033[0m \033[3mitalic\033[0m "; | |
printf "\033[4munderline\033[0m \033[9mstrikethrough\033[0m"; | |
printf "\n"; | |
# test color palette | |
"tput cols" | getline columns | |
for (column = 0; column < columns; column++) { | |
x = column / columns; | |
r = 255 - (255 * x); # negative: 255 to 0 | |
g = 255 - abs(510 * (x - 1/2)); # triangle: 0 to 255 to 0 | |
b = 255 * x; # positive: 0 to 255 | |
printf "\033[48;2;%d;%d;%dm \033[0m", r, g, b; | |
} | |
printf "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment