Color.HSL
(Color v0.4.0)
Copy Markdown
HSL color space — hue, saturation, lightness.
All channels are unit floats in [0, 1]. HSL is a non-linear
reparameterisation of sRGB, so conversions to any CIE space route
through Color.SRGB.
Summary
Types
A non-linear HSL reparameterisation of sRGB. All three components
are unit floats: h in [0.0, 1.0] (one full turn), s and l
in [0.0, 1.0].
Functions
Converts an sRGB color to HSL.
Converts a CIE XYZ color to HSL via sRGB.
Converts an HSL color to sRGB.
Converts an HSL color to CIE XYZ via sRGB.
Types
@type t() :: %Color.HSL{ alpha: Color.Types.alpha(), h: float() | nil, l: float() | nil, s: float() | nil }
A non-linear HSL reparameterisation of sRGB. All three components
are unit floats: h in [0.0, 1.0] (one full turn), s and l
in [0.0, 1.0].
Functions
Converts an sRGB color to HSL.
Arguments
srgbis aColor.SRGBstruct with unit-range channels.
Returns
- A
Color.HSLstruct.
Examples
iex> {:ok, hsl} = Color.HSL.from_srgb(%Color.SRGB{r: 1.0, g: 0.0, b: 0.0})
iex> {hsl.h, hsl.s, hsl.l}
{0.0, 1.0, 0.5}
Converts a CIE XYZ color to HSL via sRGB.
Arguments
xyzis aColor.XYZstruct.
Returns
- A
Color.HSLstruct.
Converts an HSL color to sRGB.
Arguments
hslis aColor.HSLstruct.
Returns
- A
Color.SRGBstruct with unit-range channels.
Examples
iex> {:ok, srgb} = Color.HSL.to_srgb(%Color.HSL{h: 0.0, s: 1.0, l: 0.5})
iex> {srgb.r, srgb.g, srgb.b}
{1.0, 0.0, 0.0}
Converts an HSL color to CIE XYZ via sRGB.
Arguments
hslis aColor.HSLstruct.
Returns
- A
Color.XYZstruct.