diff --git a/.gitignore b/.gitignore index 81235e16d..8f753a3bd 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ package-lock.json [._]s[a-rt-v][a-z] [._]ss[a-gi-z] [._]sw[a-p] + +.idea/ diff --git a/plugins/_path.js b/plugins/_path.js index d02c46523..30d3eba3e 100644 --- a/plugins/_path.js +++ b/plugins/_path.js @@ -253,10 +253,18 @@ export const intersects = function (path1, path2) { // Check intersection of every subpath of the first path with every subpath of the second. return hullNest1.some(function (hull1) { - if (hull1.list.length < 3) return false; + if (hull1.list.length < 3) { + // When there are only two points in the convex hull, add the first point to close the polygon. + // This can happen when the path is only a line. + hull1.list.push(hull1.list[0]); + } return hullNest2.some(function (hull2) { - if (hull2.list.length < 3) return false; + if (hull2.list.length < 3) { + // When there are only two points in the convex hull, add the first point to close the polygon. + // This can happen when the path is only a line. + hull2.list.push(hull2.list[0]); + } var simplex = [getSupport(hull1, hull2, [1, 0])], // create the initial simplex direction = minus(simplex[0]); // set the direction to point towards the origin diff --git a/test/plugins/removeOffCanvasPaths.07.svg.txt b/test/plugins/removeOffCanvasPaths.07.svg.txt new file mode 100644 index 000000000..26782d6d7 --- /dev/null +++ b/test/plugins/removeOffCanvasPaths.07.svg.txt @@ -0,0 +1,13 @@ +Should not throw when path starts with relative move and is within the view box + +=== + + + + + +@@@ + + + +