Skip to content

Instantly share code, notes, and snippets.

@LucaFilipozzi
Last active February 20, 2022 23:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucaFilipozzi/178c9bd7d4a74d6189ff56b33ab13495 to your computer and use it in GitHub Desktop.
Save LucaFilipozzi/178c9bd7d4a74d6189ff56b33ab13495 to your computer and use it in GitHub Desktop.
truecolor and font test
#!/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