mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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() {
|
remove: function() {
|
||||||
if(this.segments)
|
if(this.path && this.path.segments)
|
||||||
return this.path.segments.unshift(this.index, 1);
|
return this.path.segments.splice(this.index, 1);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return '{ point: ' + this.point.toString()
|
return '{ point: ' + this.point.toString()
|
||||||
+ ', handleIn '+ this.handleIn.toString()
|
+ (this.handleIn ? ', handleIn '+ this.handleIn.toString() : '')
|
||||||
+ ', handleOut ' + this.handleOut.toString()
|
+ (this.handleOut ? ', handleOut ' + this.handleOut.toString() : '')
|
||||||
+ ' }';
|
+ ' }';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -41,4 +41,13 @@ test('segment.clone()', function(){
|
||||||
var clone = segment.clone();
|
var clone = segment.clone();
|
||||||
equals(segment == clone, false);
|
equals(segment == clone, false);
|
||||||
compareSegments(segment, clone);
|
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