Qualpal
Repositories

qualpal::colors::HSL

C++ · cpp · 4.1.0

class qualpal::colors::HSL

HSL (Hue, Saturation, Lightness) color representation.

Represents a color in the HSL color space:

  • Hue: [0, 360) degrees (0 = red, 120 = green, 240 = blue)

  • Saturation: [0, 1] (0 = gray, 1 = fully saturated)

  • Lightness: [0, 1] (0 = black, 1 = white)

Provides conversion constructors for RGB, XYZ, Lab, and LCHab color spaces.

HSL orange(30, 1.0, 0.5);    // Pure orange
HSL gray(0, 0.0, 0.5);       // Medium gray
HSL from_rgb(RGB(0.5, 0.2, 0.7));

See also

RGB, XYZ, Lab, LCHab for conversions.

Methods

HSL

HSL

HSL()

Default constructor initializes HSL to black (0,0,0).

HSL

HSL(const LCHab & lch)

Construct HSL from LCHab color.

Parameters

lch

LCHab color to convert from

HSL

HSL(const Lab & lab)

Construct HSL from Lab color.

Parameters

lab

Lab color to convert from

HSL

HSL(const RGB & rgb)

Construct HSL from RGB color.

Parameters

rgb

RGB color to convert from

HSL

HSL(const XYZ & xyz)

Construct HSL from XYZ color.

Parameters

xyz

XYZ color to convert from

HSL

HSL(const double h, const double s, const double l)

Construct HSL from component values.

Parameters

h

Hue in degrees [0,360)

s

Saturation [0,1]

l

Lightness [0,1]

h

inline double h() const

Get hue in degrees [0,360).

l

inline double l() const

Get lightness [0,1].

operator!=

inline bool operator!=(const HSL & other) const

Inequality operator for HSL colors.

Parameters

other

Other HSL color to compare with

Returns

true if HSL colors are not equal, false otherwise

operator==

inline bool operator==(const HSL & other) const

Equality operator for HSL colors.

Parameters

other

Other HSL color to compare with

Returns

true if both HSL colors are equal, false otherwise

s

inline double s() const

Get saturation [0,1].