package ui import "opslag.de/schobers/galleg/allegro5" type Context interface { Display() *allegro5.Display Fonts() Fonts Palette() Palette Debug() Debug } type Debug interface { IsEnabled() bool Rainbow() allegro5.Color } var _ Context = &context{} type context struct { disp *allegro5.Display fts Fonts pal Palette dbg *debug } type debug struct { enbl bool rainb []allegro5.Color col int } func rainbow() []allegro5.Color { var colors = make([]allegro5.Color, len(Colors500)) for i, c := range Colors500 { colors[i] = NewColorAlpha(c, 0xbf) } return colors } func newContext(disp *allegro5.Display, f Fonts) *context { return &context{disp, f, DefaultPalette(), &debug{rainb: rainbow()}} } func (c *context) Display() *allegro5.Display { return c.disp } func (c *context) Fonts() Fonts { return c.fts } func (c *context) Palette() Palette { return c.pal } func (c *context) Debug() Debug { return c.dbg } func (d *debug) IsEnabled() bool { return d.enbl } func (d *debug) resetRainbow() { d.col = 0 } func (d *debug) Rainbow() allegro5.Color { var col = d.col d.col = (col + 1) % len(d.rainb) return d.rainb[col] }