From f07b0c28f6c4c49b742b1dfb315f7fc755edb223 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 2 May 2015 23:57:37 +0200 Subject: Add ellipse --- cutter.go | 20 +++++++++++++++++++- main.go | 18 +++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/cutter.go b/cutter.go index 2e087a4..d02e3f0 100644 --- a/cutter.go +++ b/cutter.go @@ -92,9 +92,13 @@ const ( ESC = 0x1b ) -func (c Cutter) Send(a ...interface{}) { +func (c Cutter) Add(a ...interface{}) { fmt.Fprint(c, a...) c.WriteByte(ETX) +} + +func (c Cutter) Send(a ...interface{}) { + c.Add(a...) c.Flush() } @@ -367,3 +371,17 @@ func (c Cutter) Circle(p Point, start, end Polar) { start.R, ",", end.R, ",", start.Theta, ",", end.Theta) } + +// Not supported? +func (c Cutter) Curve(a int, ph Path) { + c.Add("Y", a) + for _, p := range ph { + c.Add(",", p) + } + c.Flush() +} + +func (c Cutter) Ellipse(a int, p Point, start, end Polar, theta int) { + c.Send(")", a, ",", p, ",", start.R, ",", end.R, ",", + start.Theta, ",", end.Theta, ",", theta) +} diff --git a/main.go b/main.go index 23cae54..3b8e4ef 100644 --- a/main.go +++ b/main.go @@ -17,11 +17,19 @@ func main() { //cu.Move(Point{300, 300}) //cu.SearchMarks() //cu.Bezier(1, Point{0,0},Point{0,1000},Point{0,0},Point{1000,0}) - for i := 1; i < 10; i++ { - cu.Circle(Point{1000, 1000}, - Polar{100 * i, 0}, - Polar{100 * i, 3600}) - } + + /* + for i := 1; i < 10; i++ { + cu.Circle(Point{1000, 1000}, + Polar{100 * i, 0}, + Polar{100 * i, 3600}) + } + */ + + //cu.Move(Point{500,500}) + + cu.Ellipse(0, Point{3000, 1000}, + Polar{500, 0}, Polar{200, 3600}, 2000) /* for i := 0; i < 9; i++ { -- cgit v1.2.3