From 158268694edc76851bc7934face80098ebacfdf5 Mon Sep 17 00:00:00 2001 From: "Amy G. Dalin" Date: Mon, 17 Feb 2025 01:25:45 -0500 Subject: [PATCH] Move the NRGBAColor interface to be with the new FromColor function, since that's where it's used. --- oklab.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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) }