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