automated snapshot

This commit is contained in:
sumi
2025-12-26 14:42:39 -06:00
parent 6ab7c8d7e1
commit 80d3a0fde8
3 changed files with 47 additions and 34 deletions

View File

@@ -8,14 +8,16 @@ import (
type ContourLayer struct {
field Field
rng *rand.Rand
maxActors uint32
actors []*Actor
actorIndex uint32
actorColor rl.Color
rng *rand.Rand
loActorAngle float32
hiActorAngle float32
}
func NewContourLayer(sketch *Sketch, rng *rand.Rand, field Field, color rl.Color) *ContourLayer {
func NewContourLayer(sketch *Sketch, rng *rand.Rand, field Field, color rl.Color, loActorAngle float32, hiActorAngle float32) *ContourLayer {
maxActors := 200000
@@ -28,6 +30,8 @@ func NewContourLayer(sketch *Sketch, rng *rand.Rand, field Field, color rl.Color
maxActors: uint32(maxActors),
actorColor: color,
actorIndex: 0,
loActorAngle: loActorAngle,
hiActorAngle: hiActorAngle,
}
return &layer
@@ -43,6 +47,8 @@ func (s *ContourLayer) AddActors(color rl.Color, n, sourceWidth, sourceHeight in
field: s.field,
stepSize: 1,
color: s.actorColor,
loAngle: s.loActorAngle,
hiAngle: s.hiActorAngle,
}
s.actors[s.actorIndex] = newActor
s.actorIndex = (s.actorIndex + 1) % s.maxActors
@@ -72,11 +78,13 @@ type Actor struct {
field Field
stepSize float32
color rl.Color
loAngle float32
hiAngle float32
}
func (a *Actor) Draw() {
v := a.field.Get(a.position.X, a.position.Y)
rad := rl.Remap(v, 0, 1, 0, 5*math.Pi)
rad := rl.Remap(v, 0, 1, a.loAngle, a.hiAngle)
nextPosition := rl.Vector2{X: a.position.X + a.stepSize*float32(math.Cos(float64(rad))), Y: a.position.Y + a.stepSize*float32(math.Sin(float64(rad)))}
rl.DrawLineV(a.position, nextPosition, a.color)
a.position = nextPosition