gui/ctx.go
2023-01-22 12:38:03 +01:00

47 lines
726 B
Go

package gui
import (
"image"
"image/color"
"github.com/hajimehoshi/ebiten/text"
"golang.org/x/image/font"
)
type AppContext interface {
Font() *Font
FontSize() int
Foreground() color.Color
Background() color.Color
MeasureString(str string, f font.Face) image.Rectangle
}
type appCtx struct {
font *Font
fontSize int
fg, bg color.Color
}
var _ AppContext = &appCtx{}
func (c *appCtx) Font() *Font {
return c.font
}
func (c *appCtx) FontSize() int {
return c.fontSize
}
func (c *appCtx) Foreground() color.Color {
return c.fg
}
func (c *appCtx) Background() color.Color {
return c.bg
}
func (c *appCtx) MeasureString(str string, f font.Face) image.Rectangle {
return text.BoundString(f, str)
}