Skip to content

RGB Colors#

Disclaimer

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

Full Line Text Functions#

rgb(text, red, green, blue) #

Prints full line of custom RGB-colored text.

Parameters:

Name Type Description Default
text str

Text to be printed with color.

required
red int

Number between 0 and 255.

required
green int

Number between 0 and 255.

required
blue int

Number between 0 and 255.

required
Example
1
2
3
from colorist import rgb

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

How it appears in the terminal:

% I want this text in blue RGB colors

bg_rgb(text, red, green, blue) #

Prints full line of text on custom RGB-colored background.

Parameters:

Name Type Description Default
text str

Text to be printed on colored background.

required
red int

Number between 0 and 255.

required
green int

Number between 0 and 255.

required
blue int

Number between 0 and 255.

required
Example
1
2
3
from colorist import bg_rgb

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

How it appears in the terminal:

% I want this background in blue RGB colors

Custom String Styling#

ColorRGB(red, green, blue)#

Class for custom 16-bit RGB foreground text color.

Parameters:

Name Type Description Default
red int

Number between 0 and 255.

required
green int

Number between 0 and 255.

required
blue int

Number between 0 and 255.

required
Example
1
2
3
4
5
from colorist import ColorRGB

dusty_pink = ColorRGB(194, 145, 164)

print(f"I want to use {dusty_pink}DUSTY PINK{dusty_pink.OFF} color inside this paragraph")

How it appears in the terminal:

% I want to use DUSTY PINK color inside this paragraph

BgColorRGB(red, green, blue)#

Class for custom 16-bit RGB background color instances.

Parameters:

Name Type Description Default
red int

Number between 0 and 255.

required
green int

Number between 0 and 255.

required
blue int

Number between 0 and 255.

required
Example
1
2
3
4
5
from colorist import BgColorRGB

bg_steel_blue = BgColorRGB(70, 130, 180)

print(f"I want to use {bg_steel_blue}STEEL BLUE{bg_steel_blue.OFF} background color inside this paragraph")

How it appears in the terminal:

% I want to use STEEL BLUE background color inside this paragraph