From 8f28d1044fb83153fde4505421b75072930d6fb9 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Mon, 9 Feb 2026 22:00:33 -0500 Subject: layout: add background color option --- test/region.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/region.go b/test/region.go index afd739e..0b99a3a 100644 --- a/test/region.go +++ b/test/region.go @@ -11,6 +11,10 @@ import ( "github.com/faiface/mainthread" ) +var ( + bg = gui.HexToColor("#999999") // background color +) + func main() { mainthread.Run(run) } @@ -24,9 +28,10 @@ func run() { mux, env := gui.NewMux(w) // Create region in bottom-right quadrant of window - region := layout.NewRegion(mux.MakeEnv(), func(r image.Rectangle) image.Rectangle { + resize := func(r image.Rectangle) image.Rectangle { return image.Rect(r.Min.X+r.Dx()/2, r.Min.Y+r.Dy()/2, r.Max.X, r.Max.Y) - }) + } + region := layout.NewRegion(mux.MakeEnv(), resize, layout.Background(bg)) go blinker(region) for event := range env.Events() { @@ -64,9 +69,9 @@ func blinker(env gui.Env) { go func() { for i := 0; i < 3; i++ { env.Draw() <- redraw(false) - time.Sleep(time.Second / 3) + time.Sleep(time.Second / 6) env.Draw() <- redraw(true) - time.Sleep(time.Second / 3) + time.Sleep(time.Second / 6) } }() } -- cgit v1.2.3