From e3ed85e3952898216dde15e786eb22ea5ba1ff62 Mon Sep 17 00:00:00 2001 From: sapics Date: Mon, 15 Oct 2018 16:27:50 +0900 Subject: [PATCH] Fix error in single segment closed path flatten --- CHANGELOG.md | 3 ++- src/path/PathFlattener.js | 2 +- test/tests/Path.js | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6d38a4..9107c6af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,8 +17,9 @@ solid fixes, as we are paving the way for the upcoming release of `1.0.0`. Here - Prevent `paper` object from polluting the global scope (#1544). - Make sure `Path#arcTo()` always passes through the provide through point (#1477). -- Draw shadows on `Raster` images (#1437) +- Draw shadows on `Raster` images (#1437). - Fix boolean operation edge case (#1506, #1513, #1515). +- Fix single segment closed path flatten error (#1338, #1569). - Remove memory leak on gradient colors (#1499). - Support alpha channel in CSS colors (#1468, #1539, #1565). - Improve color CSS string parsing and documentation. diff --git a/src/path/PathFlattener.js b/src/path/PathFlattener.js index 8fc12392..1df208a4 100644 --- a/src/path/PathFlattener.js +++ b/src/path/PathFlattener.js @@ -95,7 +95,7 @@ var PathFlattener = Base.extend({ segment1 = segment2; } if (path._closed) - addCurve(segment2, segments[0]); + addCurve(segment2 || segment1, segments[0]); this.curves = curves; this.parts = parts; this.length = length; diff --git a/test/tests/Path.js b/test/tests/Path.js index 7b268c2c..d985fe7b 100644 --- a/test/tests/Path.js +++ b/test/tests/Path.js @@ -450,6 +450,13 @@ test('Path#flatten(maxDistance)', function() { }, true, 'The points of the last and before last segments should not be so close, that calling toString on them returns the same string value.'); }); +test('Path#single segment closed path flatten (#1338)', function() { + var p = PathItem.create("m445.26701,223.69688c6.1738,8.7566 -7.05172,14.0468 0,0z"); + p.strokeColor = "red"; + p.flatten(); + expect(0); +}); + test('Path#curves after removing a segment - 1', function() { var path = new paper.Path([0, 0], [1, 1], [2, 2]); var prevCurves = path.curves.slice();