erm/internal/app/darktile/sixel/colourmap.go

29 lines
465 B
Go
Raw Normal View History

2021-07-30 22:29:20 +00:00
package sixel
import "image/color"
type ColourMap struct {
data [0x100]color.Color
}
func NewColourMap() *ColourMap {
return &ColourMap{}
}
func (m *ColourMap) GetColour(id uint8) color.Color {
return m.data[id]
}
func (m *ColourMap) SetColour(id uint8, c color.Color) {
m.data[id] = c
}
func (m *ColourMap) FindColour(colour color.Color) (uint8, bool) {
for id, c := range m.data {
if c == colour {
return uint8(id), true
}
}
return 0, false
}