52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
|
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),
|
||
|
}
|
||
|
}
|