Compare commits
5 Commits
7bac753507
...
main
Author | SHA1 | Date | |
---|---|---|---|
d1108be94b | |||
2e8ccce703 | |||
77843db6de | |||
b8546a4d57 | |||
741db457fb |
2
.gitignore
vendored
@ -21,4 +21,4 @@
|
|||||||
go.work
|
go.work
|
||||||
/Session.vim
|
/Session.vim
|
||||||
/maze.png
|
/maze.png
|
||||||
/maze_sol.png
|
/sol.png
|
||||||
|
@ -29,8 +29,8 @@ couple of hours (which I was honestly not expecting).
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- `go >= 1.21`
|
- `go` >= 1.21
|
||||||
- `ffmpeg` (optional, for video visualization, see [visualization methods](#visulazation-methods)
|
- `ffmpeg` (optional, for video visualization, see [visualization methods](#visulazation-methods))
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 6.3 MiB |
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 12 MiB |
Before Width: | Height: | Size: 16 MiB After Width: | Height: | Size: 11 MiB |
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 9.7 MiB |
@ -8,7 +8,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/mazznoer/colorgrad"
|
"github.com/mazznoer/colorgrad"
|
||||||
)
|
)
|
||||||
@ -25,7 +24,6 @@ func (v *VideoVisualizer) Init(*maze.Maze) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
v.ffmpeg_cmd = path
|
v.ffmpeg_cmd = path
|
||||||
println(path)
|
|
||||||
}
|
}
|
||||||
func (v *VideoVisualizer) Run(lets_go chan<- bool) { lets_go <- true }
|
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
var wg sync.WaitGroup
|
|
||||||
i := 0
|
i := 0
|
||||||
for solved := range solved_chan {
|
for solved := range solved_chan {
|
||||||
wg.Add(1)
|
img_writer := writer.ImageWriter{
|
||||||
go func() {
|
Filename: path.Join(tmp_dir, fmt.Sprintf("%07v.png", i)),
|
||||||
img_writer := writer.ImageWriter{
|
Maze: solved,
|
||||||
Filename: path.Join(tmp_dir, fmt.Sprintf("%07v.png", i)),
|
CellWidth: 5,
|
||||||
Maze: solved,
|
CellHeight: 5,
|
||||||
CellWidth: 2,
|
WallColor: color.Black,
|
||||||
CellHeight: 2,
|
PathColor: color.White,
|
||||||
WallColor: color.Black,
|
SolutionGradient: colorgrad.Warm(),
|
||||||
PathColor: color.White,
|
}
|
||||||
SolutionGradient: colorgrad.Warm(),
|
img_writer.Write()
|
||||||
}
|
|
||||||
img_writer.Write()
|
|
||||||
wg.Done()
|
|
||||||
}()
|
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
v.ffmpeg_cmd,
|
v.ffmpeg_cmd,
|
||||||
"-y",
|
"-y",
|
||||||
"-pattern_type", "glob",
|
"-pattern_type", "glob",
|
||||||
"-i", path.Join(tmp_dir, "*.png"),
|
"-i", path.Join(tmp_dir, "*.png"),
|
||||||
"-framerate", fmt.Sprint(v.Framerate),
|
"-r", fmt.Sprint(int(v.Framerate)),
|
||||||
v.Filename,
|
v.Filename,
|
||||||
)
|
)
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
|