From 23f38c6e5b28221ffc3c8e69b9648228af06a5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 9 Jul 2011 09:51:06 +0200 Subject: [PATCH] Fix Path#flatten(), where we don't want to add last segment again for closed paths. --- src/path/Path.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/path/Path.js b/src/path/Path.js index 23e0e215..cdac2bd9 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -687,8 +687,10 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ pos = 0, // Adapt step = maxDistance so the points distribute evenly. step = flattener.length / Math.ceil(flattener.length / maxDistance), - // Add half of step to end, so imprecisions are ok too. - end = flattener.length + step / 2; + // Add/remove half of step to end, so imprecisions are ok too. + // For closed paths, remove it, because we don't want to add last + // segment again + end = flattener.length + (this._closed ? -step : step) / 2; // Iterate over path and evaluate and add points at given offsets var segments = []; while (pos <= end) {