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

t()

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

t()

@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

from_srgb(srgb)

Converts an sRGB color to HSV.

Arguments

  • srgb is a Color.SRGB struct with unit-range channels.

Returns

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}

from_xyz(xyz)

Converts a CIE XYZ color to HSV via sRGB.

to_srgb(hsv)

Converts an HSV color to sRGB.

Arguments

Returns

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}

to_xyz(hsv)

Converts an HSV color to CIE XYZ via sRGB.