/palette/rgb8.go
package palette

import (
    "math"
    "image/color"
)

// No alpha
type RGB8 struct {
    R uint8
    G uint8
    B uint8
}

// Implement Color interface on RGB8
func (c RGB8) RGBA() (r, g, b, a uint32) {
    r = uint32(c.R) << 8
    g = uint32(c.G) << 8
    b = uint32(c.B) << 8
    a = 0xFFFF
    return
}

func (c RGB8) Distance(other color.Color) float64 {
    cR, cG, cB, _ := c.RGBA()
    oR, oG, oB, _ := other.RGBA()
    dr := float64(cR) - float64(oR)
    dg := float64(cG) - float64(oG)
    db := float64(cB) - float64(oB)
    return math.Sqrt(dr * dr + dg * dg + db * db)
}