Hex Colors#
Disclaimer
Not all terminals support RGB, HSL, or Hex colors. If your terminal does support such advanced colors, read on.
Full Text Functions#
Try the hex()
and bg_hex()
methods for a full line of colored text. Allowed Hex values are, for instance, #00aaff
or #0af
, alternatively without the hash sign as 00aaff
or 0af
.
Example:
Python
from colorist import hex, bg_hex
hex("I want this text in coral Hex colors", "#ff7f50")
bg_hex("I want this background in coral Hex colors", "#ff7f50")
How it appears in the terminal:
% I want this text in coral Hex colors
% I want this background in coral Hex colors
Custom String Styling#
Or customize the styling of text and background with the ColorHex()
and BgColorHex()
classes:
Python
from colorist import ColorHex, BgColorHex
watermelon_red = ColorHex("#ff5733")
bg_mint_green = BgColorHex("#99ff99")
print(f"I want to use {watermelon_red}watermelon red{watermelon_red.OFF}...")
print(f"... and {bg_mint_green}mint green{bg_mint_green.OFF} colors")
How it appears in the terminal:
% I want to use watermelon red...
% ... mint green colors