Color.HSLuv (Color v0.4.0)

Copy Markdown

HSLuv — a perceptually-uniform alternative to HSL, built on CIELUV.

Reference: https://www.hsluv.org/ (Alexei Boronine, 2015).

HSLuv is a cylindrical reparameterisation of LCHuv where S is rescaled so S = 100 is always the maximum chroma achievable inside the sRGB gamut for the given L and H. Equal steps in S therefore produce perceptually similar saturation steps across the hue circle, unlike plain HSL where equal steps in S mean wildly different perceptual saturation for different hues.

Channels:

  • h ∈ [0, 360) — hue in degrees.

  • s ∈ [0, 100] — saturation (0 = gray, 100 = sRGB gamut edge).

  • l ∈ [0, 100] — lightness.

Summary

Types

t()

An HSLuv colour (Boronine 2015). Hue in degrees [0.0, 360.0), saturation and lightness as percentages [0.0, 100.0]. Built on CIELUV, perceptually uniform.

Functions

Converts an LCHuv color to HSLuv.

Converts a CIE XYZ color to HSLuv via LCHuv.

Converts an HSLuv color to LCHuv.

Converts an HSLuv color to CIE XYZ via LCHuv.

Types

t()

@type t() :: %Color.HSLuv{
  alpha: Color.Types.alpha(),
  h: float() | nil,
  l: float() | nil,
  s: float() | nil
}

An HSLuv colour (Boronine 2015). Hue in degrees [0.0, 360.0), saturation and lightness as percentages [0.0, 100.0]. Built on CIELUV, perceptually uniform.

Functions

from_lchuv(lc_huv)

Converts an LCHuv color to HSLuv.

Arguments

Returns

from_xyz(xyz)

Converts a CIE XYZ color to HSLuv via LCHuv.

to_lchuv(hs_luv)

Converts an HSLuv color to LCHuv.

Arguments

Returns

Examples

iex> {:ok, lch} = Color.HSLuv.to_lchuv(%Color.HSLuv{h: 12.177, s: 100.0, l: 53.237})
iex> {Float.round(lch.l, 2), Float.round(lch.c, 2), Float.round(lch.h, 2)}
{53.24, 179.04, 12.18}

to_xyz(hsluv)

Converts an HSLuv color to CIE XYZ via LCHuv.