mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
parent
c12f7c4a64
commit
771bb61038
4 changed files with 30 additions and 7 deletions
|
@ -70,16 +70,20 @@ var Matrix = Base.extend(/** @lends Matrix# */{
|
|||
* @name Matrix#initialize
|
||||
* @param {Matrix} matrix the matrix to copy the values from
|
||||
*/
|
||||
initialize: function Matrix(arg) {
|
||||
initialize: function Matrix(arg, _dontNotify) {
|
||||
var count = arguments.length,
|
||||
ok = true;
|
||||
if (count === 6) {
|
||||
if (count >= 6) { // >= 6 to pass on optional _dontNotify argument.
|
||||
this._set.apply(this, arguments);
|
||||
} else if (count === 1) {
|
||||
} else if (count === 1 || count === 2) {
|
||||
// Support both Matrix and Array arguments through #_set(), and pass
|
||||
// on the optional _dontNotify argument:
|
||||
if (arg instanceof Matrix) {
|
||||
this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty);
|
||||
this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty,
|
||||
_dontNotify);
|
||||
} else if (Array.isArray(arg)) {
|
||||
this._set.apply(this, arg);
|
||||
this._set.apply(this,
|
||||
_dontNotify ? arg.concat([_dontNotify]) : arg);
|
||||
} else {
|
||||
ok = false;
|
||||
}
|
||||
|
|
|
@ -1562,7 +1562,7 @@ new function() { // Injection scope for various item event handlers
|
|||
}
|
||||
// Use Matrix#initialize to easily copy over values.
|
||||
if (!excludeMatrix)
|
||||
this._matrix.set(source._matrix);
|
||||
this._matrix.set(source._matrix, true);
|
||||
// We can't just set _applyMatrix as many item types won't allow it,
|
||||
// e.g. creating a Shape in Path#toShape().
|
||||
// Using the setter instead takes care of it.
|
||||
|
|
|
@ -179,3 +179,22 @@ test('Item#clone() Hierarchy', function() {
|
|||
return clone.isBelow(path2);
|
||||
}, true);
|
||||
});
|
||||
|
||||
test('Item#clone() and #applyMatrix (#1225)', function() {
|
||||
var group = new Group({
|
||||
applyMatrix: false,
|
||||
children: [
|
||||
new Shape.Rectangle({
|
||||
size: [100, 100],
|
||||
point: [100, 100],
|
||||
strokeColor: 'red',
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
group.translate(300, 300);
|
||||
|
||||
equals(function() {
|
||||
return group.clone().matrix.translation;
|
||||
}, new Point(300, 300));
|
||||
});
|
||||
|
|
|
@ -122,7 +122,7 @@ test('PathItem#create() with SVG path-data (#1101)', function() {
|
|||
test('PathItem#compare()', function() {
|
||||
var empty = new Path();
|
||||
var circle = new Path.Circle({
|
||||
point: [100, 100],
|
||||
center: [100, 100],
|
||||
radius: 100
|
||||
});
|
||||
var square = new Path.Rectangle({
|
||||
|
|
Loading…
Reference in a new issue