automated snapshot
This commit is contained in:
84
main.go
84
main.go
@@ -10,7 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
sg "github.com/d2fn/sumi/internal/graphics"
|
||||
"github.com/ojrac/opensimplex-go"
|
||||
|
||||
gui "github.com/gen2brain/raylib-go/raygui"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
@@ -71,7 +70,7 @@ func Bootstrap() *Env {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
layout := Layout{
|
||||
layout := Layout {
|
||||
Monitor: sg.Rect{X: 0, Y: 0, Width: float32(monitorWidth), Height: float32(monitorHeight)},
|
||||
Window: sg.Rect{X: 0, Y: 0, Width: float32(windowWidth), Height: float32(windowHeight)},
|
||||
Controls: sg.Rect{X: 0, Y: 0, Width: float32(controlsWidth), Height: float32(windowHeight)},
|
||||
@@ -81,7 +80,7 @@ func Bootstrap() *Env {
|
||||
|
||||
//rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||
rl.InitWindow(int32(layout.Window.Width), int32(layout.Window.Height), "sumi sierpinski arrow")
|
||||
rl.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(30)
|
||||
|
||||
env := NewEnv()
|
||||
env.Layout = layout
|
||||
@@ -105,37 +104,37 @@ func main() {
|
||||
|
||||
rng := rand.New(rand.NewSource(env.Time.Unix()))
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/david.png")
|
||||
noiseField := &SimplexNoiseField{Noise: opensimplex.New32(env.Time.Unix())}
|
||||
sinXYField := &SinXYField{}
|
||||
//noiseField := &SimplexNoiseField{Noise: opensimplex.New32(env.Time.Unix())}
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/ramstatue.png")
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/bassrockastro/Photo Dec 24 2025, 5 58 23 PM.jpg")
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/bassrockastro/andromeda.jpg")
|
||||
//imageField := NewImageField("/home/d/Dropbox/art/data/moses_statue.jpg")
|
||||
imageField := NewImageField("/home/d/Dropbox/art/data/moses_statue.jpg")
|
||||
//imageLayer := NewImageLayer("/home/d/Dropbox/art/data/moses_statue.jpg")
|
||||
|
||||
field :=
|
||||
&TranslateField{
|
||||
x: -float32(env.Offscreen.Bounds.Width / 2.0),
|
||||
y: -float32(env.Offscreen.Bounds.Height / 2.0),
|
||||
field: &ScaleField{
|
||||
scale: 100.0,
|
||||
field: &AdderField{
|
||||
field:
|
||||
&AdderField{
|
||||
fields: []Field{
|
||||
&ScaleField{scale: 10, field: noiseField},
|
||||
sinXYField,
|
||||
&ScaleField{scale: 3, field: imageField},
|
||||
&ScaleField{scale: 150, field: &SinXYField{ }},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
//sierpinskiLayer := &SierpinskiArrow { dirty: true }
|
||||
sierpinskiLayer := &SierpinskiArrow { dirty: true }
|
||||
|
||||
sketch := NewSketch(env)
|
||||
|
||||
fieldColor := colorCycle.Next()
|
||||
fmt.Printf("field color = %v\n", fieldColor)
|
||||
|
||||
sketch.AddColorLayer("background-magenta", rl.Magenta)
|
||||
sketch.AddColorLayer("background-blue", rl.Blue)
|
||||
sketch.AddColorLayer("background-black", rl.Black)
|
||||
//sketch.AddLayer("field", &FieldLayer{field: field, loColor: rl.NewColor(0, 0, 0, 0), hiColor: fieldColor, dirty: true})
|
||||
//sketch.AddLayer("moses", imageLayer)
|
||||
sketch.AddLayer("field", &FieldLayer{field: field, loColor: rl.NewColor(0, 0, 0, 0), hiColor: fieldColor, dirty: true})
|
||||
actorColor := colorCycle.Next()
|
||||
|
||||
fmt.Printf("actor color = %v\n", actorColor)
|
||||
@@ -149,9 +148,9 @@ func main() {
|
||||
//NewColor(11, 35, 176, 50),
|
||||
|
||||
//r
|
||||
contourLayer := NewContourLayer(&sketch, rng, field, actorColor, -25*math.Pi, 25*math.Pi)
|
||||
contourLayer := NewContourLayer(&sketch, rng, field, actorColor, -4*math.Pi, 4*math.Pi)
|
||||
sketch.AddLayer("contours", contourLayer)
|
||||
//sketch.AddLayer("sierpinski-arrowhead", sierpinskiLayer)
|
||||
sketch.AddLayer("sierpinski-arrowhead", sierpinskiLayer)
|
||||
// aurora := NewImageLayer("/home/d/Dropbox/photos/Events/2025/Aurora/Photo Nov 11 2025, 9 52 03 PM.jpg")
|
||||
// sketch.AddLayer("aurora", aurora)
|
||||
// cave := NewImageLayer("/home/d/Dropbox/photos/Events/2025/ Chelsea and James visit Lindell/Photo Nov 29 2025, 5 26 40 PM (29).jpg")
|
||||
@@ -185,14 +184,6 @@ func main() {
|
||||
|
||||
sketch.Update(env)
|
||||
|
||||
/**
|
||||
* MAIN DRAWING
|
||||
*/
|
||||
rl.BeginDrawing()
|
||||
rl.ClearBackground(rl.GetColor(uint(gui.GetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR))))
|
||||
|
||||
sketch.Draw(env)
|
||||
|
||||
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)
|
||||
@@ -201,19 +192,34 @@ func main() {
|
||||
gui.SetStyle(gui.DEFAULT, gui.TEXT_COLOR_FOCUSED, 0xFFFFFFFF)
|
||||
gui.SetStyle(gui.DEFAULT, gui.BORDER_COLOR_NORMAL, 0x404040FF)
|
||||
|
||||
y := float32(10)
|
||||
/**
|
||||
* MAIN DRAWING
|
||||
*/
|
||||
sg.BeginDrawing()
|
||||
|
||||
minX := float32(60)
|
||||
maxX := float32(g.Layout.Controls.X + g.Layout.Controls.Width - 20)
|
||||
sliderWidth := maxX - minX - 20
|
||||
env.Window.Begin()
|
||||
env.Window.Background(rl.GetColor(uint(gui.GetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR))))
|
||||
env.Window.End()
|
||||
|
||||
sketch.Draw(env)
|
||||
|
||||
margin := 10
|
||||
y := float32(margin)
|
||||
minX := float32(margin)
|
||||
maxX := float32(env.Layout.Controls.X + env.Layout.Controls.Width - 20)
|
||||
sliderWidth := maxX - 0 - 20
|
||||
controlRowHeight := 20
|
||||
controlRect := env.Layout.Controls
|
||||
c := env.Controls
|
||||
c.Begin()
|
||||
//rl.ClearBackground(rl.GetColor(uint(gui.GetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR))))
|
||||
for _, layerTools := range sketch.layerToolsOrdered {
|
||||
|
||||
config := layerTools.config
|
||||
|
||||
//layerTools.texture.Texture
|
||||
|
||||
gui.Label(rl.Rectangle{X: minX, Y: y, Width: 120, Height: 24}, layerTools.name)
|
||||
gui.Label(rl.Rectangle{X: minX, Y: y, Width: controlRect.Width, Height: 24}, layerTools.name)
|
||||
|
||||
y += float32(controlRowHeight + 10)
|
||||
|
||||
@@ -235,24 +241,16 @@ func main() {
|
||||
config.bVisible = gui.Toggle(rl.Rectangle{X: minX, Y: y, Width: 16, Height: 16}, "B", config.bVisible)
|
||||
config.b = uint8(gui.Slider(rl.Rectangle{X: minX + 20, Y: y, Width: sliderWidth, Height: 16}, "", "", float32(config.b), 0, 255))
|
||||
|
||||
/*
|
||||
// don't do anything with saturation / k values yet
|
||||
y += float32(controlRowHeight)
|
||||
config.desaturate = !gui.Toggle(rl.Rectangle{X: minX, Y: y, Width: 16, Height: 16}, "S", !config.desaturate)
|
||||
config.saturation = gui.Slider(rl.Rectangle{X: minX + 20, Y: y, Width: sliderWidth, Height: 16}, "", "", config.saturation, 0, 100)
|
||||
y += float32(controlRowHeight)
|
||||
gui.Label(rl.Rectangle{X: minX, Y: y, Width: 16, Height: 16}, "K")
|
||||
config.kValue = gui.Slider(rl.Rectangle{X: minX + 20, Y: y, Width: sliderWidth, Height: 16}, "", "", config.kValue, 0, 2)
|
||||
*/
|
||||
|
||||
y += float32(controlRowHeight + 10)
|
||||
}
|
||||
|
||||
rl.EndDrawing()
|
||||
c.End()
|
||||
|
||||
sg.EndDrawing()
|
||||
|
||||
if rl.IsKeyDown(rl.KeySpace) {
|
||||
capture := sketch.Capture()
|
||||
if _, err := storage.Save(capture); err != nil {
|
||||
capture := sketch.Capture(env)
|
||||
if _, err := env.Storage.Save(capture); err != nil {
|
||||
log.Printf("Error saving snapshot: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user