Raxol.Terminal.Color.TrueColor.Conversion (Raxol Terminal v2.6.0)

Copy Markdown View Source

Color space math for TrueColor: RGB/HSL/HSV/XYZ/Lab conversions and luminance calculations.

Summary

Functions

Converts HSL (h in 0..360, s/l in 0..1) to normalized RGB (0..1 each).

Converts HSV (h in 0..360, s/v in 0..1) to normalized RGB (0..1 each).

Calculates relative luminance for an 8-bit RGB color (WCAG formula).

Converts normalized RGB (0..1 each) to HSL tuple {h, s, l} where h is 0..360, s and l are 0..100.

Converts normalized RGB (0..1 each) to HSV tuple {h, s, v} where h is 0..360, s and v are 0..100.

Converts an 8-bit RGB struct to XYZ color space.

Converts XYZ to CIELAB (L, a, b*) using D65 illuminant.

Functions

hsl_to_rgb(h, s, l)

Converts HSL (h in 0..360, s/l in 0..1) to normalized RGB (0..1 each).

hsv_to_rgb(h, s, v)

Converts HSV (h in 0..360, s/v in 0..1) to normalized RGB (0..1 each).

relative_luminance(r, g, b)

Calculates relative luminance for an 8-bit RGB color (WCAG formula).

rgb_to_hsl(r, g, b)

Converts normalized RGB (0..1 each) to HSL tuple {h, s, l} where h is 0..360, s and l are 0..100.

rgb_to_hsv(r, g, b)

Converts normalized RGB (0..1 each) to HSV tuple {h, s, v} where h is 0..360, s and v are 0..100.

to_xyz(r, g, b)

Converts an 8-bit RGB struct to XYZ color space.

xyz_to_lab(x, y, z)

Converts XYZ to CIELAB (L, a, b*) using D65 illuminant.