fix 0 vector len + fix imdraw polyline
This commit is contained in:
parent
0585b0af8c
commit
4619398b9e
|
@ -85,6 +85,9 @@ func (u Vec) Angle() float64 {
|
|||
|
||||
// Unit returns a vector of length 1 facing the direction of u (has the same angle).
|
||||
func (u Vec) Unit() Vec {
|
||||
if u == 0 {
|
||||
return 1
|
||||
}
|
||||
return u / V(u.Len(), 0)
|
||||
}
|
||||
|
||||
|
|
|
@ -433,18 +433,6 @@ func (imd *IMDraw) outlineEllipseArc(radius pixel.Vec, low, high, thickness floa
|
|||
func (imd *IMDraw) polyline(thickness float64, closed bool) {
|
||||
points := imd.getAndClearPoints()
|
||||
|
||||
// filter identical adjacent points
|
||||
filtered := points[:0]
|
||||
for i := 0; i < len(points); i++ {
|
||||
if closed || i+1 < len(points) {
|
||||
j := (i + 1) % len(points)
|
||||
if points[i].pos != points[j].pos {
|
||||
filtered = append(filtered, points[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
points = filtered
|
||||
|
||||
if len(points) < 2 {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue