From efafa0f6f7a072d16da0fe024c1b8c86d49b4584 Mon Sep 17 00:00:00 2001 From: Thomas Friedel Date: Thu, 22 Feb 2018 14:19:47 +0100 Subject: [PATCH] fixed a problem with miter joints if the lines are parallel --- paths.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/paths.go b/paths.go index e1cf07d..e710a59 100644 --- a/paths.go +++ b/paths.go @@ -289,8 +289,17 @@ func (cv *Canvas) lineJoint(p pathPoint, p0, p1, p2, l0p0, l0p1, l0p2, l0p3 lm.V l1p2 := p2.Add(v3) l1p3 := p1.Add(v3) - ip0, _, _ := lineIntersection(l0p0, l0p1, l1p1, l1p0) - ip1, _, _ := lineIntersection(l0p2, l0p3, l1p3, l1p2) + var ip0, ip1 lm.Vec2 + if l0p1.Sub(l1p1).LenSqr() < 0.000000001 { + ip0 = l0p1.Sub(l1p1).MulF(0.5).Add(l1p1) + } else { + ip0, _, _ = lineIntersection(l0p0, l0p1, l1p1, l1p0) + } + if l0p3.Sub(l1p3).LenSqr() < 0.000000001 { + ip1 = l0p3.Sub(l1p3).MulF(0.5).Add(l1p3) + } else { + ip1, _, _ = lineIntersection(l0p2, l0p3, l1p3, l1p2) + } tris = append(tris, p1[0], p1[1], l0p1[0], l0p1[1], ip0[0], ip0[1],