aboutsummaryrefslogtreecommitdiffstats
path: root/test/region.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2026-02-09 22:00:33 -0500
committerSam Anthony <sam@samanthony.xyz>2026-02-09 22:00:33 -0500
commit8f28d1044fb83153fde4505421b75072930d6fb9 (patch)
treeec39000ed901dc959626fc09d8e270268c6b3d03 /test/region.go
parent5fde17eafa11bf397bbf1f18864b8ee26d9a701d (diff)
downloadgui-8f28d1044fb83153fde4505421b75072930d6fb9.zip
layout: add background color option
Diffstat (limited to 'test/region.go')
-rw-r--r--test/region.go13
1 files changed, 9 insertions, 4 deletions
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)
}
}()
}