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

A color in OKLCH: OKLab in polar form, as lightness, chroma and hue. More...

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

Public Member Functions

constexpr OKLCH ()
 Default constructor initializes the color to opaque black (0, 0, 0, 1).
constexpr OKLCH (const float l, const float c, const float h, const float alpha=1.0f)
 Construct a color from OKLCH values and alpha.
Color Channels
constexpr float lightness () const noexcept
 Get the perceived lightness, 1 being D65 white.
constexpr float chroma () const noexcept
 Get the chroma, the distance from gray.
constexpr float hue () const noexcept
 Get the hue angle in the 0-360 range.
Public Member Functions inherited from aest::colors::ColorBase< OKLCH >
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 OKLCH 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 = "OKLCH"
 Color space name, used by the std::formatter specialization.

Additional Inherited Members

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

Detailed Description

A color in OKLCH: OKLab in polar form, as lightness, chroma and hue.

Chroma is the distance from gray and hue the angle around it, so changing one leaves the other two and the perceived lightness alone, unlike HSL. The hue is wrapped to the [0, 360) range and chroma clamped at 0; for grays, whose chroma is 0, the hue has no meaning. Lightness is not clamped.

See also
Ottosson 2020

Definition at line 110 of file OkLab.cppm.

Constructor & Destructor Documentation

◆ OKLCH() [1/2]

aest::colors::OKLCH::OKLCH ( )
inlineconstexpr

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

Definition at line 117 of file OkLab.cppm.

◆ OKLCH() [2/2]

aest::colors::OKLCH::OKLCH ( const float l,
const float c,
const float h,
const float alpha = 1.0f )
inlineconstexpr

Construct a color from OKLCH values and alpha.

Parameters
[in]lPerceived lightness, 1 being D65 white
[in]cChroma, clamped at 0
[in]hHue in degrees, wrapped to the 0-360 range
[in]alphaAlpha channel value (default 1.0)
Precondition
Every channel is finite: NaN and infinities are undefined behavior.

Definition at line 129 of file OkLab.cppm.

Member Function Documentation

◆ chroma()

float aest::colors::OKLCH::chroma ( ) const
inlinenodiscardconstexprnoexcept

Get the chroma, the distance from gray.

Returns
The chroma, 0 or greater

Definition at line 145 of file OkLab.cppm.

◆ hue()

float aest::colors::OKLCH::hue ( ) const
inlinenodiscardconstexprnoexcept

Get the hue angle in the 0-360 range.

Returns
The hue in degrees

Definition at line 151 of file OkLab.cppm.

◆ lightness()

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

Get the perceived lightness, 1 being D65 white.

Returns
The L channel

Definition at line 139 of file OkLab.cppm.

Member Data Documentation

◆ TYPE

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

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

Definition at line 114 of file OkLab.cppm.


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