mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Move Path#get/setSegments back to top and remove test-code for array object extension.
This commit is contained in:
parent
781b315808
commit
053fb2d955
1 changed files with 19 additions and 39 deletions
|
@ -28,6 +28,25 @@ var Path = this.Path = PathItem.extend({
|
|||
|| typeof segments[0] !== 'object' ? arguments : segments);
|
||||
},
|
||||
|
||||
/**
|
||||
* The segments contained within the path.
|
||||
*/
|
||||
getSegments: function() {
|
||||
return this._segments;
|
||||
},
|
||||
|
||||
setSegments: function(segments) {
|
||||
var length = segments.length;
|
||||
if (!this._segments) {
|
||||
this._segments = [];
|
||||
} else {
|
||||
this.setSelected(false);
|
||||
this._segments.length = 0;
|
||||
}
|
||||
for(var i = 0; i < length; i++)
|
||||
this._add(Segment.read(segments, i, 1));
|
||||
},
|
||||
|
||||
/**
|
||||
* The curves contained within the path.
|
||||
*/
|
||||
|
@ -409,45 +428,6 @@ var Path = this.Path = PathItem.extend({
|
|||
}
|
||||
}
|
||||
};
|
||||
}, new function() { // Scope for segments list change detection
|
||||
|
||||
var segmentsFields = Base.each(
|
||||
['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'],
|
||||
function(name) {
|
||||
var func = Array.prototype[name];
|
||||
this[name] = function() {
|
||||
return func.apply(this, arguments);
|
||||
};
|
||||
}, {});
|
||||
|
||||
return {
|
||||
beans: true,
|
||||
|
||||
/**
|
||||
* The segments contained within the path.
|
||||
*/
|
||||
getSegments: function() {
|
||||
return this._segments;
|
||||
},
|
||||
|
||||
setSegments: function(segments) {
|
||||
var length = segments.length;
|
||||
if (!this._segments) {
|
||||
// Enhance the _segments array with functions that watch for
|
||||
// change.
|
||||
this._segments = Base.each(segmentsFields,
|
||||
function(value, name) {
|
||||
this[name] = value;
|
||||
}, []);
|
||||
} else {
|
||||
this.setSelected(false);
|
||||
this._segments.length = 0;
|
||||
}
|
||||
for(var i = 0; i < length; i++) {
|
||||
this._add(Segment.read(segments, i, 1));
|
||||
}
|
||||
}
|
||||
};
|
||||
}, new function() { // Inject methods that require scoped privates
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue