diff --git a/geometry.go b/geometry.go index 12a324f2ef9400183104c203277c009bdbc4ecc7..af8b24ec7e30e77e1990c3e256b593b9f1bbe4fc 100644 --- a/geometry.go +++ b/geometry.go @@ -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) } diff --git a/imdraw/imdraw.go b/imdraw/imdraw.go index fbef4e975bf4f1e58d0d06cd9954cea70a54217d..3a69537295523fe200216693b6f71c741d4611b0 100644 --- a/imdraw/imdraw.go +++ b/imdraw/imdraw.go @@ -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 }