Skip to content

Commit 06ffd80

Browse files
committed
Fix issue in Path#removeSegments() where curves are removed wrongly when start index is 0.
Closes paperjs#200.
1 parent 24443c5 commit 06ffd80

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/path/Path.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,9 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
684684
// one to the left of the segment, not to the right, as normally).
685685
// Also take into account closed paths, which have one curve more
686686
// than segments.
687-
var index = to == count + (this._closed ? 1 : 0) ? from - 1 : from,
687+
var index = from > 0 && to === count + (this._closed ? 1 : 0)
688+
? from - 1
689+
: from,
688690
curves = curves.splice(index, amount);
689691
// Return the removed curves as well, if we're asked to include
690692
// them, but exclude the first curve, since that's shared with the

test/tests/Path_Curves.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
module('Path Curves');
1414

15-
test('path.curves Synchronisation', function() {
15+
test('path.curves synchronisation', function() {
1616
var path = new Path();
1717

1818
path.add(new Point(100, 100));
@@ -52,7 +52,7 @@ test('path.curves Synchronisation', function() {
5252
equals(path.curves.length, 0, 'curves.length');
5353
});
5454

55-
test('path.curves on Closed Paths', function() {
55+
test('path.curves on closed paths', function() {
5656
var path = new Path.Circle(new Point(100, 100) , 100);
5757
equals(path.curves.toString(), "{ point1: { x: 0, y: 100 }, handle1: { x: 0, y: -55.22847 }, handle2: { x: -55.22847, y: 0 }, point2: { x: 100, y: 0 } },{ point1: { x: 100, y: 0 }, handle1: { x: 55.22847, y: 0 }, handle2: { x: 0, y: -55.22847 }, point2: { x: 200, y: 100 } },{ point1: { x: 200, y: 100 }, handle1: { x: 0, y: 55.22847 }, handle2: { x: 55.22847, y: 0 }, point2: { x: 100, y: 200 } },{ point1: { x: 100, y: 200 }, handle1: { x: -55.22847, y: 0 }, handle2: { x: 0, y: 55.22847 }, point2: { x: 0, y: 100 } }");
5858
path.removeSegments(0, 1);
@@ -111,6 +111,6 @@ test('Splitting a straight path should produce linear segments', function() {
111111
var path = new Path.Line([0, 0], [50, 50]);
112112
var path2 = path.split(0, 0.5);
113113
equals(function() {
114-
return path2.firstSegment.linear
114+
return path2.firstSegment.linear;
115115
}, true);
116116
});

0 commit comments

Comments
 (0)