automated snapshot

This commit is contained in:
sumi
2025-12-23 10:45:22 -06:00
parent f37bdf0604
commit ecac2dcebe
2 changed files with 52 additions and 23 deletions

59
main.go
View File

@@ -62,11 +62,14 @@ func main() {
sketch := NewSketch(sourceWidth, sourceHeight) sketch := NewSketch(sourceWidth, sourceHeight)
sierpinskiLayer := &SierpinskiArrow { dirty: true }
contourLayer := NewContourLayer(&sketch, rng, field) contourLayer := NewContourLayer(&sketch, rng, field)
//sketch.CreateLayer("testPattern", &TestPattern{}, int32(sourceWidth), int32(sourceHeight)) //sketch.CreateLayer("testPattern", &TestPattern{}, int32(sourceWidth), int32(sourceHeight))
//sketch.CreateLayer("actors", &contourLayer, 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("field", &FieldLayer{field: &field, dirty: true}, int32(sourceWidth), int32(sourceHeight))
sketch.CreateLayer("contours", contourLayer) sketch.CreateLayer("contours", contourLayer)
sketch.CreateLayer("sierpinski", sierpinskiLayer)
ports := MakePorts() ports := MakePorts()
ports["sierpinskiArrowAngle"] = Sine { ports["sierpinskiArrowAngle"] = Sine {
@@ -106,14 +109,14 @@ func main() {
sketch.Draw(renderCtx) sketch.Draw(renderCtx)
//gui.LoadStyle("styles/dark.rgs") //gui.LoadStyle("styles/dark.rgs")
gui.SetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR, 0x181818FF) gui.SetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR, 0x181818FF)
gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_NORMAL, 0x2A2A2AFF) 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_FOCUSED, 0x3A3A3AFF)
gui.SetStyle(gui.DEFAULT, gui.BASE_COLOR_PRESSED, 0x4A4A4AFF) 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_NORMAL, 0xE0E0E0FF)
gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_FOCUSED, 0xFFFFFFFF) gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_FOCUSED, 0xFFFFFFFF)
gui.SetStyle(gui.DEFAULT, gui.BORDER_COLOR_NORMAL, 0x404040FF) gui.SetStyle(gui.DEFAULT, gui.BORDER_COLOR_NORMAL, 0x404040FF)
controlPanelWidth := float32(targetWidth) / 4.0 controlPanelWidth := float32(targetWidth) / 4.0
controlPanelHeight := float32(targetHeight) controlPanelHeight := float32(targetHeight)
@@ -136,30 +139,44 @@ func main() {
gui.GroupBox(rl.Rectangle{X: 20, Y: 20, Width: controlPanelWidth - 50, Height: 60 }, "Blending") 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) 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 { for _, layerTools := range sketch.layerToolsOrdered {
config := layerTools.config 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) y += 30
config.a = uint8(gui.Slider(rl.Rectangle{X: 64, Y: 136, Width: 264, Height: 16}, "", "", float32(config.a), 0, 255))
config.rVisible = gui.Toggle(rl.Rectangle{X: 40, Y: 160, Width: 16, Height: 16}, "R", config.rVisible) config.visible = gui.Toggle(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "A", config.visible)
config.r = uint8(gui.Slider(rl.Rectangle{X: 64, Y: 160, Width: 264, Height: 16}, "", "", float32(config.r), 0, 255)) 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) y += 24
config.g = uint8(gui.Slider(rl.Rectangle{X: 64, Y: 184, Width: 264, Height: 16}, "", "", float32(config.g), 0, 255))
config.bVisible = gui.Toggle(rl.Rectangle{X: 40, Y: 208, Width: 16, Height: 16}, "B", config.bVisible) config.rVisible = gui.Toggle(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "R", config.rVisible)
config.b = uint8(gui.Slider(rl.Rectangle{X: 64, Y: 208, Width: 264, Height: 16}, "", "", float32(config.b), 0, 255)) 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) y += 24
config.saturation = gui.Slider(rl.Rectangle{X: 64, Y: 232, Width: 264, Height: 16}, "", "", config.saturation, 0, 100)
gui.Label(rl.Rectangle{X: 40, Y: 256, Width: 16, Height: 16}, "S") config.gVisible = gui.Toggle(rl.Rectangle{X: 30, Y: y, Width: 16, Height: 16}, "G", config.gVisible)
config.kValue = gui.Slider(rl.Rectangle{X: 64, Y: 256, Width: 264, Height: 16}, "", "", config.kValue, 0, 2) 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() rl.EndDrawing()

View File

@@ -4,12 +4,22 @@ import (
rl "github.com/gen2brain/raylib-go/raylib" rl "github.com/gen2brain/raylib-go/raylib"
) )
type SierpinskiArrow struct{} type SierpinskiArrow struct{
dirty bool
}
func (s *SierpinskiArrow) Draw(ctx *RenderCtx) { func (s *SierpinskiArrow) Draw(ctx *RenderCtx) {
sierpinskiArrow(ctx, int(ctx.Ports["sierpinskiArrowDepth"]), ctx.Ports["sierpinskiArrowLength"]) 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) { func sierpinskiArrow(ctx *RenderCtx, order int, length float64) {
if order == 0 { if order == 0 {
curve(ctx, order, length, ctx.Ports["sierpinskiArrowAngle"]) 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) { func curve(ctx *RenderCtx, order int, length float64, angle float64) {
if order == 0 { if order == 0 {
len := int32(length) 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) rl.Translatef(float32(length), 0, 0)
} else { } else {
curve(ctx, order-1, length/2, -angle) curve(ctx, order-1, length/2, -angle)
@@ -33,3 +44,4 @@ func curve(ctx *RenderCtx, order int, length float64, angle float64) {
} }
} }