Color.HSLuv.Gamut (Color v0.12.1)

Copy Markdown

Helpers that compute the sRGB gamut boundary inside CIELUV for HSLuv and HPLuv.

These reimplement the reference algorithm from https://www.hsluv.org/implementations/ (Alexei Boronine) using the sRGB working-space XYZ→RGB matrix derived by Color.RGB.WorkingSpace from Lindbloom's primaries, so the result matches our Color.SRGB exactly.

Summary

Functions

Returns the six sRGB gamut boundary lines in CIELUV chroma space for a given L. Each line is {slope, intercept} describing v = slope * u + intercept in the chroma plane.

Returns the maximum chroma achievable inside the sRGB gamut for the given (l, h) in CIELUV coordinates, where h is in degrees.

Returns the largest chroma for the given l such that HPLuv is still achromatic at any hue, i.e. the distance from the origin in uv to the nearest gamut boundary line.

Functions

get_bounds(l)

Returns the six sRGB gamut boundary lines in CIELUV chroma space for a given L. Each line is {slope, intercept} describing v = slope * u + intercept in the chroma plane.

Arguments

  • l is the CIELUV lightness.

Returns

  • A list of six {slope, intercept} tuples.

max_chroma_for_lh(l, h)

Returns the maximum chroma achievable inside the sRGB gamut for the given (l, h) in CIELUV coordinates, where h is in degrees.

Arguments

  • l is the CIELUV lightness.

  • h is the hue in degrees.

Returns

  • A non-negative float.

max_safe_chroma_for_l(l)

Returns the largest chroma for the given l such that HPLuv is still achromatic at any hue, i.e. the distance from the origin in uv to the nearest gamut boundary line.

Arguments

  • l is the CIELUV lightness.

Returns

  • A non-negative float.