automated snapshot

This commit is contained in:
sumi
2025-12-23 11:08:12 -06:00
parent ecac2dcebe
commit 2c61cd2f46
3 changed files with 29 additions and 15 deletions

34
main.go
View File

@@ -3,7 +3,7 @@ package main
import ( import (
// "fmt" // "fmt"
"log" "log"
"math/rand" //"math/rand"
"os" "os"
"time" "time"
@@ -46,7 +46,7 @@ func main() {
t0 := time.Now() t0 := time.Now()
/* /*
*/
rng := rand.New(rand.NewSource(0)) rng := rand.New(rand.NewSource(0))
imageField := NewImageField("/home/d/Dropbox/art/passage/data/david.png") imageField := NewImageField("/home/d/Dropbox/art/passage/data/david.png")
@@ -59,24 +59,34 @@ func main() {
field: imageField, field: imageField,
}, },
} }
*/
sketch := NewSketch(sourceWidth, sourceHeight) sketch := NewSketch(sourceWidth, sourceHeight)
sierpinskiLayer := &SierpinskiArrow { dirty: true } sierpinskiLayer := &SierpinskiArrow { dirty: true }
contourLayer := NewContourLayer(&sketch, rng, field) //contourLayer := NewContourLayer(&sketch, rng, field)
//sketch.CreateLayer("testPattern", &TestPattern{}, int32(sourceWidth), int32(sourceHeight)) //sketch.CreateLayer("field", &FieldLayer{field: field, dirty: true})
//sketch.CreateLayer("actors", &contourLayer, int32(sourceWidth), int32(sourceHeight)) //sketch.CreateLayer("contours", contourLayer)
//sketch.CreateLayer("field", &FieldLayer{field: &field, dirty: true}, int32(sourceWidth), int32(sourceHeight))
sketch.CreateLayer("contours", contourLayer)
sketch.CreateLayer("sierpinski", sierpinskiLayer) sketch.CreateLayer("sierpinski", sierpinskiLayer)
ports := MakePorts() ports := MakePorts()
ports["sierpinskiArrowAngle"] = Sine { ports["sierpinskiArrowAngle"] =
Amp: 120, Const {
Bias: 100, V: 60,
Freq: 0.1, }
}
ports["sierpinskiArrowDepth"] =
Const {
V: 6,
}
ports["sierpinskiArrowLength"] =
Const {
V: 10000,
}
for !rl.WindowShouldClose() { for !rl.WindowShouldClose() {

View File

@@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
rl "github.com/gen2brain/raylib-go/raylib" rl "github.com/gen2brain/raylib-go/raylib"
) )
@@ -9,6 +10,8 @@ type SierpinskiArrow struct{
} }
func (s *SierpinskiArrow) Draw(ctx *RenderCtx) { func (s *SierpinskiArrow) Draw(ctx *RenderCtx) {
rl.Translatef(float32(ctx.SourceWidth) / 2.0, float32(ctx.SourceHeight) / 2.0, 0)
rl.ClearBackground(rl.NewColor(0, 0, 0, 0))
sierpinskiArrow(ctx, int(ctx.Ports["sierpinskiArrowDepth"]), ctx.Ports["sierpinskiArrowLength"]) sierpinskiArrow(ctx, int(ctx.Ports["sierpinskiArrowDepth"]), ctx.Ports["sierpinskiArrowLength"])
} }
@@ -21,6 +24,7 @@ func (s *SierpinskiArrow) IsDirty() bool {
} }
func sierpinskiArrow(ctx *RenderCtx, order int, length float64) { func sierpinskiArrow(ctx *RenderCtx, order int, length float64) {
fmt.Printf("drawing SierpinskiArrow, order = %d, length = %.2f\n", order, length)
if order == 0 { if order == 0 {
curve(ctx, order, length, ctx.Ports["sierpinskiArrowAngle"]) curve(ctx, order, length, ctx.Ports["sierpinskiArrowAngle"])
} else { } else {

View File

@@ -70,8 +70,6 @@ func NewSketch(sourceWidth, sourceHeight int32) Sketch {
func (s *Sketch) CreateLayer(name string, layer Layer) { func (s *Sketch) CreateLayer(name string, layer Layer) {
texture := rl.LoadRenderTexture(s.sourceWidth, s.sourceHeight) texture := rl.LoadRenderTexture(s.sourceWidth, s.sourceHeight)
rl.GenTextureMipmaps(&texture.Texture)
rl.SetTextureFilter(texture.Texture, rl.FilterTrilinear)
config := NewLayerConfig() config := NewLayerConfig()
layerTools := layerTools :=
LayerTools { LayerTools {
@@ -91,9 +89,11 @@ func (s *Sketch) Draw(ctx *RenderCtx) {
layer.Update(ctx) layer.Update(ctx)
if instance.layer.IsDirty() { if instance.layer.IsDirty() {
rl.BeginTextureMode(instance.texture) rl.BeginTextureMode(instance.texture)
rl.PushMatrix()
layer.Draw(ctx) layer.Draw(ctx)
rl.PopMatrix()
rl.EndTextureMode() rl.EndTextureMode()
rl.GenTextureMipmaps(&instance.texture.Texture) //rl.GenTextureMipmaps(&instance.texture.Texture)
} }
} }