aboutsummaryrefslogtreecommitdiffstats
path: root/python/printcolors.py
blob: cf5044ba0032e131c908b1d912fc172c3e766fe1 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3


# Credit: https://www.geeksforgeeks.org/print-colors-python-terminal/
class colors:
    reset = '\033[0m'
    bold = '\033[01m'
    disable = '\033[02m'
    underline = '\033[04m'
    reverse = '\033[07m'
    strikethrough = '\033[09m'
    invisible = '\033[08m'
    class fg:
        black = '\033[30m'
        red = '\033[31m'
        green = '\033[32m'
        orange = '\033[33m'
        blue = '\033[34m'
        purple = '\033[35m'
        cyan = '\033[36m'
        lightgray = '\033[37m'
        darkgray = '\033[90m'
        lightred = '\033[91m'
        lightgreen = '\033[92m'
        yellow = '\033[93m'
        lightblue = '\033[94m'
        pink = '\033[95m'
        lightcyan = '\033[96m'
    class bg:
        black = '\033[40m'
        red = '\033[41m'
        green = '\033[42m'
        orange = '\033[43m'
        blue = '\033[44m'
        purple = '\033[45m'
        cyan = '\033[46m'
        lightgray = '\033[47m'


if __name__ == '__main__':
    C = colors
    text = 'hello world'

    print(f'{text}')
    print(f'{C.fg.red}{text}{C.reset}')
    print(f'{C.fg.green}{text}{C.reset}')
    print(f'{C.fg.orange}{text}{C.reset}')
    print(f'{C.fg.blue}{text}{C.reset}')
    print(f'{C.fg.purple}{text}{C.reset}')
    print(f'{C.fg.cyan}{text}{C.reset}')
    print(f'{C.fg.lightgray}{text}{C.reset}')
    print(f'{C.fg.darkgray}{text}{C.reset}')
    print(f'{C.fg.lightred}{text}{C.reset}')
    print(f'{C.fg.lightgreen}{text}{C.reset}')
    print(f'{C.fg.yellow}{text}{C.reset}')
    print(f'{C.fg.lightblue}{text}{C.reset}')
    print(f'{C.fg.pink}{text}{C.reset}')
    print(f'{C.fg.lightcyan}{text}{C.reset}')

    print(f'{C.bold}{text}{C.reset}')
    print(f'{C.bold}{C.fg.red}{text}{C.reset}')
    print(f'{C.bold}{C.fg.green}{text}{C.reset}')
    print(f'{C.bold}{C.fg.orange}{text}{C.reset}')
    print(f'{C.bold}{C.fg.blue}{text}{C.reset}')
    print(f'{C.bold}{C.fg.purple}{text}{C.reset}')
    print(f'{C.bold}{C.fg.cyan}{text}{C.reset}')
    print(f'{C.bold}{C.fg.lightgray}{text}{C.reset}')
    print(f'{C.bold}{C.fg.darkgray}{text}{C.reset}')
    print(f'{C.bold}{C.fg.lightred}{text}{C.reset}')
    print(f'{C.bold}{C.fg.lightgreen}{text}{C.reset}')
    print(f'{C.bold}{C.fg.yellow}{text}{C.reset}')
    print(f'{C.bold}{C.fg.lightblue}{text}{C.reset}')
    print(f'{C.bold}{C.fg.pink}{text}{C.reset}')
    print(f'{C.bold}{C.fg.lightcyan}{text}{C.reset}')

    print(f'{C.reverse}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.red}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.green}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.orange}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.blue}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.purple}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.cyan}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.lightgray}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.darkgray}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.lightred}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.lightgreen}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.yellow}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.lightblue}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.pink}{text}{C.reset}')
    print(f'{C.reverse}{C.fg.lightcyan}{text}{C.reset}')