maze-solver-go/visualizer/visualizer.go

42 lines
641 B
Go
Raw Normal View History

2023-08-17 13:37:54 +02:00
package visualizer
import (
"fmt"
2023-08-17 13:37:54 +02:00
"maze-solver/maze"
)
type Visualizer interface {
Init(*maze.Maze)
Visualize(<-chan *maze.SolvedMaze)
Run(lets_go chan<- bool)
}
2023-08-17 13:37:54 +02:00
type VisualizerFactory struct {
Type *string
Filename *string
Framerate *float64
2023-08-17 13:37:54 +02:00
}
const (
_VIDEO = "video"
_WINDOW = "window"
)
var VIZ_METHODS = []string{
_VIDEO,
_WINDOW,
2023-08-17 13:37:54 +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
}