-
Notifications
You must be signed in to change notification settings - Fork 2
/
colors.py
40 lines (32 loc) · 1.16 KB
/
colors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 256-colored backgrounds work too:
# The 8-bit colours are arranged like so:
#
# 0x00-0x07: standard colors (same as the 4-bit colours)
# 0x08-0x0F: high intensity colors
# 0x10-0xE7: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
# 0xE8-0xFF: grayscale from black to white in 24 steps
# \033[38;2;<r>;<g>;<b>m #Select RGB foreground color
# \033[48;2;<r>;<g>;<b>m #Select RGB background color
import sys
# foregbround colors on white
for i in range(0, 32):
sys.stdout.write(u"\u001b[48;2;255;255;255m"); # white bg
for j in range(0, 8):
code = str(i * 8 + j)
sys.stdout.write(u"\u001b[38;5;" + code + "m " + code.ljust(4))
print(u"\u001b[0m")
print("\n")
# foregbround colors on black
for i in range(0, 32):
sys.stdout.write(u"\u001b[40m")
for j in range(0, 8):
code = str(i * 8 + j)
sys.stdout.write(u"\u001b[38;5;" + code + "m " + code.ljust(4))
print(u"\u001b[0m")
print("\n")
# background colors
for i in range(0, 32):
for j in range(0, 8):
code = str(i * 8 + j)
sys.stdout.write(u"\u001b[48;5;" + code + "m " + code.ljust(4))
print(u"\u001b[0m")