Vixen
02b45cc4
csharp
public readonly record struct OkLch

A colour as perceptual lightness, chroma and hue.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

⚠ The conversion goes through linear RGB, because Oklab's input is linear and feeding it sRGB-encoded values produces something that is not Oklab and has none of the properties it is being used for. Vixen.Core.Mathematics says the same thing about the same function; it is repeated here because a colour picker is exactly where somebody reaches for the encoded value, which is the one they can see.

Fields and properties (4)

  • public float L

    Lightness, 0 at black and about 1 at white.

  • public float C

    How far from grey. Roughly 0 to 0.4 for anything inside sRGB.

  • public float H

    Hue in degrees.

  • public bool IsInGamut

    Whether a monitor can actually make this colour.

Methods (3)

  • public OkLch(float L, float C, float H)

    A colour as perceptual lightness, chroma and hue.

  • public static OkLch FromSrgb(Color4 color)

    Converts an sRGB colour.

  • public Color4 ToSrgb(float alpha = 1)

    Converts back, clamping into the sRGB gamut.

Used by (4)

  • ColorFieldVixen.Ui.Controls.Advanced
  • ColorModelTestsVixen.Ui.Controls.Advanced.Tests
  • ColorPickerVixen.Ui.Controls.Advanced
  • ColorPickerTestsVixen.Ui.Controls.Advanced.Tests