4 Commits

Author SHA1 Message Date
2e8ccce703 fix: video visualizer 2023-08-28 11:57:40 +02:00
77843db6de fixed assets 2023-08-27 19:58:22 +02:00
b8546a4d57 fix: video visualizer 2023-08-27 19:35:40 +02:00
741db457fb updated gitignore 2023-08-27 19:35:11 +02:00
6 changed files with 12 additions and 20 deletions

2
.gitignore vendored
View File

@ -21,4 +21,4 @@
go.work
/Session.vim
/maze.png
/maze_sol.png
/sol.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 6.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 12 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 MiB

After

Width:  |  Height:  |  Size: 11 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 9.7 MiB

View File

@ -8,7 +8,6 @@ import (
"os"
"os/exec"
"path"
"sync"
"github.com/mazznoer/colorgrad"
)
@ -25,7 +24,6 @@ func (v *VideoVisualizer) Init(*maze.Maze) {
panic(err)
}
v.ffmpeg_cmd = path
println(path)
}
func (v *VideoVisualizer) Run(lets_go chan<- bool) { lets_go <- true }
@ -36,32 +34,26 @@ func (v *VideoVisualizer) Visualize(solved_chan <-chan *maze.SolvedMaze) {
if err != nil {
panic(err)
}
var wg sync.WaitGroup
i := 0
for solved := range solved_chan {
wg.Add(1)
go func() {
img_writer := writer.ImageWriter{
Filename: path.Join(tmp_dir, fmt.Sprintf("%07v.png", i)),
Maze: solved,
CellWidth: 2,
CellHeight: 2,
CellWidth: 5,
CellHeight: 5,
WallColor: color.Black,
PathColor: color.White,
SolutionGradient: colorgrad.Warm(),
}
img_writer.Write()
wg.Done()
}()
i++
}
wg.Wait()
cmd := exec.Command(
v.ffmpeg_cmd,
"-y",
"-pattern_type", "glob",
"-i", path.Join(tmp_dir, "*.png"),
"-framerate", fmt.Sprint(v.Framerate),
"-r", fmt.Sprint(int(v.Framerate)),
v.Filename,
)
err = cmd.Run()