generated from thombashi/python-lib-project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathansi_styles.py
executable file
·52 lines (38 loc) · 1.55 KB
/
ansi_styles.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
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
import sys
from tcolorpy import Color, tcolor
def print_truecolor(c: Color) -> None:
end = " "
print(tcolor(c.color_code, bg_color=c), end=end)
print(tcolor(c.color_code, color=c), end=end)
print(tcolor(c.color_code, color=c, styles=["bold"]), end=end)
print(tcolor(c.color_code, color=c, styles=["dim"]), end=end)
print(tcolor(c.color_code, color=c, styles=["italic"]), end=end)
print(tcolor(c.color_code, color=c, styles=["underline"]), end=end)
print(tcolor(c.color_code, color=c, styles=["invert"]), end=end)
print(tcolor(c.color_code, color=c, styles=["strike"]), end=end)
print()
def main() -> int:
step = 32
print(
"bg_color {color} {bold} {dim} {italic} {underline} {invert} {strike}".format( # noqa
color="color",
bold=tcolor("bold", styles=["bold"]),
dim=tcolor("dim", styles=["dim"]),
italic=tcolor("italic", styles=["italic"]),
underline=tcolor("underline", styles=["underline"]),
invert=tcolor("invert", styles=["invert"]),
strike=tcolor("strike", styles=["strike"]),
)
)
for i in range(0, 255, step):
print_truecolor(Color((255, i, 0)))
for i in range(0, 255, step):
print_truecolor(Color((255 - i, 255, 0)))
for i in range(0, 255, step):
print_truecolor(Color((0, 255, i)))
for i in range(0, 255, step):
print_truecolor(Color((0, 255 - i, 255)))
return 0
if __name__ == "__main__":
sys.exit(main())