From 027e531860a9932fb295a5927ad58358367a1dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Mon, 12 Nov 2018 22:39:00 +0100 Subject: [PATCH 1/3] fixes issue #86: Decorators drawn when offset larger than line length --- src/patternUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/patternUtils.js b/src/patternUtils.js index 7b0e44c..332589c 100644 --- a/src/patternUtils.js +++ b/src/patternUtils.js @@ -66,10 +66,10 @@ function projectPatternOnPointPath(pts, pattern) { // 2. generate the positions of the pattern as offsets from the path start const positionOffsets = []; let positionOffset = startOffsetPixels; - do { + while(repeatIntervalPixels > 0 && positionOffset < totalPathLength - endOffsetPixels) { positionOffsets.push(positionOffset); positionOffset += repeatIntervalPixels; - } while(repeatIntervalPixels > 0 && positionOffset < totalPathLength - endOffsetPixels); + } // 3. projects offsets to segments let segmentIndex = 0; From 71676cec66e6f1875ba4ba37db5bdf80538ce282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sun, 3 May 2020 10:37:57 +0200 Subject: [PATCH 2/3] Bugfix, last change would not generate any symbols when repeat=fase --- src/patternUtils.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/patternUtils.js b/src/patternUtils.js index 332589c..525606a 100644 --- a/src/patternUtils.js +++ b/src/patternUtils.js @@ -59,16 +59,19 @@ function projectPatternOnPointPath(pts, pattern) { const endOffset = asRatioToPathLength(pattern.endOffset, totalPathLength); const repeat = asRatioToPathLength(pattern.repeat, totalPathLength); - const repeatIntervalPixels = totalPathLength * repeat; - const startOffsetPixels = offset > 0 ? totalPathLength * offset : 0; - const endOffsetPixels = endOffset > 0 ? totalPathLength * endOffset : 0; - // 2. generate the positions of the pattern as offsets from the path start const positionOffsets = []; - let positionOffset = startOffsetPixels; - while(repeatIntervalPixels > 0 && positionOffset < totalPathLength - endOffsetPixels) { - positionOffsets.push(positionOffset); - positionOffset += repeatIntervalPixels; + if (repeat) { + const repeatIntervalPixels = totalPathLength * repeat; + const endOffsetPixels = endOffset > 0 ? totalPathLength * endOffset : 0; + let positionOffset = offset > 0 ? totalPathLength * offset : 0; + + while(repeatIntervalPixels > 0 && positionOffset < totalPathLength - endOffsetPixels) { + positionOffsets.push(positionOffset); + positionOffset += repeatIntervalPixels; + } + } else { + positionOffsets.push(offset > 0 ? totalPathLength * offset : 0); } // 3. projects offsets to segments From 5cd1ff78e8f19cbd0f348ecd6a1b9d75c7d4b654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Sun, 3 May 2020 10:39:15 +0200 Subject: [PATCH 3/3] Bugfix, when repeating symbols generate a symbol even at the last pixel --- src/patternUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/patternUtils.js b/src/patternUtils.js index 525606a..67c001b 100644 --- a/src/patternUtils.js +++ b/src/patternUtils.js @@ -66,7 +66,7 @@ function projectPatternOnPointPath(pts, pattern) { const endOffsetPixels = endOffset > 0 ? totalPathLength * endOffset : 0; let positionOffset = offset > 0 ? totalPathLength * offset : 0; - while(repeatIntervalPixels > 0 && positionOffset < totalPathLength - endOffsetPixels) { + while(repeatIntervalPixels > 0 && positionOffset <= totalPathLength - endOffsetPixels) { positionOffsets.push(positionOffset); positionOffset += repeatIntervalPixels; }