mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
parent
96e0f9ef6c
commit
9a772678a8
2 changed files with 10 additions and 9 deletions
|
@ -417,7 +417,8 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
var total = this._countCurves(),
|
var total = this._countCurves(),
|
||||||
// If we're adding a new segment to the end of an open path,
|
// If we're adding a new segment to the end of an open path,
|
||||||
// we need to step one index down to get its curve.
|
// we need to step one index down to get its curve.
|
||||||
from = Math.max(index + amount - 1 === total ? index - 1 : index, 0),
|
from = index > 0 && index + amount - 1 === total ? index - 1
|
||||||
|
: index,
|
||||||
start = from,
|
start = from,
|
||||||
to = Math.min(from + amount, total);
|
to = Math.min(from + amount, total);
|
||||||
if (segs._curves) {
|
if (segs._curves) {
|
||||||
|
|
|
@ -99,23 +99,23 @@ test('Curve list after removing a segment - 2', function() {
|
||||||
}, 2, 'After creating a path with three segments, we should have two curves. By accessing path.curves we also make sure the curves are created internally.');
|
}, 2, 'After creating a path with three segments, we should have two curves. By accessing path.curves we also make sure the curves are created internally.');
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.segments[2].remove();
|
return path.lastSegment.remove();
|
||||||
}, true, 'Removing the paths last segment should be successful.');
|
}, true, 'Removing the last segment should be successful.');
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.curves.length;
|
return path.curves.length;
|
||||||
}, 1, 'After removing the last segment, we should be left with one curve.');
|
}, 1, 'After removing the last segment, we should be left with one curve.');
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.segments[1].remove();
|
return path.lastSegment.remove();
|
||||||
}, true, 'Removing the paths last segment should be successful.');
|
}, true, 'Removing last segment should be successful.');
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.curves.length;
|
return path.curves.length;
|
||||||
}, 0, 'After removing the last segment, we should be left with no curves.');
|
}, 0, 'After removing the last segment, we should be left with no curves.');
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.segments[0].remove();
|
return path.lastSegment.remove();
|
||||||
}, true, 'Removing the final remaining segment should be successful.');
|
}, true, 'Removing the final remaining segment should be successful.');
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
|
@ -127,13 +127,13 @@ test('Curve list after removing a segment - 2', function() {
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.curves.length;
|
return path.curves.length;
|
||||||
}, 1, 'After adding two new segments at the end, we should have one curve again.');
|
}, 1, 'After adding two new segments, we should have one curve again.');
|
||||||
|
|
||||||
path.addSegment([2, 2]);
|
path.addSegment([2, 2]);
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.curves.length;
|
return path.curves.length;
|
||||||
}, 2, 'After adding a new segment at the end, we should have two curves again.');
|
}, 2, 'After adding a new segment, we should have two curves again.');
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.curves[1].segment1 === path.curves[0].segment2;
|
return path.curves[1].segment1 === path.curves[0].segment2;
|
||||||
|
@ -143,7 +143,7 @@ test('Curve list after removing a segment - 2', function() {
|
||||||
|
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return path.curves.length;
|
return path.curves.length;
|
||||||
}, 4, 'After adding tow new segments at the end, we should have four curves now.');
|
}, 4, 'After adding two new segments at the end, we should have four curves now.');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Splitting a straight path should produce segments without handles', function() {
|
test('Splitting a straight path should produce segments without handles', function() {
|
||||||
|
|
Loading…
Reference in a new issue