Documentation
¶
Overview ¶
Package oklch provides zero-dependency Go 1.22+ perceptual color space conversions (sRGB <-> Linear RGB <-> OKLab <-> OKLCH) and WCAG 2.1 contrast auditing by NBrain (https://nbra.in).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChannelToLinear ¶
ChannelToLinear converts a normalized sRGB channel to linear light intensity.
func RelativeLuminance ¶
RelativeLuminance returns WCAG 2.1 relative luminance Y in [0,1].
func WCAGContrastRatio ¶
WCAGContrastRatio computes the WCAG 2.1 contrast ratio in [1,21].
Types ¶
type OKLCH ¶
type OKLCH struct{ L, C, H float64 }
OKLCH represents perceptual Lightness L, Chroma C, and Hue H in degrees [0,360).
func SRGBToOKLCH ¶
SRGBToOKLCH converts sRGB directly to cylindrical OKLCH.
type OKLab ¶
type OKLab struct{ L, A, B float64 }
OKLab represents perceptual lightness L and chromatic axes a, b.
func SRGBToOKLab ¶
SRGBToOKLab implements Björn Ottosson's exact D65 sRGB -> OKLab transform.