From cc5f2e53c8be9ec6c7977c0d20e1a8fb4a266a58 Mon Sep 17 00:00:00 2001 From: Christian Haas Date: Thu, 15 Jun 2017 14:14:43 +0200 Subject: [PATCH] made Color implement image.Color interface --- Palette.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Palette.go b/Palette.go index 3435236..139d880 100644 --- a/Palette.go +++ b/Palette.go @@ -7,6 +7,16 @@ type Color struct { Blue int } +// RGBA implements the image/color interface. +func (clr Color) RGBA() (r, g, b, a uint32) { + upscale := func(value int) uint32 { + b := uint32(value & 0xFF) + return (b << 8) | b + } + + return upscale(clr.Red), upscale(clr.Green), upscale(clr.Blue), 0xFFFF +} + // Palette is an identifiable list of colors. type Palette struct { // Colors contains the color values of the palette.