2023-08-17 13:37:54 +02:00
|
|
|
package visualizer
|
|
|
|
|
|
|
|
import (
|
2023-08-27 11:21:26 +02:00
|
|
|
"fmt"
|
2023-08-17 13:37:54 +02:00
|
|
|
"maze-solver/maze"
|
|
|
|
)
|
|
|
|
|
2023-08-27 11:21:26 +02:00
|
|
|
type Visualizer interface {
|
|
|
|
Init(*maze.Maze)
|
|
|
|
Visualize(<-chan *maze.SolvedMaze)
|
|
|
|
Run(lets_go chan<- bool)
|
|
|
|
}
|
2023-08-17 13:37:54 +02:00
|
|
|
|
2023-08-27 11:21:26 +02:00
|
|
|
type VisualizerFactory struct {
|
|
|
|
Type *string
|
|
|
|
Filename *string
|
|
|
|
Framerate *float64
|
2023-08-17 13:37:54 +02:00
|
|
|
}
|
|
|
|
|
2023-08-27 11:21:26 +02:00
|
|
|
const (
|
|
|
|
_VIDEO = "video"
|
|
|
|
_WINDOW = "window"
|
|
|
|
)
|
|
|
|
|
|
|
|
var VIZ_METHODS = []string{
|
|
|
|
_VIDEO,
|
|
|
|
_WINDOW,
|
2023-08-17 13:37:54 +02:00
|
|
|
}
|
|
|
|
|
2023-08-27 11:21:26 +02:00
|
|
|
func (f *VisualizerFactory) Get() Visualizer {
|
|
|
|
switch *f.Type {
|
|
|
|
case _VIDEO:
|
|
|
|
return &VideoVisualizer{
|
|
|
|
Filename: *f.Filename,
|
|
|
|
Framerate: *f.Framerate,
|
|
|
|
}
|
|
|
|
case _WINDOW:
|
|
|
|
return &WindowVisualizer{}
|
|
|
|
}
|
|
|
|
panic(fmt.Sprintf("Unrecognized visualizer type %q", *f.Type))
|
2023-08-17 13:37:54 +02:00
|
|
|
}
|