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

Functions for wokring with the OKLCH color space.

OKLCH is to LCH as OKLab is to Lab.

Uses the :d65 reference illuminant.

Summary

Types

t()

Defines the channels in an OKLCH color.

Functions

Converts from an RGB Color struct to a LCH struct.

Generates a new LCH color

Generates a new OKLCH color object

Generates a new OKLCH color object

Converts from OKLCH to sRGB

Types

@type t() :: %Ultraviolet.Color.OKLCH{
  a: number(),
  c: number(),
  h: number(),
  l: number()
}

Defines the channels in an OKLCH color.

Functions

Link to this function

from_rgb(color, options \\ [])

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

Converts from an RGB Color struct to a LCH struct.

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 LCH color

iex>Ultraviolet.Color.LCH.new({0.5, 0.0, 60})
{:ok, %Ultraviolet.Color.LCH{h: 60, c: 0.0, l: 0.5}}
@spec new(number(), number(), number()) :: {:ok, t()}

Generates a new OKLCH color object

iex>Ultraviolet.Color.OKLCH.new(0.5, 0.0, 60)
{:ok, %Ultraviolet.Color.OKLCH{h: 60, c: 0.0, l: 0.5}}
@spec new(number(), number(), number(), number()) :: {:ok, t()}

Generates a new OKLCH color object

iex>Ultraviolet.Color.OKLCH.new(0.5, 0.0, 60, 0.5)
{:ok, %Ultraviolet.Color.OKLCH{h: 60, c: 0.0, l: 0.5, a: 0.5}}
Link to this function

to_rgb(lch, options \\ [])

View Source

Converts from OKLCH 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