How to Print Foreground Text Colors#
Introduction#
When you want to print colored text in the terminal, Colorist offers two ways of doing so:
- Full text functions: Print a full line of colored text with the
green()
,yellow()
,red()
, etc. functions. - Custom string styling: Mix colors to any part of a string with the
Color
andBrightColor
classes.
Print Line of Colored Text#
How to print a full line of colored text in the terminal:
Python | |
---|---|
How it appears in the terminal:
% This is GREEN!
% This is YELLOW!
% This is RED!
Print Mixed Colors in Text#
How to customize colors inside a paragraph and print it in the terminal:
Python | |
---|---|
How it appears in the terminal:
% I want red color inside this paragraph
% Both green and yellow are nice colors
Tip
Remember to turn off a color with Color.OFF
or BrightColor.OFF
every time you want to revert back to the default terminal text style. Otherwise, the effect may spill over and into other terminal messages.
Bright Colors#
Most terminals support bright colors that stand more out:
Python | |
---|---|
How it appears in the terminal:
% Put cyan inside this paragraph
Refer to the documentation for a complete list of full line text color functions and custom string styling.
Cheat Sheets#
Normal Colors#
Color | Color Code | Example |
---|---|---|
Color.GREEN | This is GREEN! | |
Color.YELLOW | This is YELLOW! | |
Color.RED | This is RED! | |
Color.MAGENTA | This is MAGENTA! | |
Color.BLUE | This is BLUE! | |
Color.CYAN | This is CYAN! | |
Color.WHITE | This is WHITE! | |
Color.BLACK | This is BLACK! | |
- | Color.DEFAULT | - |
- | Color.OFF | - |
Bright Colors#
Color | Color Code | Example |
---|---|---|
BrightColor.GREEN | This is BRIGHT GREEN! | |
BrightColor.YELLOW | This is BRIGHT YELLOW! | |
BrightColor.RED | This is BRIGHT RED! | |
BrightColor.MAGENTA | This is BRIGHT MAGENTA! | |
BrightColor.BLUE | This is BRIGHT BLUE! | |
BrightColor.CYAN | This is BRIGHT CYAN! | |
BrightColor.WHITE | This is BRIGHT WHITE! | |
BrightColor.BLACK | This is BRIGHT BLACK! | |
- | BrightColor.DEFAULT | - |
- | BrightColor.OFF | - |