etk/style.go

63 lines
1.2 KiB
Go
Raw Normal View History

2022-06-08 23:35:42 +00:00
package etk
2022-07-07 21:53:14 +00:00
import (
"image/color"
"log"
"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
)
var transparent = color.RGBA{0, 0, 0, 0}
func defaultFont() font.Face {
tt, err := opentype.Parse(fonts.MPlus1pRegular_ttf)
if err != nil {
log.Fatal(err)
}
const dpi = 72
defaultFont, err := opentype.NewFace(tt, &opentype.FaceOptions{
Size: 32,
DPI: dpi,
Hinting: font.HintingFull,
})
if err != nil {
log.Fatal(err)
}
return defaultFont
}
2022-06-08 23:35:42 +00:00
type Attributes struct {
2022-07-07 21:53:14 +00:00
TextFont font.Face
TextColorLight color.Color
TextColorDark color.Color
TextBgColor color.Color
2022-06-08 23:35:42 +00:00
BorderColor color.Color
2022-07-07 21:53:14 +00:00
InputBgColor color.Color
2022-06-08 23:35:42 +00:00
ButtonTextColor color.Color
ButtonBgColor color.Color
ButtonBgColorDisabled color.Color
}
var Style = &Attributes{
2022-07-07 21:53:14 +00:00
TextFont: defaultFont(),
TextColorLight: color.RGBA{255, 255, 255, 255},
TextColorDark: color.RGBA{0, 0, 0, 255},
TextBgColor: transparent,
2022-06-08 23:35:42 +00:00
BorderColor: color.RGBA{0, 0, 0, 255},
2022-07-07 21:53:14 +00:00
InputBgColor: color.RGBA{0, 128, 0, 255},
2022-06-08 23:35:42 +00:00
ButtonBgColor: color.RGBA{255, 255, 255, 255},
ButtonBgColorDisabled: color.RGBA{110, 110, 110, 255},
}