Plotter code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
926 B

package plotter
import (
"codeisalie/gono/pkg/comm"
"codeisalie/gono/pkg/plotter"
"fmt"
"time"
)
// Run ...
func Run(c *comm.Comm) {
svg := plotter.SvgParser{}
svg.Parse("drawing.svg", c.Cfg)
// for _, path := range svg.Paths {
// fmt.Printf("%+v\n", path)
// for _, point := range path.List {
// fmt.Printf("-- %+v\n", point)
// }
// }
// svg.Paths
fmt.Println(svg.Root.ViewBox)
c.Send(comm.EnableMotors)
c.Send(comm.GetReportPosition)
for _, path := range svg.Paths {
fmt.Printf("%+v\n", path)
// if len(path.List) <= 1 {
// continue
// }
c.Send(comm.SetPenUp)
for idx, point := range path.List {
c.Send(comm.DrawLine, point.X, point.Y, 1)
if idx == 0 && len(path.List) > 1 {
c.Send(comm.SetPenDown)
}
}
c.Send(comm.SetPenUp)
}
c.Send(comm.DrawLine, c.Cfg.DrawingArea.Home.X, c.Cfg.DrawingArea.Home.Y, 1)
c.Send(comm.DisableMotors)
time.Sleep(2 * time.Second)
}