Skip to content

OKLCH Colors#

Disclaimer

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

Full Line Text Functions#

oklch(text, lightness, chroma, hue) #

Prints full line of custom OKLCH-colored text.

Parameters:

Name Type Description Default
text str

Text to be printed on colored background.

required
lightness float

Lightness value between 0.0 and 1.0 where 0.0 is black and 1.0 is white.

required
chroma float

Chroma value between 0.0 and 0.4.

required
hue float

Number between 0 and 360 degrees.

required
Example
1
2
3
from colorist import oklch

oklch("I want this text in orange OKLCH colors", 0.71, 0.1, 31)

How it appears in the terminal:

% I want this text in orange OKLCH colors

bg_oklch(text, lightness, chroma, hue) #

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

Parameters:

Name Type Description Default
text str

Text to be printed on colored background.

required
lightness float

Lightness value between 0.0 and 1.0 where 0.0 is black and 1.0 is white.

required
chroma float

Chroma value between 0.0 and 0.4.

required
hue float

Number between 0 and 360 degrees.

required
Example
1
2
3
from colorist import bg_oklch

bg_oklch("I want this background in green OKLCH colors", 0.54, 0.15, 141)

How it appears in the terminal:

% I want this background in green OKLCH colors

Custom String Styling#

ColorOKLCH(lightness, chroma, hue)#

Class for custom OKLCH foreground text color.

Parameters:

Name Type Description Default
lightness float

Lightness value between 0.0 and 1.0 where 0.0 is black and 1.0 is white.

required
chroma float

Chroma value between 0.0 and 0.4.

required
hue float

Number between 0 and 360 degrees.

required
Example
1
2
3
4
5
from colorist import ColorOKLCH

dusty_orange = ColorOKLCH(0.71, 0.1, 31)

print(f"I want to use {dusty_orange}DUSTY ORANGE{dusty_orange.OFF} foreground color inside this paragraph")

How it appears in the terminal:

% I want to use DUSTY ORANGE foreground color inside this paragraph

BgColorOKLCH(lightness, chroma, hue)#

Class for custom OKLCH background color.

Parameters:

Name Type Description Default
lightness float

Lightness value between 0.0 and 1.0 where 0.0 is black and 1.0 is white.

required
chroma float

Chroma value between 0.0 and 0.4.

required
hue float

Number between 0 and 360 degrees.

required
Example
1
2
3
4
5
from colorist import BgColorOKLCH

bg_basil_green = BgColorOKLCH(0.54, 0.15, 141)

print(f"I want to use {bg_basil_green}BASIL GREEN{bg_basil_green.OFF} background color inside this paragraph")

How it appears in the terminal:

% I want to use BASIL GREEN background color inside this paragraph