zntg/ui/palette.go

77 lines
1.5 KiB
Go
Raw Normal View History

2018-08-03 06:46:10 +00:00
package ui
import (
"image/color"
"opslag.de/schobers/zntg/allg5"
2018-08-03 06:46:10 +00:00
)
type Palette interface {
Primary() allg5.Color
PrimaryHighlight() allg5.Color
PrimaryTransparent() allg5.Color
Lightest() allg5.Color
Darker() allg5.Color
Darkest() allg5.Color
Disabled() allg5.Color
2018-08-03 06:46:10 +00:00
}
type palette struct {
primary allg5.Color
primaryH allg5.Color
primaryT allg5.Color
lightest allg5.Color
darker allg5.Color
darkest allg5.Color
disabled allg5.Color
2018-08-03 06:46:10 +00:00
}
func (p *palette) Primary() allg5.Color {
2018-08-03 06:46:10 +00:00
return p.primary
}
func (p *palette) PrimaryHighlight() allg5.Color {
2018-09-09 16:49:18 +00:00
return p.primaryH
}
func (p *palette) PrimaryTransparent() allg5.Color {
return p.primaryT
}
func (p *palette) Lightest() allg5.Color {
return p.lightest
2018-08-03 06:46:10 +00:00
}
func (p *palette) Darker() allg5.Color {
return p.darker
2018-08-03 06:46:10 +00:00
}
func (p *palette) Darkest() allg5.Color {
return p.darkest
}
func (p *palette) Disabled() allg5.Color {
2018-08-03 06:46:10 +00:00
return p.disabled
}
func NewColor(c *color.RGBA) allg5.Color {
return allg5.NewColorAlpha(c.R, c.G, c.B, c.A)
2018-08-03 06:46:10 +00:00
}
func NewColorAlpha(c *color.RGBA, a uint8) allg5.Color {
return allg5.NewColorAlpha(c.R, c.G, c.B, a)
2018-08-03 06:46:10 +00:00
}
func DefaultPalette() Palette {
var primary = Blue500
2018-08-03 06:46:10 +00:00
return &palette{
primary: NewColor(primary),
2018-09-09 16:49:18 +00:00
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),
2018-08-03 06:46:10 +00:00
}
}