Skip to content

HSL Colors#

Disclaimer

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

Full Text Functions#

You can output colors in HSL with the hsl() and bg_hsl() methods. The value for hue can be between 0-360 degrees, while saturation and lightness can be a percentage between 0-100%:

Example:

Python
from colorist import hsl, bg_hsl

hsl("I want this text in green HSL colors", 120, 50, 50)
bg_hsl("I want this background in green HSL colors", 120, 50, 50)

How it appears in the terminal:

% I want this text in green HSL colors
% I want this background in green HSL colors

Custom String Styling#

Or customize the styling of text and background with the ColorHSL() and BgColorHSL() classes:

Python
from colorist import ColorHSL, BgColorHSL

mustard_green = ColorHSL(60, 56, 43)
bg_steel_gray = BgColorHSL(190, 2, 49)

print(f"I want to use {mustard_green}mustard green{mustard_green.OFF}...")
print(f"... and {bg_steel_gray}steel gray{bg_steel_gray.OFF} colors")

How it appears in the terminal:

% I want to use mustard green...
% ... steel gray colors