Skip to content

HSL Colors#

What are HSL Colors?#

The 24-bit HSL color model covers over 16 million colors, and each color can be defined as hue, saturation, and lightness:

Parameter Hue Saturation Lightness
Allowed values 0-360 degrees 0-100 % 0-100 %
Description Deegree on the color wheel. Intensity of the color. Brightness of the color.

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#

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
1
2
3
4
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
1
2
3
4
5
6
7
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...
% ... and steel gray colors