Color.HPLuv (Color v0.4.0)

Copy Markdown

HPLuv — the "pastel" sibling of HSLuv.

Where HSLuv lets S = 100 reach the full sRGB gamut boundary (which gives different chromas at different hues), HPLuv rescales so that S = 100 is the largest chroma achievable at the given L at ALL hues. This means HPLuv cannot represent the most saturated sRGB colours at any given lightness, but any HPLuv(h, 100, l) triple is achromatically consistent across hues — useful for "pastel" palettes.

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

Summary

Types

t()

An HPLuv colour. Like HSLuv but with the chroma component clipped to the largest pastel-friendly chroma at the given lightness. Hue in degrees [0.0, 360.0), saturation and lightness as percentages [0.0, 100.0].

Functions

Converts an LCHuv color to HPLuv.

Converts a CIE XYZ color to HPLuv via LCHuv.

Converts an HPLuv color to LCHuv.

Converts an HPLuv color to CIE XYZ via LCHuv.

Types

t()

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

An HPLuv colour. Like HSLuv but with the chroma component clipped to the largest pastel-friendly chroma at the given lightness. Hue in degrees [0.0, 360.0), saturation and lightness as percentages [0.0, 100.0].

Functions

from_lchuv(lc_huv)

Converts an LCHuv color to HPLuv.

from_xyz(xyz)

Converts a CIE XYZ color to HPLuv via LCHuv.

to_lchuv(hp_luv)

Converts an HPLuv color to LCHuv.

Arguments

Returns

Examples

iex> {:ok, lch} = Color.HPLuv.to_lchuv(%Color.HPLuv{h: 0.0, s: 0.0, l: 50.0})
iex> {Float.round(lch.l, 2), Float.round(lch.c, 2)}
{50.0, 0.0}

to_xyz(hpluv)

Converts an HPLuv color to CIE XYZ via LCHuv.