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

Functions for working in the LCH / HCL colorspace.

Summary

Types

t()

Defines the channels in a LCH color.

Functions

Converts from an RGB Color struct to a LCH struct.

Generates a new LCH color

Generates a new LCH color

Generates a new LCH color

Converts from LCH to an RGB Color struct

Types

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

Defines the channels in a LCH 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

  • :reference: the CIE Lab white reference point. Default: :d65
  • :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}}

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}}

Generates a new LCH color

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

to_rgb(lch, options \\ [])

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

Converts from LCH to an RGB Color struct

Options

  • :reference: the CIE Lab white reference point. Default: :d65
  • :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