zntg/ui/palette.go

77 lines
1.6 KiB
Go

package ui
import (
"image/color"
"opslag.de/schobers/galleg/allegro5"
)
type Palette interface {
Primary() allegro5.Color
PrimaryHighlight() allegro5.Color
PrimaryTransparent() allegro5.Color
Lightest() allegro5.Color
Darker() allegro5.Color
Darkest() allegro5.Color
Disabled() allegro5.Color
}
type palette struct {
primary allegro5.Color
primaryH allegro5.Color
primaryT allegro5.Color
lightest allegro5.Color
darker allegro5.Color
darkest allegro5.Color
disabled allegro5.Color
}
func (p *palette) Primary() allegro5.Color {
return p.primary
}
func (p *palette) PrimaryHighlight() allegro5.Color {
return p.primaryH
}
func (p *palette) PrimaryTransparent() allegro5.Color {
return p.primaryT
}
func (p *palette) Lightest() allegro5.Color {
return p.lightest
}
func (p *palette) Darker() allegro5.Color {
return p.darker
}
func (p *palette) Darkest() allegro5.Color {
return p.darkest
}
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 {
var primary = Blue500
return &palette{
primary: NewColor(primary),
primaryH: NewColor(Blue400),
primaryT: NewColorAlpha(primary, 96),
lightest: allegro5.NewColor(0xff, 0xff, 0xff),
darker: allegro5.NewColorAlpha(0, 0, 0, 188),
darkest: allegro5.NewColorAlpha(0, 0, 0, 222),
disabled: allegro5.NewColorAlpha(0x1f, 0x1f, 0x1f, 0x1f),
}
}