Fix issue in Path#removeSegments() where curves are removed wrongly when start index is 0.

Closes #200.
This commit is contained in:
Jürg Lehni 2013-04-26 08:46:57 -07:00
parent 24443c548a
commit 06ffd8089d
2 changed files with 6 additions and 4 deletions

View file

@ -684,7 +684,9 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
// one to the left of the segment, not to the right, as normally).
// Also take into account closed paths, which have one curve more
// than segments.
var index = to == count + (this._closed ? 1 : 0) ? from - 1 : from,
var index = from > 0 && to === count + (this._closed ? 1 : 0)
? from - 1
: from,
curves = curves.splice(index, amount);
// Return the removed curves as well, if we're asked to include
// them, but exclude the first curve, since that's shared with the

View file

@ -12,7 +12,7 @@
module('Path Curves');
test('path.curves Synchronisation', function() {
test('path.curves synchronisation', function() {
var path = new Path();
path.add(new Point(100, 100));
@ -52,7 +52,7 @@ test('path.curves Synchronisation', function() {
equals(path.curves.length, 0, 'curves.length');
});
test('path.curves on Closed Paths', function() {
test('path.curves on closed paths', function() {
var path = new Path.Circle(new Point(100, 100) , 100);
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 } }");
path.removeSegments(0, 1);
@ -111,6 +111,6 @@ test('Splitting a straight path should produce linear segments', function() {
var path = new Path.Line([0, 0], [50, 50]);
var path2 = path.split(0, 0.5);
equals(function() {
return path2.firstSegment.linear
return path2.firstSegment.linear;
}, true);
});