Documentation
¶
Overview ¶
Package gamut converts between sRGB, Display P3, Oklab and Oklch, and maps colors into a display's gamut as CSS Color 4 does.
Colors travel as extended sRGB: gamma encoded with the sRGB curve, mirrored around zero, so that a color outside the sRGB gamut (but inside Display P3's) has components below 0 or above 1.
Index ¶
- func Decode(v float64) float64
- func Encode(v float64) float64
- func FromOklch(l, c, h float64) (float64, float64, float64)
- func LinearP3ToSRGB(r, g, b float64) (float64, float64, float64)
- func LinearSRGB(l, a, b float64) (r, g, bb float64)
- func LinearSRGBToP3(r, g, b float64) (float64, float64, float64)
- func Map(sp Space, l, c, h float64) (r, g, b float64)
- func Oklab(r, g, b float64) (l, a, bb float64)
- func Oklch(l, a, b float64) (float64, float64, float64)
- type Space
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode returns the linear light of an sRGB-encoded component, which may be outside 0 to 1.
func LinearP3ToSRGB ¶
LinearP3ToSRGB converts linear Display P3 to linear sRGB.
func LinearSRGB ¶
LinearSRGB converts Oklab to linear sRGB, unclamped.
func LinearSRGBToP3 ¶
LinearSRGBToP3 converts linear sRGB to linear Display P3.
func Map ¶
Map returns the Oklch color as linear RGB inside the gamut of sp. It reduces the chroma, keeping lightness and hue, until clipping what is left out changes the color imperceptibly (the algorithm of CSS Color 4, "gamut mapping to a destination color space"). A negative or NaN chroma is 0, as CSS clamps it, a NaN lightness 0 and a hue that is not finite 0.