Struct Oklch
Stores a color as Oklab lightness, chroma, and hue.
struct Oklch(T)
if (is(T == float) || is(T == double));
Use OKLCH when editing or interpolating perceptual lightness, colorfulness,
or hue directly. Lightness and chroma are raw mathematical values; chroma is
not silently clamped or canonicalized, and hue preserves its raw degree
value.
T must be float or double. The natural .init value contains
NaNs and is not a usable color.
Fields
| Name | Type | Description |
c
|
T | Chroma component.
|
h
|
OklabHue!T | Raw, degree-based Oklab-family hue.
|
l
|
T | Perceptual lightness component.
|
Properties
| Name | Type | Description |
canonicalized[get]
|
Oklch | Returns an equivalent representation with non-negative chroma.
|
isAchromatic[get]
|
bool | Reports whether chroma is exactly zero.
|
Methods
| Name | Description |
isNearAchromatic
(epsilon)
|
Tests chroma against a caller-selected near-achromatic threshold.
|
Aliases
| Name | Description |
Scalar
|
Scalar component type.
|
Example
const color = Oklchd(
0.55,
0.12,
OklabHued.fromDegrees(250.0)
);
assert(color.l == 0.55);
assert(color.c == 0.12);
assert(color.h.rawDegrees == 250.0);