automated snapshot

This commit is contained in:
sumi
2025-12-18 00:12:08 -06:00
parent 57ad5d0d5e
commit f982f194dd

22
main.go
View File

@@ -23,8 +23,6 @@ func main() {
os.MkdirAll(snapshotsDir, 0755) os.MkdirAll(snapshotsDir, 0755)
//rng := rand.New(rand.NewSource(0))
log := log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile) log := log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
storage, err := NewStorage(snapshotsDir) storage, err := NewStorage(snapshotsDir)
@@ -53,7 +51,7 @@ func main() {
field := field :=
ScaleField { ScaleField {
Scale: 100.0, Scale: 10.0,
Field: &SimplexNoiseField { Field: &SimplexNoiseField {
Noise: opensimplex.NewNormalized32(0), Noise: opensimplex.NewNormalized32(0),
}, },
@@ -87,7 +85,7 @@ func main() {
rl.BeginDrawing() rl.BeginDrawing()
//rl.ClearBackground(rl.Black) //rl.ClearBackground(rl.Black)
rl.BeginMode2D(camera) rl.BeginMode2D(camera)
rl.BeginBlendMode(rl.BlendAdditive)
t := time.Since(t0).Seconds() t := time.Since(t0).Seconds()
// set up RenderCtx // set up RenderCtx
@@ -115,6 +113,7 @@ func main() {
} }
} }
rl.EndBlendMode()
rl.EndMode2D() rl.EndMode2D()
// HUD // HUD
@@ -136,9 +135,7 @@ func (s *FieldSketch) Draw(ctx *RenderCtx) {
//screen := rl.Vector2 { X: float32(x) - float32(ctx.Width) / 2.0, Y: float32(y) - float32(ctx.Height) / 2.0 } //screen := rl.Vector2 { X: float32(x) - float32(ctx.Width) / 2.0, Y: float32(y) - float32(ctx.Height) / 2.0 }
screen := rl.Vector2 { X: float32(x), Y: float32(y) } screen := rl.Vector2 { X: float32(x), Y: float32(y) }
world := rl.GetScreenToWorld2D(screen, ctx.Cam) world := rl.GetScreenToWorld2D(screen, ctx.Cam)
//fmt.Printf("screen -> %v, world -> %v\n", screen, world)
v := s.Field.Get(world.X, world.Y) v := s.Field.Get(world.X, world.Y)
//fmt.Printf("%.3f\n", v)
clr := GrayCurve(v, 1.0) clr := GrayCurve(v, 1.0)
rl.DrawPixelV(world, clr) rl.DrawPixelV(world, clr)
} }
@@ -152,12 +149,14 @@ type ContourSketch struct {
func NewContourSketch(rng *rand.Rand, field Field) ContourSketch { func NewContourSketch(rng *rand.Rand, field Field) ContourSketch {
actors := make([]*Actor, 10000) actors := make([]*Actor, 1000)
for i := range len(actors) { for i := range len(actors) {
actors[i] = actors[i] =
&Actor { &Actor {
position: RandRadialVec(rng, 0, 500, 0, 360), position: RandRadialVec(rng, 0, 500, 0, 360),
field: field, field: field,
stepSize: 0.5,
color: rl.NewColor(11, 35, 176, 200),
} }
} }
@@ -176,14 +175,15 @@ func (s *ContourSketch) Draw(ctx *RenderCtx) {
type Actor struct { type Actor struct {
position rl.Vector2 position rl.Vector2
field Field field Field
stepSize float32
color rl.Color
} }
func (a *Actor) Draw() { func (a *Actor) Draw() {
v := a.field.Get(a.position.X, a.position.Y) v := a.field.Get(a.position.X, a.position.Y)
rad := rl.Remap(v, 0, 1, 0, 2 * math.Pi) rad := rl.Remap(v, 0, 1, 0, 3 * math.Pi)
stepSize := float32(2.0) 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))) }
nextPosition := rl.Vector2 { X: a.position.X + stepSize*float32(math.Cos(float64(rad))), Y: a.position.Y + stepSize*float32(math.Sin(float64(rad))) } rl.DrawLineV(a.position, nextPosition, a.color)
rl.DrawLineV(a.position, nextPosition, rl.NewColor(255, 255, 255, 25))
//fmt.Printf("position %v -> nextPosition %v \n", a.position, nextPosition) //fmt.Printf("position %v -> nextPosition %v \n", a.position, nextPosition)
a.position = nextPosition a.position = nextPosition
} }