mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Use insert: false option in creation of all clones.
Still needs implementing in Item constructor.
This commit is contained in:
parent
cfbd356247
commit
b7aea1e527
4 changed files with 18 additions and 8 deletions
|
@ -99,7 +99,10 @@ var PlacedSymbol = Item.extend(/** @lends PlacedSymbol# */{
|
|||
},
|
||||
|
||||
clone: function(insert) {
|
||||
return this._clone(new PlacedSymbol(this.symbol), insert);
|
||||
return this._clone(new PlacedSymbol({
|
||||
symbol: this.symbol,
|
||||
insert: false
|
||||
}), insert);
|
||||
},
|
||||
|
||||
isEmpty: function() {
|
||||
|
|
|
@ -94,14 +94,17 @@ var Raster = Item.extend(/** @lends Raster# */{
|
|||
},
|
||||
|
||||
clone: function(insert) {
|
||||
var element = this._image;
|
||||
if (!element) {
|
||||
var param = { insert: false },
|
||||
image = this._image;
|
||||
if (image) {
|
||||
param.image = image;
|
||||
} else {
|
||||
// If the Raster contains a Canvas object, we need to create
|
||||
// a new one and draw this raster's canvas on it.
|
||||
element = CanvasProvider.getCanvas(this._size);
|
||||
element.getContext('2d').drawImage(this._canvas, 0, 0);
|
||||
var canvas = param.canvas = CanvasProvider.getCanvas(this._size);
|
||||
canvas.getContext('2d').drawImage(this._canvas, 0, 0);
|
||||
}
|
||||
return this._clone(new Raster(element), insert);
|
||||
return this._clone(new Raster(param), insert);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,7 +91,11 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
},
|
||||
|
||||
clone: function(insert) {
|
||||
var copy = this._clone(new Path(this._segments), insert);
|
||||
var copy = this._clone(new Path({
|
||||
segments: this._segments,
|
||||
insert: false
|
||||
}), insert);
|
||||
// Speed up things a little by copy over values that don't need checking
|
||||
copy._closed = this._closed;
|
||||
if (this._clockwise !== undefined)
|
||||
copy._clockwise = this._clockwise;
|
||||
|
|
|
@ -48,7 +48,7 @@ var PointText = TextItem.extend(/** @lends PointText# */{
|
|||
},
|
||||
|
||||
clone: function(insert) {
|
||||
return this._clone(new PointText(), insert);
|
||||
return this._clone(new PointText({ insert: false }), insert);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue