diff --git a/config/changelog.yaml b/config/changelog.yaml index ed971708506..d033aa6e98b 100644 --- a/config/changelog.yaml +++ b/config/changelog.yaml @@ -6,6 +6,8 @@ Unreleased: Fixed: benjamin: - Fix for incorrect length of the ribbon + core: + - Fix an edge case in utils.pointOnCurve for perfect horizontal curves 2.7.2: date: 2020-07-29 diff --git a/packages/core/src/utils.js b/packages/core/src/utils.js index b16424b8d1e..dd15e7654e0 100644 --- a/packages/core/src/utils.js +++ b/packages/core/src/utils.js @@ -89,6 +89,14 @@ export function pointOnCurve(start, cp1, cp2, end, check) { p1: { x: check.x - 1, y: check.y }, p2: { x: check.x + 1, y: check.y } }) + if (intersections.length === 0) { + // Handle edge case of a curve that's a perfect horizontal line + intersections = curve.intersects({ + p1: { x: check.x, y: check.y - 1 }, + p2: { x: check.x, y: check.y + 1 } + }) + } + if (intersections.length > 0) return intersections.shift() else return false }