Created
February 9, 2022 07:04
-
-
Save nick3499/a032f94e9d7082ad7c4737d3180529dd to your computer and use it in GitHub Desktop.
Print Web-safe Color Table: Python3
This file contains 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
#!/bin/python3 | |
'''Print Web-safe color table.''' | |
def print_table(): | |
'''Print table.''' | |
ws_rgb = ['0', '51', '102', '153', '255'] | |
print('\x1b[31m Web-safe Color Table\x1b[0m') | |
for r_num in ws_rgb: | |
for g_num in ws_rgb: | |
for b_num in ws_rgb: | |
r_hex = f'{hex(int(r_num))[2:]:>02}' | |
g_hex = f'{hex(int(g_num))[2:]:>02}' | |
b_hex = f'{hex(int(b_num))[2:]:>02}' | |
print(f'\x1b[48;2;{r_num};{g_num};{b_num}m \x1b[0m \ | |
#{r_hex}{g_hex}{b_hex} rgb({r_num}, {g_num}, {b_num})') | |
if __name__ == '__main__': | |
print_table() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment