zntg/ui/palette.go
2018-09-22 16:31:09 +02:00

77 lines
1.5 KiB
Go

package ui
import (
"image/color"
"opslag.de/schobers/zntg/allg5"
)
type Palette interface {
Primary() allg5.Color
PrimaryHighlight() allg5.Color
PrimaryTransparent() allg5.Color
Lightest() allg5.Color
Darker() allg5.Color
Darkest() allg5.Color
Disabled() allg5.Color
}
type palette struct {
primary allg5.Color
primaryH allg5.Color
primaryT allg5.Color
lightest allg5.Color
darker allg5.Color
darkest allg5.Color
disabled allg5.Color
}
func (p *palette) Primary() allg5.Color {
return p.primary
}
func (p *palette) PrimaryHighlight() allg5.Color {
return p.primaryH
}
func (p *palette) PrimaryTransparent() allg5.Color {
return p.primaryT
}
func (p *palette) Lightest() allg5.Color {
return p.lightest
}
func (p *palette) Darker() allg5.Color {
return p.darker
}
func (p *palette) Darkest() allg5.Color {
return p.darkest
}
func (p *palette) Disabled() allg5.Color {
return p.disabled
}
func NewColor(c *color.RGBA) allg5.Color {
return allg5.NewColorAlpha(c.R, c.G, c.B, c.A)
}
func NewColorAlpha(c *color.RGBA, a uint8) allg5.Color {
return allg5.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: allg5.NewColor(0xff, 0xff, 0xff),
darker: allg5.NewColorAlpha(0, 0, 0, 188),
darkest: allg5.NewColorAlpha(0, 0, 0, 222),
disabled: allg5.NewColorAlpha(0x1f, 0x1f, 0x1f, 0x1f),
}
}