Skip to content

RGB Colors#

What are RGB Colors?#

The 24-bit RGB color model covers over 16 million colors, and each color can be defined as red, green, and blue:

Channel Red Green Blue
Allowed values 0-255 0-255 0-255

Disclaimer

Not all terminals support 24-bit colors in RGB, HSL, or Hex. If your terminal does support such advanced colors, read on.

Full Text Functions#

Try the rgb() and bg_rgb() methods for a full line of colored text. The values for red, green, blue can be an integer between 0-255.

Example:

Python
1
2
3
4
from colorist import rgb, bg_rgb

rgb("I want this text in blue RGB colors", 0, 128, 255)
bg_rgb("I want this background in blue RGB colors", 0, 128, 255)

How it appears in the terminal:

% I want this text in blue RGB colors
% I want this background in blue RGB colors

Custom String Styling#

Or customize the styling of text and background with the ColorRGB() and BgColorRGB() classes:

Python
1
2
3
4
5
6
7
from colorist import ColorRGB, BgColorRGB

dusty_pink = ColorRGB(194, 145, 164)
bg_steel_blue = BgColorRGB(70, 130, 180)

print(f"I want to use {dusty_pink}dusty pink{dusty_pink.OFF}...")
print(f"... and {bg_steel_blue}steel blue{bg_steel_blue.OFF} colors")

How it appears in the terminal:

% I want to use dusty pink...
% ... and steel blue colors