diff --git a/oklab.go b/oklab.go index e17f9e0..59ebdae 100644 --- a/oklab.go +++ b/oklab.go @@ -106,6 +106,14 @@ func FromRGBA(r, g, b, a uint32) Color { return FromNRGBA(r, g, b, a) } +// NRGBAColor represent a color that can give us non pre-multiplied RGBA components. +// +// This isn't a standard interface, but we implement it and check for it regardless. +type NRGBAColor interface { + color.Color + NRGBA() (r, g, b, a uint32) +} + // FromColor converts an arbitrary color type to an OKLab [Color], with special handling // for [color.NRGBA], [color.NRGBA64], and anything implementing the [NRGBAColor] interface // to preserve transparent colors. @@ -172,14 +180,6 @@ func Distance(a, b Color) float64 { return math.Sqrt(max(sqr(dL), sqr(dL+dA)) + max(sqr(da), sqr(da+dA)) + max(sqr(db), sqr(db+dA))) } -// NRGBAColor represent a color that can give us non pre-multiplied RGBA components. -// -// This isn't a standard interface, but we implement it and check for it regardless. -type NRGBAColor interface { - color.Color - NRGBA() (r, g, b, a uint32) -} - func okLabModel(c color.Color) color.Color { return FromColor(c) }