automated snapshot

This commit is contained in:
sumi
2025-12-23 22:23:04 -06:00
parent 312d9895f5
commit b5a0015e16
2 changed files with 30 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
package main
import (
"fmt"
"math"
"math/rand"
"github.com/gen2brain/raylib-go/raylib"
@@ -8,21 +9,27 @@ import (
type ContourLayer struct {
field Field
maxActors uint32
actors []*Actor
actorIndex uint32
rng *rand.Rand
}
func NewContourLayer(sketch *Sketch, rng *rand.Rand, field Field) *ContourLayer {
actors := make([]*Actor, 0)
maxActors := 200000
actors := make([]*Actor, maxActors)
layer := ContourLayer {
rng: rng,
field: field,
actors: actors,
maxActors: uint32(maxActors),
actorIndex: 0,
}
layer.AddActors(1, sketch.sourceWidth, sketch.sourceHeight)
//layer.AddActors(1, sketch.sourceWidth, sketch.sourceHeight)
return &layer
}
@@ -38,18 +45,22 @@ func (s *ContourLayer) AddActors(n, sourceWidth, sourceHeight int32) {
stepSize: 1,
color: rl.NewColor(11, 35, 176, 50),
}
s.actors = append(s.actors, newActor)
s.actors[s.actorIndex] = newActor
s.actorIndex = (s.actorIndex + 1) % s.maxActors
}
}
func (s *ContourLayer) Update(ctx *RenderCtx) {
s.AddActors(100, ctx.SourceWidth, ctx.SourceHeight)
fmt.Printf("num actors = %d\n", len(s.actors))
}
func (s *ContourLayer) Draw(ctx *RenderCtx) {
rl.BeginBlendMode(rl.BlendAdditive)
for _, actor := range s.actors {
actor.Draw()
if actor != nil {
actor.Draw()
}
}
rl.EndBlendMode()
}