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
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
Defines the channels in an OKLCH color.
Functions
@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, passfalse
. Default:2
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 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}}
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}}
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, passfalse
. Default:0