From 1be88eeb17b53333fbb0dad537c34a34ed9d7333 Mon Sep 17 00:00:00 2001 From: faiface Date: Sun, 19 Mar 2017 20:09:05 +0100 Subject: [PATCH] optimize color.NRGBA -> pixel.NRGBA conversion --- color.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/color.go b/color.go index 0303704..7345e4a 100644 --- a/color.go +++ b/color.go @@ -82,6 +82,14 @@ func nrgbaModel(c color.Color) color.Color { if c, ok := c.(NRGBA); ok { return c } + if c, ok := c.(color.NRGBA); ok { + return NRGBA{ + R: float64(c.R) / 255, + G: float64(c.G) / 255, + B: float64(c.B) / 255, + A: float64(c.A) / 255, + } + } r, g, b, a := c.RGBA() if a == 0 { return NRGBA{0, 0, 0, 0}