Skip to content

HSL Colors#

What Are HSL Colors?#

The 24-bit HSL color space covers over 16 million colors, and each color can be defined by three parameters:

  • Hue
  • Saturation
  • Lightness

The model represents color as a cylindrical coordinate system rather than a set of primary color intensities like RGB. It was designed to be more intuitive for humans, as it allows you to change the shade or intensity of a color by adjusting a single numerical value rather than recalculating three different color channels.

Disclaimer

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

Input Parameters#

Each color in HSL is defined as hue, saturation, and lightness with the following allowed values:

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

What Is Hue?#

Hue represents the color wheel position from 0 to 360 degrees. Simply by changing this value, you can easily cover the entire color spectrum:

What Is Saturation?#

Saturation represents the intensity or purity of a color. Higher values indicate more vivid, saturated colors, while lower values indicate more muted or grayish, unsaturated colors. Example:

Example
Saturation 0 10 20 30 40 50 60 70 80 90 100

What Is Lightness?#

Lightness represents the brightness of the color. It ranges from 0 to 100 %, where 0 % is black and 100 % is white. Example:

Example
Lightness 0 10 20 30 40 50 60 70 80 90 100

Full Line 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