aest 0.1.0
Collection of C++ utility libraries
Loading...
Searching...
No Matches
aest::colors::OKLab Class Referencefinalexport

A color in OKLab, the perceptual space by Björn Ottosson. More...

Inheritance diagram for aest::colors::OKLab:
aest::colors::ColorBase< OKLab >

Public Member Functions

constexpr OKLab ()
 Default constructor initializes the color to opaque black (0, 0, 0, 1).
constexpr OKLab (const float l, const float a, const float b, const float alpha=1.0f)
 Construct a color from OKLab values and alpha.
Color Channels
constexpr float lightness () const noexcept
 Get the perceived lightness, 1 being D65 white.
constexpr float a () const noexcept
 Get the green-red axis, negative toward green.
constexpr float b () const noexcept
 Get the blue-yellow axis, negative toward blue.
Public Member Functions inherited from aest::colors::ColorBase< OKLab >
constexpr float alpha () const noexcept
 Get the alpha channel value in the 0-1 range.
constexpr float ch1 () const noexcept
 Get the first channel value.
constexpr float ch2 () const noexcept
 Get the second channel value.
constexpr float ch3 () const noexcept
 Get the third channel value.
constexpr OKLab opacity (const float alpha) const
 Returns a new color with the same channels and the specified alpha value.

Static Public Attributes

static constexpr std::string_view TYPE = "OKLab"
 Color space name, used by the std::formatter specialization.

Additional Inherited Members

Public Attributes inherited from aest::colors::ColorBase< OKLab >
friend Derived
 Lets the derived color reach the private constructor and channels.

Detailed Description

A color in OKLab, the perceptual space by Björn Ottosson.

L is the perceived lightness, 0 for black and 1 for the D65 white; a runs from green to red and b from blue to yellow, both 0 for grays. Equal distances look about equally different, which makes OKLab the space for color differences and for gradients that keep their lightness even. Channels are not clamped: HDR colors have L above 1, and colors outside any display's gamut are valid until converted to it.

See also
Ottosson 2020, CSS Color 4

Definition at line 55 of file OkLab.cppm.

Constructor & Destructor Documentation

◆ OKLab() [1/2]

aest::colors::OKLab::OKLab ( )
inlineconstexpr

Default constructor initializes the color to opaque black (0, 0, 0, 1).

Definition at line 62 of file OkLab.cppm.

◆ OKLab() [2/2]

aest::colors::OKLab::OKLab ( const float l,
const float a,
const float b,
const float alpha = 1.0f )
inlineconstexpr

Construct a color from OKLab values and alpha.

Parameters
[in]lPerceived lightness, 1 being D65 white
[in]aGreen-red axis
[in]bBlue-yellow axis
[in]alphaAlpha channel value (default 1.0)
Precondition
Every channel is finite: NaN and infinities are undefined behavior.

Definition at line 74 of file OkLab.cppm.

Member Function Documentation

◆ a()

float aest::colors::OKLab::a ( ) const
inlinenodiscardconstexprnoexcept

Get the green-red axis, negative toward green.

Returns
The a channel

Definition at line 90 of file OkLab.cppm.

◆ b()

float aest::colors::OKLab::b ( ) const
inlinenodiscardconstexprnoexcept

Get the blue-yellow axis, negative toward blue.

Returns
The b channel

Definition at line 96 of file OkLab.cppm.

◆ lightness()

float aest::colors::OKLab::lightness ( ) const
inlinenodiscardconstexprnoexcept

Get the perceived lightness, 1 being D65 white.

Returns
The L channel

Definition at line 84 of file OkLab.cppm.

Member Data Documentation

◆ TYPE

std::string_view aest::colors::OKLab::TYPE = "OKLab"
staticconstexpr

Color space name, used by the std::formatter specialization.

Definition at line 59 of file OkLab.cppm.


The documentation for this class was generated from the following file: