Skip to content

Commit

Permalink
glitches on batch stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimbbp committed Mar 9, 2024
1 parent efe015a commit 8efca74
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
5 changes: 3 additions & 2 deletions devnotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.
4 changes: 2 additions & 2 deletions src/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

}
Expand Down
4 changes: 2 additions & 2 deletions src/mosaic/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
Expand Down
15 changes: 9 additions & 6 deletions src/video/batchResSequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
14 changes: 7 additions & 7 deletions src/video/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

}

Expand Down

0 comments on commit 8efca74

Please sign in to comment.