Convert LineTo to MoveTo for the first point of a path

Same for QuadCurveTo and CubicCurveTo.

Closes #133
This commit is contained in:
André Hänsel 2017-04-25 07:59:14 +02:00
parent 1286d3b203
commit 1f71aa3f15

15
path.go
View file

@ -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
}