Oklch struct
Namespace: Arlecchino.Rendering.Colors · Assembly: Arlecchino.Core
A color as lightness, chroma and hue, in the space where those three come apart. Moving the lightness of an Rgb here leaves the color recognizably itself, which moving it in HSL does not.
public readonly struct Oklch : IEquatable<Oklch>
Implements IEquatable<T><Oklch>
Constructors
| Member | Summary |
|---|---|
Oklch(double, double, double) | A color as lightness, chroma and hue, in the space where those three come apart. Moving the lightness of an Rgb here leaves the color recognizably itself, which moving it in HSL does not. |
Properties
| Member | Summary |
|---|---|
Chroma | How far the color stands from gray, up to about 0.4 within sRGB. |
FitsScreen | Whether sRGB holds this color, or whether showing it would want channels it has not got. |
Hue | Degrees around the wheel. |
Lightness | Perceived lightness, 0 for black and 1 for white. |
Methods
| Member | Summary |
|---|---|
Deconstruct(out double, out double, out double) | |
Of(Rgb) | Splits a color into the three. |
ToRgb() | The color as the screen shows it, trimmed to sRGB on the way. |
ToString() | Writes the three parts out, which is what a log of a derived palette holds. |
Trimmed() | The same lightness and hue with the chroma cut back to the most sRGB holds. Cutting the chroma keeps the hue, where clamping the channels turns a color that is too vivid into a different color. |
Constructors in detail
Oklch(double, double, double)
public Oklch(double Lightness, double Chroma, double Hue);
A color as lightness, chroma and hue, in the space where those three come apart. Moving the lightness of an Rgb here leaves the color recognizably itself, which moving it in HSL does not.
Parameters
| Name | Type | Description |
|---|---|---|
Lightness | double | Perceived lightness, 0 for black and 1 for white. |
Chroma | double | How far the color stands from gray, up to about 0.4 within sRGB. |
Hue | double | Degrees around the wheel. |
Properties in detail
Chroma
public double Chroma { get; init; }
How far the color stands from gray, up to about 0.4 within sRGB.
Type double
FitsScreen
public bool FitsScreen { get; }
Whether sRGB holds this color, or whether showing it would want channels it has not got.
Type bool
Hue
public double Hue { get; init; }
Degrees around the wheel.
Type double
Lightness
public double Lightness { get; init; }
Perceived lightness, 0 for black and 1 for white.
Type double
Methods in detail
Deconstruct(out double, out double, out double)
public void Deconstruct(out double Lightness, out double Chroma, out double Hue);
Parameters
| Name | Type | Description |
|---|---|---|
Lightness | double | |
Chroma | double | |
Hue | double |
Of(Rgb)
public static Oklch Of(Rgb color);
Splits a color into the three.
Parameters
| Name | Type | Description |
|---|---|---|
color | Rgb | The color to read. |
Returns Oklch — The same color, said the other way round.
ToRgb()
public Rgb ToRgb();
The color as the screen shows it, trimmed to sRGB on the way.
Returns Rgb — The 24-bit color.
ToString()
public override string ToString();
Writes the three parts out, which is what a log of a derived palette holds.
Returns string — Lightness, chroma and hue.
Trimmed()
public Oklch Trimmed();
The same lightness and hue with the chroma cut back to the most sRGB holds. Cutting the chroma keeps the hue, where clamping the channels turns a color that is too vivid into a different color.
Returns Oklch — A color the screen can show.