Added argument parsing to run the solver correctly

This commit is contained in:
Karma Riuk
2023-08-11 12:30:37 +02:00
parent e5840321e2
commit d28c118102
7 changed files with 248 additions and 9 deletions

View File

@ -1,5 +1,46 @@
package writer
import (
"fmt"
"image/color"
"maze-solver/maze"
"github.com/mazznoer/colorgrad"
)
type Writer interface {
Write() error
}
type WriterFactory struct {
Type string
Filename *string
PathChar, WallChar, SolutionChar *string
CellWidth, CellHeight *int
WallColor, PathColor color.Color
SolutionGradient colorgrad.Gradient
}
const (
_IMAGE = "image"
)
var TYPES = map[string]string{
".png": _IMAGE,
}
func (f *WriterFactory) Get(m *maze.SolvedMaze) Writer {
switch f.Type {
case _IMAGE:
return &ImageWriter{
Filename: *f.Filename,
Maze: m,
CellWidth: *f.CellWidth,
CellHeight: *f.CellHeight,
WallColor: f.WallColor,
PathColor: f.PathColor,
SolutionGradient: f.SolutionGradient,
}
}
panic(fmt.Sprintf("Unrecognized writer type %q", f.Type))
}