26 {0.8190224379967030, 0.3619062600528904, -0.1288737815209879},
27 {0.0329836539323885, 0.9292868615863434, 0.0361446663506424},
28 {0.0481771893596242, 0.2642395317527308, 0.6335478284694309},
33 {0.2104542683093140, 0.7936177747023054, -0.0040720430116193},
34 {1.9779985324311684, -2.4285922420485799, 0.4505937096174110},
35 {0.0259040424655478, 0.7827717124575296, -0.8086757549230774},
59 static constexpr std::string_view
TYPE =
"OKLab";
74 constexpr OKLab(
const float l,
const float a,
const float b,
const float alpha = 1.0f)
84 [[nodiscard]]
constexpr float lightness() const noexcept {
return _ch1; }
90 [[nodiscard]]
constexpr float a() const noexcept {
return _ch2; }
96 [[nodiscard]]
constexpr float b() const noexcept {
return _ch3; }
114 static constexpr std::string_view
TYPE =
"OKLCH";
129 constexpr OKLCH(
const float l,
const float c,
const float h,
const float alpha = 1.0f)
145 [[nodiscard]]
constexpr float chroma() const noexcept {
return _ch2; }
151 [[nodiscard]]
constexpr float hue() const noexcept {
return _ch3; }
186 return OKLab{
static_cast<float>(lab[0]),
static_cast<float>(lab[1]),
187 static_cast<float>(lab[2]), color.
alpha()};
205 roots[1] * roots[1] * roots[1],
206 roots[2] * roots[2] * roots[2]});
207 return XYZ{
static_cast<float>(xyz[0]),
static_cast<float>(xyz[1]),
208 static_cast<float>(xyz[2]), color.
alpha()};
224 const double a = color.
a();
225 const double b = color.
b();
226 return OKLCH{color.
lightness(),
static_cast<float>(std::hypot(a, b)),
243 const double chroma = color.
chroma();
245 return OKLab{color.
lightness(),
static_cast<float>(chroma * std::cos(angle)),
246 static_cast<float>(chroma * std::sin(angle)), color.
alpha()};
constexpr float wrap_hue(const float hue)
Wrap a hue angle to the [0, 360) range.
constexpr float non_negative(const float value)
Clamp a floating-point value to be non-negative, leaving it unbounded above.
constexpr double DEGREES_PER_RADIAN
Degrees in a radian.
blas::Vector< double, 3 > Vector3
A column of three values, such as XYZ or linear RGB channels.
blas::Matrix< double, 3, 3 > Matrix3
A 3x3 matrix, stored as three rows.
constexpr Vector< T, Rows > multiply(const Matrix< T, Rows, Columns > &matrix, const Vector< T, Columns > &vector)
Multiplies a matrix by a column vector.
constexpr Matrix< T, 3, 3 > inverse(const Matrix< T, 3, 3 > &matrix)
Inverts a 3x3 matrix through its adjugate.
constexpr Matrix3 OKLAB_TO_LMS
Matrix from OKLab back to the cube roots of LMS.
constexpr Matrix3 XYZ_TO_LMS
Matrix from XYZ, D65, to the LMS cone responses of OKLab, as recomputed by CSS Color 4 so that D65 wh...
constexpr Matrix3 LMS_TO_XYZ
Matrix from LMS back to XYZ, D65.
constexpr Matrix3 LMS_TO_OKLAB
Matrix from the cube roots of LMS to OKLab, from CSS Color 4.
A color in OKLCH: OKLab in polar form, as lightness, chroma and hue.
constexpr OKLCH()
Default constructor initializes the color to opaque black (0, 0, 0, 1).
constexpr float lightness() const noexcept
Get the perceived lightness, 1 being D65 white.
static constexpr std::string_view TYPE
Color space name, used by the std::formatter specialization.
constexpr OKLCH(const float l, const float c, const float h, const float alpha=1.0f)
Construct a color from OKLCH values and alpha.
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.
A color in OKLab, the perceptual space by Björn Ottosson.
static constexpr std::string_view TYPE
Color space name, used by the std::formatter specialization.
constexpr float a() const noexcept
Get the green-red axis, negative toward green.
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.
constexpr float lightness() const noexcept
Get the perceived lightness, 1 being D65 white.
constexpr float b() const noexcept
Get the blue-yellow axis, negative toward blue.
A color in the CIE 1931 XYZ color space, relative to the D65 white point.
constexpr float x() const noexcept
Get the X tristimulus value.
constexpr float z() const noexcept
Get the Z tristimulus value.
constexpr float y() const noexcept
Get the Y tristimulus value, the relative luminance.
constexpr ColorBase(const float alpha, const float channel1, const float channel2, const float channel3)
constexpr float alpha() const noexcept
static OKLCH convert(const OKLab &color)
Converts color to OKLCH.
static OKLab convert(const OKLCH &color)
Converts color to OKLab.
static OKLab convert(const XYZ &color)
Converts color to OKLab: LMS, cube root, then the OKLab matrix.
static constexpr XYZ convert(const OKLab &color)
Converts color to XYZ: the inverse matrix, cube, then back from LMS.
Converts colors from one color space to another.
OKLab type
The parent space.
XYZ type
The parent space.
Names the color space a space converts through, joining every space in one tree.