polygons should only be defined by the path since the last moveTo
This commit is contained in:
parent
4a0b551a93
commit
20674e7f7a
1 changed files with 11 additions and 2 deletions
13
paths.go
13
paths.go
|
@ -118,7 +118,16 @@ func (cv *Canvas) Stroke() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cv *Canvas) Fill() {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +144,7 @@ func (cv *Canvas) Fill() {
|
||||||
tris := buf[:0]
|
tris := buf[:0]
|
||||||
tris = append(tris)
|
tris = append(tris)
|
||||||
|
|
||||||
tris = triangulatePath(cv.path, tris)
|
tris = triangulatePath(path, tris)
|
||||||
total := len(tris)
|
total := len(tris)
|
||||||
for i := 0; i < total; i += 2 {
|
for i := 0; i < total; i += 2 {
|
||||||
x, y := tris[i], tris[i+1]
|
x, y := tris[i], tris[i+1]
|
||||||
|
|
Loading…
Reference in a new issue