Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

Commit

Permalink
made Color implement image.Color interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dertseha committed Jun 15, 2017
1 parent 57c43a3 commit cc5f2e5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Palette.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cc5f2e5

Please sign in to comment.