From 20674e7f7a3e60376a753cb5343fa63d46f919b7 Mon Sep 17 00:00:00 2001 From: Thomas Friedel Date: Wed, 31 Jan 2018 12:12:42 +0100 Subject: [PATCH] polygons should only be defined by the path since the last moveTo --- paths.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/paths.go b/paths.go index 4ae4704..7e26678 100644 --- a/paths.go +++ b/paths.go @@ -118,7 +118,16 @@ func (cv *Canvas) Stroke() { } func (cv *Canvas) Fill() { - if len(cv.path) < 3 { + lastMove := 0 + for i, p := range cv.path { + if p.move { + lastMove = i + } + } + + path := cv.path[lastMove:] + + if len(path) < 3 { return } @@ -135,7 +144,7 @@ func (cv *Canvas) Fill() { tris := buf[:0] tris = append(tris) - tris = triangulatePath(cv.path, tris) + tris = triangulatePath(path, tris) total := len(tris) for i := 0; i < total; i += 2 { x, y := tris[i], tris[i+1]