automated snapshot
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user