I think coloroma is really simple and everyone should have a chance to learn so I'll be teaching coloroma in Python. [You can run the code below into the repl to see how it looks like!]
from colorama import init init()
If you're not on a windows device
init() will have no difference.
So now you are using ANSI sequences to print color through coloroma!
from colorama import Fore, Back, Style print(Fore.RED + 'red color text') print(Back.BLUE + 'red text with BLUE background') print(Style.DIM + 'and in dim text') print(Style.RESET_ALL) print('back to normal now')
So you would want to add
Fore.RED if you want the text to be red.
You would want to add
Back.BLUE to make the text background blue!
And you can use the
Style.DIM to dim the text.
Finally you can use
Style.RESET_ALL to make it normal again.
You don't have to put these colors, you can put your own!
it's cool isn't it?
Optional Step 3
If you don't want the color to repeatedly you can send requests to turn off the color change, such as this:
from colorama import init init(autoreset=True) print(Fore.RED + 'some red text') print('automatically back to default color again')
So now it will print the first statement with color and not the second one!
Here are the ANSI sequences that coloroma converts:
ESC [ 0 m # reset all (colors and brightness) ESC [ 1 m # bright ESC [ 2 m # dim (looks same as normal brightness) ESC [ 22 m # normal brightness # FOREGROUND: ESC [ 30 m # black ESC [ 31 m # red ESC [ 32 m # green ESC [ 33 m # yellow ESC [ 34 m # blue ESC [ 35 m # magenta ESC [ 36 m # cyan ESC [ 37 m # white ESC [ 39 m # reset # BACKGROUND ESC [ 40 m # black ESC [ 41 m # red ESC [ 42 m # green ESC [ 43 m # yellow ESC [ 44 m # blue ESC [ 45 m # magenta ESC [ 46 m # cyan ESC [ 47 m # white ESC [ 49 m # reset # cursor positioning ESC [ y;x H # position cursor at x across, y down ESC [ y;x f # position cursor at x across, y down ESC [ n A # move cursor n lines up ESC [ n B # move cursor n lines down ESC [ n C # move cursor n characters forward ESC [ n D # move cursor n characters backward # clear the screen ESC [ mode J # clear the screen # clear the line ESC [ mode K # clear the line
If you have any questions or need help you can ask me :)
Hope you all like it!