View Source Ultraviolet.Color.OKLab (Ultraviolet v0.1.1)

Functions for working with the OKLab color space.

Uses the :d65 reference illuminant.

Summary

Types

t()

Defines the channels in an OKLab color.

Functions

Converts from sRGB to OKLab.

Generates a new OKLab color

Generates a new OKLab color

Generates a new OKLab color

Converts from OKLab to sRGB.

Types

@type t() :: %Ultraviolet.Color.OKLab{
  a: number(),
  a_: number(),
  b_: number(),
  l_: number()
}

Defines the channels in an OKLab color.

Functions

Link to this function

from_rgb(color, options \\ [])

View Source
@spec from_rgb(Ultraviolet.Color.t(), list()) :: {:ok, t()}

Converts from sRGB to OKLab.

Options

  • :round: an integer if rounding L, a, and b channel values to N decimal places is desired; if no rounding is desired, pass false. Default: 2
@spec new(tuple() | [number()] | map() | [...]) :: {:ok, t()}

Generates a new OKLab color

iex>Ultraviolet.Color.OKLab.new({0.5, 0.0, 0.0})
{:ok, %Ultraviolet.Color.OKLab{l_: 0.5, a_: 0.0, b_: 0.0}}
@spec new(number(), number(), number()) :: {:ok, t()}

Generates a new OKLab color

iex>Ultraviolet.Color.OKLab.new(0.5, 0.0, 0.0)
{:ok, %Ultraviolet.Color.OKLab{l_: 0.5, a_: 0.0, b_: 0.0}}
@spec new(number(), number(), number(), number()) :: {:ok, t()}

Generates a new OKLab color

iex>Ultraviolet.Color.OKLab.new(0.5, 0.0, 0.0, 0.5)
{:ok, %Ultraviolet.Color.OKLab{l_: 0.5, a_: 0.0, b_: 0.0, a: 0.5}}
Link to this function

to_rgb(oklab, options \\ [])

View Source
@spec to_rgb(t(), list()) :: {:ok, Ultraviolet.Color.t()}

Converts from OKLab to sRGB.

Options

  • :round: an integer if rounding r, g, and b channel values to N decimal places is desired; if no rounding is desired, pass false. Default: 0