mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-13 16:33:28 -04:00
Move #matrix accessor from PlacedItem to Item.
This commit is contained in:
parent
5ff3a07b31
commit
cf4c2b4919
2 changed files with 18 additions and 16 deletions
|
@ -212,6 +212,23 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
|||
this._changed(ChangeFlag.ATTRIBUTE);
|
||||
},
|
||||
|
||||
/**
|
||||
* The item's transformation matrix, defining position and dimensions in the
|
||||
* document.
|
||||
*
|
||||
* @type Matrix
|
||||
* @bean
|
||||
*/
|
||||
getMatrix: function() {
|
||||
return this._matrix;
|
||||
},
|
||||
|
||||
setMatrix: function(matrix) {
|
||||
// Use Matrix#initialize to easily copy over values.
|
||||
this._matrix.initialize(matrix);
|
||||
this._changed(Change.GEOMETRY);
|
||||
},
|
||||
|
||||
/**
|
||||
* The item's position within the project. This is the
|
||||
* {@link Rectangle#center} of the item's {@link #bounds} rectangle.
|
||||
|
@ -790,6 +807,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
|||
ctx = canvas.getContext('2d'),
|
||||
matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y);
|
||||
matrix.applyToContext(ctx);
|
||||
// XXX: Decide how to handle _matrix
|
||||
this.draw(ctx, {});
|
||||
var raster = new Raster(canvas);
|
||||
raster.setBounds(bounds);
|
||||
|
|
|
@ -32,21 +32,5 @@ var PlacedItem = this.PlacedItem = Item.extend(/** @lends PlacedItem# */{
|
|||
// raster, simply preconcatenate the internal matrix with the provided
|
||||
// one.
|
||||
this._matrix.preConcatenate(matrix);
|
||||
},
|
||||
|
||||
/**
|
||||
* The item's transformation matrix, defining position and dimensions in the
|
||||
* document.
|
||||
*
|
||||
* @type Matrix
|
||||
* @bean
|
||||
*/
|
||||
getMatrix: function() {
|
||||
return this._matrix;
|
||||
},
|
||||
|
||||
setMatrix: function(matrix) {
|
||||
this._matrix = matrix.clone();
|
||||
this._changed(Change.GEOMETRY);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue