mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Segment.js: fix toString and remove methods. Add test for segment.remove().
This commit is contained in:
parent
9b5e18c795
commit
c1d2cab5d9
2 changed files with 13 additions and 4 deletions
|
@ -115,15 +115,15 @@ Segment = Base.extend({
|
|||
},
|
||||
|
||||
remove: function() {
|
||||
if(this.segments)
|
||||
return this.path.segments.unshift(this.index, 1);
|
||||
if(this.path && this.path.segments)
|
||||
return this.path.segments.splice(this.index, 1);
|
||||
return false;
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
return '{ point: ' + this.point.toString()
|
||||
+ ', handleIn '+ this.handleIn.toString()
|
||||
+ ', handleOut ' + this.handleOut.toString()
|
||||
+ (this.handleIn ? ', handleIn '+ this.handleIn.toString() : '')
|
||||
+ (this.handleOut ? ', handleOut ' + this.handleOut.toString() : '')
|
||||
+ ' }';
|
||||
},
|
||||
|
||||
|
|
|
@ -41,4 +41,13 @@ test('segment.clone()', function(){
|
|||
var clone = segment.clone();
|
||||
equals(segment == clone, false);
|
||||
compareSegments(segment, clone);
|
||||
});
|
||||
|
||||
test('segment.remove()', function(){
|
||||
var doc = new Doc();
|
||||
var path = new Path([10, 10], [5, 5], [10, 10]);
|
||||
console.log(path.segments);
|
||||
path.segments[1].remove();
|
||||
console.log(path.segments);
|
||||
equals(path.segments.length, 2);
|
||||
});
|
Loading…
Reference in a new issue