From 8efca747de4be8216279bef6e045cbd4e9e7d2e2 Mon Sep 17 00:00:00 2001 From: joachimbbp <104856283+joachimbbp@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:19:12 -0500 Subject: [PATCH] glitches on batch stuff --- devnotes.md | 5 +++-- src/main/main.go | 4 ++-- src/mosaic/draw.go | 4 ++-- src/video/batchResSequence.go | 15 +++++++++------ src/video/sequence.go | 14 +++++++------- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/devnotes.md b/devnotes.md index a51d9a0..786edf8 100644 --- a/devnotes.md +++ b/devnotes.md @@ -21,5 +21,6 @@ Refactoring for useability March 08 2024: Dogfodding the app with my own video. -It feels like compositing the sprites on with alpha only sometimes creates compelling results. -I'm getting the handle on what kind of images look and feel best \ No newline at end of file + It feels like compositing the sprites on with alpha only sometimes creates compelling results. + I'm getting the handle on what kind of images look and feel best +Introduced some restrictions on the goroutines (from copilot). I need to brush up on the logic with these, but the purpose is to keep the program for crashing with the new batch feature. Currently it doesn't seem to restrict performance: generating video took 0 hours 1 minutes 34 seconds with this new 10 core restriction. \ No newline at end of file diff --git a/src/main/main.go b/src/main/main.go index afd952c..c23695e 100644 --- a/src/main/main.go +++ b/src/main/main.go @@ -49,13 +49,13 @@ func main() { false, ) case "batchRes": - batchResolutions := []int{120, 80, 60, 48, 40, 30, 24, 16, 15, 12} + batchResIndices := []int{0, 4, 9} util.TimeIt( "generating video for multiple resolutions", video.BatchSequence, util.SequencePath, util.DatabasePath, - batchResolutions, + batchResIndices, ) } diff --git a/src/mosaic/draw.go b/src/mosaic/draw.go index a43bb13..dc15d17 100644 --- a/src/mosaic/draw.go +++ b/src/mosaic/draw.go @@ -9,7 +9,7 @@ import ( "github.com/joachimbbp/spritefire/src/util" ) -func Draw(canvas []util.IndexedSprite, frameName string, spriteSizeIndex int) { +func Draw(canvas []util.IndexedSprite, prefix string, frameName string, spriteSizeIndex int) { spriteSize := util.ResizeResolutions[spriteSizeIndex] fmt.Println("\nDrawing and saving image to disk") @@ -44,7 +44,7 @@ func Draw(canvas []util.IndexedSprite, frameName string, spriteSizeIndex int) { img := rl.LoadImageFromTexture(targetTexture.Texture) - rl.ExportImage(*img, util.ImageOutput+"/"+frameName) + rl.ExportImage(*img, util.ImageOutput+"/"+prefix+frameName) rl.UnloadImage(img) rl.UnloadRenderTexture(targetTexture) } diff --git a/src/video/batchResSequence.go b/src/video/batchResSequence.go index d1fd3d7..50b639e 100644 --- a/src/video/batchResSequence.go +++ b/src/video/batchResSequence.go @@ -2,18 +2,21 @@ package video import ( "fmt" + + "github.com/joachimbbp/spritefire/src/util" ) func BatchSequence(sequencePath string, spriteColorDbPath string, spriteResIndices []int) { fmt.Printf("not implemented yet, batchSequence") fmt.Println(sequencePath, spriteColorDbPath, spriteResIndices) - for resIndex := range spriteResIndices { - print((spriteResIndices[resIndex])) - fmt.Println("") - print(resIndex) + for _, resIndex := range spriteResIndices { + fmt.Println("resolution: ") + fmt.Println((util.SpriteSizes[resIndex])) + + fmt.Println("index: ") + fmt.Println(resIndex) - fmt.Println("") - Sequence(sequencePath, spriteColorDbPath, resIndex, true) + //Sequence(sequencePath, spriteColorDbPath, resIndex, true) } } diff --git a/src/video/sequence.go b/src/video/sequence.go index 8358056..284abcb 100644 --- a/src/video/sequence.go +++ b/src/video/sequence.go @@ -15,9 +15,9 @@ import ( func Sequence(sequencePath string, spriteColorDbPath string, spriteSizeIndex int, batch bool) { prefix := "" + spriteSize := util.SpriteSizes[spriteSizeIndex] if batch { - prefix = strconv.Itoa(int(util.SpriteSizes[spriteSizeIndex])) + "_" - //prefix = "prefix" + prefix = strconv.Itoa(int(spriteSize)) + "_" } frames, err := os.ReadDir(sequencePath) @@ -49,14 +49,14 @@ func Sequence(sequencePath string, spriteColorDbPath string, spriteSizeIndex int } wg.Wait() - frameNames := make([]string, 0, len(sequenceData)) + keys := make([]string, 0, len(sequenceData)) for k := range sequenceData { - frameNames = append(frameNames, k) + keys = append(keys, k) } - sort.Strings(frameNames) + sort.Strings(keys) - for _, frameName := range frameNames { - mosaic.Draw(sequenceData[frameName], prefix+frameName, spriteSizeIndex) + for _, frameName := range keys { + mosaic.Draw(sequenceData[frameName], prefix, frameName, spriteSizeIndex) }