Skip to content

Commit

Permalink
bugfix in ClosePath
Browse files Browse the repository at this point in the history
  • Loading branch information
tfriedel6 committed May 9, 2020
1 parent e37f4f5 commit 3a0ca2c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions path2d.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,16 @@ func (p *Path2D) ClosePath() {
if len(p.p) < 2 {
return
}
if isSamePoint(p.p[len(p.p)-1].pos, p.p[0].pos, 0.1) {
return
}
closeIdx := 0
for i := len(p.p) - 1; i >= 0; i-- {
if p.p[i].flags&pathMove != 0 {
closeIdx = i
break
}
}
p.LineTo(p.p[closeIdx].pos[0], p.p[closeIdx].pos[1])
if !isSamePoint(p.p[len(p.p)-1].pos, p.p[0].pos, 0.1) {
p.LineTo(p.p[closeIdx].pos[0], p.p[closeIdx].pos[1])
}
p.p[len(p.p)-1].next = p.p[closeIdx].next
p.p[len(p.p)-1].flags |= pathAttach
}
Expand Down

0 comments on commit 3a0ca2c

Please sign in to comment.