From 615a2b5096f89ce42e735fea7d969cadff98b846 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 24 Jun 2021 03:20:05 +0200 Subject: [PATCH] Use Luv colorspace for color profile conversions --- color.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/color.go b/color.go index 3e4f585..db7980e 100644 --- a/color.go +++ b/color.go @@ -188,7 +188,7 @@ func ansi256ToANSIColor(c ANSI256Color) ANSIColor { h, _ := colorful.Hex(ansiHex[c]) for i := 0; i <= 15; i++ { hb, _ := colorful.Hex(ansiHex[i]) - d := h.DistanceLab(hb) + d := h.DistanceLuv(hb) if d < md { md = d @@ -235,8 +235,8 @@ func hexToANSI256Color(c colorful.Color) ANSI256Color { // Return the one which is nearer to the original input rgb value c2 := colorful.Color{R: float64(cr) / 255.0, G: float64(cg) / 255.0, B: float64(cb) / 255.0} g2 := colorful.Color{R: float64(gv) / 255.0, G: float64(gv) / 255.0, B: float64(gv) / 255.0} - colorDist := c.DistanceLab(c2) - grayDist := c.DistanceLab(g2) + colorDist := c.DistanceLuv(c2) + grayDist := c.DistanceLuv(g2) if colorDist <= grayDist { return ANSI256Color(16 + ci)