automated snapshot

This commit is contained in:
sumi
2025-12-22 01:43:35 -06:00
parent 922c8bb2f6
commit 2f10e026a0
3 changed files with 73 additions and 20 deletions

28
main.go
View File

@@ -15,21 +15,21 @@ import (
const (
targetWidth = 1000
targetHeight = 1000
sourceScale = 8
sourceScale = 2
snapshotsDir = "snapshots"
)
type TextureCam struct {
SourceWidth int
SourceHeight int
SourceWidth int32
SourceHeight int32
LookAt rl.Vector2
Zoom float32
}
func main() {
sourceWidth := sourceScale * targetWidth
sourceHeight := sourceScale * targetHeight
sourceWidth := int32(sourceScale * targetWidth)
sourceHeight := int32(sourceScale * targetHeight)
os.MkdirAll(snapshotsDir, 0755)
log := log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
@@ -64,7 +64,7 @@ func main() {
x: -float32(sourceWidth / 2.0),
y: -float32(sourceHeight / 2.0),
field: &ScaleField{
scale: 5.0,
scale: 1.0,
field: &imageField,
},
}
@@ -72,7 +72,7 @@ func main() {
contourLayer := NewContourLayer(rng, &field, sourceWidth, sourceHeight)
sketch := NewSketch()
sketch := NewSketch(sourceWidth, sourceHeight)
//sketch.CreateLayer("testPattern", &TestPattern{}, int32(sourceWidth), int32(sourceHeight))
//sketch.CreateLayer("actors", &contourLayer, int32(sourceWidth), int32(sourceHeight))
//sketch.CreateLayer("field", &FieldLayer{field: &field, dirty: true}, int32(sourceWidth), int32(sourceHeight))
@@ -112,7 +112,9 @@ func main() {
sketch.Draw(renderCtx)
if rl.IsKeyDown(rl.KeySpace) {
if _, err := storage.Save(); err != nil {
capture := sketch.Capture()
if _, err := storage.Save(capture); err != nil {
log.Printf("Error saving snapshot: %v\n", err)
}
}
@@ -172,11 +174,11 @@ type ContourLayer struct {
field Field
actors []*Actor
rng *rand.Rand
sourceWidth int
sourceHeight int
sourceWidth int32
sourceHeight int32
}
func NewContourLayer(rng *rand.Rand, field Field, sourceWidth int, sourceHeight int) ContourLayer {
func NewContourLayer(rng *rand.Rand, field Field, sourceWidth int32, sourceHeight int32) ContourLayer {
actors := make([]*Actor, 0)
@@ -195,8 +197,8 @@ func NewContourLayer(rng *rand.Rand, field Field, sourceWidth int, sourceHeight
func (s *ContourLayer) AddActors(n int) {
for range n {
x := s.rng.Int() % s.sourceWidth
y := s.rng.Int() % s.sourceHeight
x := s.rng.Int31() % s.sourceWidth
y := s.rng.Int31() % s.sourceHeight
newActor :=
&Actor {
position: rl.Vector2{X: float32(x), Y: float32(y)},