From 22c3791a7f7e5e93ab429f2ede4682d50e5ea7d9 Mon Sep 17 00:00:00 2001 From: Dietrich Featherston Date: Mon, 5 Jan 2026 13:42:07 -0600 Subject: [PATCH] dynamic window sizing --- main.go | 73 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/main.go b/main.go index fe0193e..6eff106 100644 --- a/main.go +++ b/main.go @@ -17,32 +17,61 @@ import ( //"github.com/ojrac/opensimplex-go" ) -var snapshotsPath string +var ( + snapshotsPath string + storage *Storage + sourceWidth, sourceHeight int + targetWidth, targetHeight int +) + +func bootstrap() { + + rl.InitWindow(800, 600, "bootstrap") + + monitor := rl.GetCurrentMonitor() + fmt.Printf("Using monitor %d\n", monitor) + + monitorWidth := rl.GetMonitorWidth(monitor) + monitorHeight := rl.GetMonitorHeight(monitor) + + defaultTargetWidth := int(float32(monitorWidth) * 0.95) + defaultTargetHeight := int(float32(monitorHeight) * 0.9) + defaultSourceWidth := 5*defaultTargetWidth + defaultSourceHeight := 5*defaultTargetHeight + + fmt.Printf("monitor : %d x %d / window : %d x %d / buffer : %d x %d", + monitorWidth, monitorHeight, + defaultTargetWidth, defaultTargetHeight, + defaultSourceWidth, defaultSourceHeight) + + flag.StringVar(&snapshotsPath, "path", "snapshots", "Path to snapshots and db") + flag.IntVar(&sourceWidth, "bw", defaultSourceWidth, "Width of the internal graphics source") + flag.IntVar(&sourceHeight, "bh", defaultSourceHeight, "Height of the internal graphics source") + flag.IntVar(&targetWidth, "w", defaultTargetWidth, "Width of the display window") + flag.IntVar(&targetHeight, "h", defaultTargetHeight, "Height of the display window") + flag.Parse() + + rl.CloseWindow() + + log.Printf("Storing snapshots at '%s'\n", snapshotsPath) + + os.MkdirAll(snapshotsPath, 0755) + var err error + storage, err = NewStorage(snapshotsPath) + if err != nil { + log.Printf("Error loading storage: %v\n", err) + os.Exit(1) + } +} func main() { log := log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile) - flag.StringVar(&snapshotsPath, "path", "snapshots", "Path to snapshots and db") - flag.Parse() - - var sourceWidth int32 = 8000 - var sourceHeight int32 = 6400 - - var targetWidth int32 = int32(1600) - var targetHeight int32 = int32(1000) - - log.Printf("Storing snapshots at '%s'\n", snapshotsPath) - - os.MkdirAll(snapshotsPath, 0755) - storage, err := NewStorage(snapshotsPath) - if err != nil { - log.Printf("Error loading storage: %v\n", err) - os.Exit(1) - } + bootstrap() //rl.SetConfigFlags(rl.FlagMsaa4xHint) - rl.InitWindow(targetWidth, targetHeight, "sumi sierpinski arrow") + rl.InitWindow(int32(targetWidth), int32(targetHeight), "sumi sierpinski arrow") // layout_name: controls initialization var ControlScrollPaneScrollView rl.Rectangle @@ -72,8 +101,8 @@ func main() { scale: 100.0, field: &AdderField { fields: []Field { + &ScaleField { scale: 10,field: noiseField }, sinXYField, - noiseField, }, }, }, @@ -81,7 +110,7 @@ func main() { sierpinskiLayer := &SierpinskiArrow { dirty: true } - sketch := NewSketch(sourceWidth, sourceHeight) + sketch := NewSketch(int32(sourceWidth), int32(sourceHeight)) fieldColor := colorCycle.Next() fmt.Printf("field color = %v\n", fieldColor) @@ -102,7 +131,7 @@ func main() { //NewColor(11, 35, 176, 50), //r - contourLayer := NewContourLayer(&sketch, rng, field, actorColor, -10*math.Pi, 10*math.Pi) + contourLayer := NewContourLayer(&sketch, rng, field, actorColor, -25*math.Pi, 25*math.Pi) sketch.AddLayer("contours", contourLayer) sketch.AddLayer("sierpinski-arrowhead", sierpinskiLayer) // aurora := NewImageLayer("/home/d/Dropbox/photos/Events/2025/Aurora/Photo Nov 11 2025, 9 52 03 PM.jpg")