View Source Ultraviolet.Color.Lab (Ultraviolet v0.1.1)
Functions for working in the CIE Lab color space.
To calculate the lightness value of a color (L), the CIE Lab color space
uses a reference white point. This reference white point defines what is
considered to be "white" in the color space. By default Ultraviolet uses the
D65 reference point.
Possible reference points are:
:d50: Represents the color temperature of daylight at 5000K.:d55: Represents mid-morning or mid-afternoon daylight at 5500K.:d65: Represents average daylight at 6500K (default):a: Represents the color temperature of a typical incandescent light bulb at approximately 2856K.:b: Represents noon daylight with a color temperature of approximately 4874K.:c: Represents average or north sky daylight; it's a theoretical construct, not often used in practical applications.:f2: Represents cool white fluorescent light.:f7: This is a broad-band fluorescent light source with a color temperature of approximately 6500K.:f11: This is a narrow tri-band fluorescent light source with a color temperature of approximately 4000K.:e: Represents an equal energy white point, where all wavelengths in the visible spectrum are equally represented.:icc
Summary
Functions
Converts from an RGB Color struct to a Lab struct.
Generates a new CIE Lab color.
Generates a new CIE Lab color.
Generates a new CIE Lab color.
Converts from CIE Lab to sRGB
Types
Defines the channels in a Lab color.
@type white_point() ::
:d50 | :d55 | :d65 | :a | :b | :c | :f2 | :f7 | :f11 | :e | :icc
Functions
@spec from_rgb(Ultraviolet.Color.t(), list()) :: {:ok, t()}
Converts from an RGB Color struct to a Lab 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, passfalse. Default:2
Generates a new CIE Lab color.
iex>Ultraviolet.Color.Lab.new({65.49, 64.24, -10.65})
{:ok, %Ultraviolet.Color.Lab{l_: 65.49, a_: 64.24, b_: -10.65}}
Generates a new CIE Lab color.
iex>Ultraviolet.Color.Lab.new(65.49, 64.24, -10.65)
{:ok, %Ultraviolet.Color.Lab{l_: 65.49, a_: 64.24, b_: -10.65}}
Generates a new CIE Lab color.
iex>Ultraviolet.Color.Lab.new(65.49, 64.24, -10.65, 0.5)
{:ok, %Ultraviolet.Color.Lab{l_: 65.49, a_: 64.24, b_: -10.65, a: 0.5}}
@spec to_rgb(t(), list()) :: {:ok, Ultraviolet.Color.t()}
Converts from CIE Lab to sRGB
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, passfalse. Default:0