From 1f71aa3f15e4503d66194d653814bc367265a4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20H=C3=A4nsel?= Date: Tue, 25 Apr 2017 07:59:14 +0200 Subject: [PATCH] Convert LineTo to MoveTo for the first point of a path Same for QuadCurveTo and CubicCurveTo. Closes #133 --- path.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/path.go b/path.go index 57ba3ff..04a6572 100644 --- a/path.go +++ b/path.go @@ -76,9 +76,10 @@ func (p *Path) MoveTo(x, y float64) { // LineTo adds a line to the current path func (p *Path) LineTo(x, y float64) { if len(p.Components) == 0 { //special case when no move has been done - p.MoveTo(0, 0) + p.MoveTo(x, y) + } else { + p.appendToPath(LineToCmp, x, y) } - p.appendToPath(LineToCmp, x, y) p.x = x p.y = y } @@ -86,9 +87,10 @@ func (p *Path) LineTo(x, y float64) { // QuadCurveTo adds a quadratic bezier curve to the current path func (p *Path) QuadCurveTo(cx, cy, x, y float64) { if len(p.Components) == 0 { //special case when no move has been done - p.MoveTo(0, 0) + p.MoveTo(x, y) + } else { + p.appendToPath(QuadCurveToCmp, cx, cy, x, y) } - p.appendToPath(QuadCurveToCmp, cx, cy, x, y) p.x = x p.y = y } @@ -96,9 +98,10 @@ func (p *Path) QuadCurveTo(cx, cy, x, y float64) { // CubicCurveTo adds a cubic bezier curve to the current path func (p *Path) CubicCurveTo(cx1, cy1, cx2, cy2, x, y float64) { if len(p.Components) == 0 { //special case when no move has been done - p.MoveTo(0, 0) + p.MoveTo(x, y) + } else { + p.appendToPath(CubicCurveToCmp, cx1, cy1, cx2, cy2, x, y) } - p.appendToPath(CubicCurveToCmp, cx1, cy1, cx2, cy2, x, y) p.x = x p.y = y }