zntg/ui/palette.go

52 lines
1.0 KiB
Go
Raw Normal View History

2018-08-03 06:46:10 +00:00
package ui
import (
"image/color"
"opslag.de/schobers/galleg/allegro5"
)
type Palette interface {
Primary() allegro5.Color
White() allegro5.Color
Black() allegro5.Color
Disabled() allegro5.Color
}
type palette struct {
primary allegro5.Color
white allegro5.Color
black allegro5.Color
disabled allegro5.Color
}
func (p *palette) Primary() allegro5.Color {
return p.primary
}
func (p *palette) White() allegro5.Color {
return p.white
}
func (p *palette) Black() allegro5.Color {
return p.black
}
func (p *palette) Disabled() allegro5.Color {
return p.disabled
}
func NewColor(c *color.RGBA) allegro5.Color {
return allegro5.NewColorAlpha(c.R, c.G, c.B, c.A)
}
func NewColorAlpha(c *color.RGBA, a uint8) allegro5.Color {
return allegro5.NewColorAlpha(c.R, c.G, c.B, a)
}
func DefaultPalette() Palette {
return &palette{
primary: NewColor(Blue500),
white: allegro5.NewColor(0xff, 0xff, 0xff),
black: allegro5.NewColor(0, 0, 0),
disabled: allegro5.NewColorAlpha(0x1f, 0x1f, 0x1f, 0x1f),
}
}