From ecac2dcebe674efb159172aca632600099907136 Mon Sep 17 00:00:00 2001 From: sumi Date: Tue, 23 Dec 2025 10:45:22 -0600 Subject: [PATCH] automated snapshot --- main.go | 59 +++++++++++++++++++++++++++++++++------------------ sierpinski.go | 16 ++++++++++++-- 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index 71402c4..837bb67 100644 --- a/main.go +++ b/main.go @@ -62,11 +62,14 @@ func main() { sketch := NewSketch(sourceWidth, sourceHeight) + sierpinskiLayer := &SierpinskiArrow { dirty: true } + contourLayer := NewContourLayer(&sketch, rng, field) //sketch.CreateLayer("testPattern", &TestPattern{}, int32(sourceWidth), int32(sourceHeight)) //sketch.CreateLayer("actors", &contourLayer, int32(sourceWidth), int32(sourceHeight)) //sketch.CreateLayer("field", &FieldLayer{field: &field, dirty: true}, int32(sourceWidth), int32(sourceHeight)) sketch.CreateLayer("contours", contourLayer) + sketch.CreateLayer("sierpinski", sierpinskiLayer) ports := MakePorts() ports["sierpinskiArrowAngle"] = Sine { @@ -106,14 +109,14 @@ func main() { sketch.Draw(renderCtx) - //gui.LoadStyle("styles/dark.rgs") - gui.SetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR, 0x181818FF) - gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_NORMAL, 0x2A2A2AFF) - gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_FOCUSED, 0x3A3A3AFF) - gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_PRESSED, 0x4A4A4AFF) - gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_NORMAL, 0xE0E0E0FF) - gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_FOCUSED, 0xFFFFFFFF) - gui.SetStyle(gui.DEFAULT, gui.BORDER_COLOR_NORMAL, 0x404040FF) + //gui.LoadStyle("styles/dark.rgs") + gui.SetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR, 0x181818FF) + gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_NORMAL, 0x2A2A2AFF) + gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_FOCUSED, 0x3A3A3AFF) + gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_PRESSED, 0x4A4A4AFF) + gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_NORMAL, 0xE0E0E0FF) + gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_FOCUSED, 0xFFFFFFFF) + gui.SetStyle(gui.DEFAULT, gui.BORDER_COLOR_NORMAL, 0x404040FF) controlPanelWidth := float32(targetWidth) / 4.0 controlPanelHeight := float32(targetHeight) @@ -136,30 +139,44 @@ func main() { gui.GroupBox(rl.Rectangle{X: 20, Y: 20, Width: controlPanelWidth - 50, Height: 60 }, "Blending") BlendModeToggleGroupActive = gui.ToggleGroup(rl.Rectangle{X: 30, Y: 40, Width: (controlPanelWidth - 70) / 3.0, Height: 24}, "ONE;TWO;THREE", BlendModeToggleGroupActive) + y := float32(90) for _, layerTools := range sketch.layerToolsOrdered { config := layerTools.config - gui.Label(rl.Rectangle{X: 20, Y: 90, Width: 120, Height: 24}, layerTools.name) + gui.Label(rl.Rectangle{X: 20, Y: y, Width: 120, Height: 24}, layerTools.name) - config.visible = gui.Toggle(rl.Rectangle{X: 40, Y: 136, Width: 16, Height: 16}, "A", config.visible) - config.a = uint8(gui.Slider(rl.Rectangle{X: 64, Y: 136, Width: 264, Height: 16}, "", "", float32(config.a), 0, 255)) + y += 30 - config.rVisible = gui.Toggle(rl.Rectangle{X: 40, Y: 160, Width: 16, Height: 16}, "R", config.rVisible) - config.r = uint8(gui.Slider(rl.Rectangle{X: 64, Y: 160, Width: 264, Height: 16}, "", "", float32(config.r), 0, 255)) + config.visible = gui.Toggle(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "A", config.visible) + config.a = uint8(gui.Slider(rl.Rectangle{X: 50, Y: y, Width: 264, Height: 16}, "", "", float32(config.a), 0, 255)) - config.gVisible = gui.Toggle(rl.Rectangle{X: 40, Y: 184, Width: 16, Height: 16}, "G", config.gVisible) - config.g = uint8(gui.Slider(rl.Rectangle{X: 64, Y: 184, Width: 264, Height: 16}, "", "", float32(config.g), 0, 255)) + y += 24 - config.bVisible = gui.Toggle(rl.Rectangle{X: 40, Y: 208, Width: 16, Height: 16}, "B", config.bVisible) - config.b = uint8(gui.Slider(rl.Rectangle{X: 64, Y: 208, Width: 264, Height: 16}, "", "", float32(config.b), 0, 255)) + config.rVisible = gui.Toggle(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "R", config.rVisible) + config.r = uint8(gui.Slider(rl.Rectangle{X: 50, Y: y, Width: 264, Height: 16}, "", "", float32(config.r), 0, 255)) - config.desaturate = !gui.Toggle(rl.Rectangle{X: 40, Y: 232, Width: 16, Height: 16}, "S", !config.desaturate) - config.saturation = gui.Slider(rl.Rectangle{X: 64, Y: 232, Width: 264, Height: 16}, "", "", config.saturation, 0, 100) + y += 24 - gui.Label(rl.Rectangle{X: 40, Y: 256, Width: 16, Height: 16}, "S") - config.kValue = gui.Slider(rl.Rectangle{X: 64, Y: 256, Width: 264, Height: 16}, "", "", config.kValue, 0, 2) + config.gVisible = gui.Toggle(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "G", config.gVisible) + config.g = uint8(gui.Slider(rl.Rectangle{X: 50, Y: y, Width: 264, Height: 16}, "", "", float32(config.g), 0, 255)) + y += 24 + + config.bVisible = gui.Toggle(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "B", config.bVisible) + config.b = uint8(gui.Slider(rl.Rectangle{X: 50, Y: y, Width: 264, Height: 16}, "", "", float32(config.b), 0, 255)) + + y += 24 + + config.desaturate = !gui.Toggle(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "S", !config.desaturate) + config.saturation = gui.Slider(rl.Rectangle{X: 50, Y: y, Width: 264, Height: 16}, "", "", config.saturation, 0, 100) + + y += 24 + + gui.Label(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "K") + config.kValue = gui.Slider(rl.Rectangle{X: 50, Y: y, Width: 264, Height: 16}, "", "", config.kValue, 0, 2) + + y += 30 } rl.EndDrawing() diff --git a/sierpinski.go b/sierpinski.go index 3f3d5be..a951560 100644 --- a/sierpinski.go +++ b/sierpinski.go @@ -4,12 +4,22 @@ import ( rl "github.com/gen2brain/raylib-go/raylib" ) -type SierpinskiArrow struct{} +type SierpinskiArrow struct{ + dirty bool +} func (s *SierpinskiArrow) Draw(ctx *RenderCtx) { sierpinskiArrow(ctx, int(ctx.Ports["sierpinskiArrowDepth"]), ctx.Ports["sierpinskiArrowLength"]) } +func (s *SierpinskiArrow) Update(ctx *RenderCtx) { + s.dirty = true +} + +func (s *SierpinskiArrow) IsDirty() bool { + return s.dirty +} + func sierpinskiArrow(ctx *RenderCtx, order int, length float64) { if order == 0 { curve(ctx, order, length, ctx.Ports["sierpinskiArrowAngle"]) @@ -22,7 +32,8 @@ func sierpinskiArrow(ctx *RenderCtx, order int, length float64) { func curve(ctx *RenderCtx, order int, length float64, angle float64) { if order == 0 { len := int32(length) - rl.DrawLine(0, 0, len, 0, rl.Black) + rl.SetLineWidth(4) + rl.DrawLine(0, 0, len, 0, rl.RayWhite) rl.Translatef(float32(length), 0, 0) } else { curve(ctx, order-1, length/2, -angle) @@ -33,3 +44,4 @@ func curve(ctx *RenderCtx, order int, length float64, angle float64) { } } +