mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Start implementing Item#matrix, work in progress.
This commit is contained in:
parent
92066a6ecb
commit
de4b5a0d87
4 changed files with 9 additions and 8 deletions
|
@ -110,6 +110,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
paper.project.activeLayer.addChild(this);
|
paper.project.activeLayer.addChild(this);
|
||||||
this._style = PathStyle.create(this);
|
this._style = PathStyle.create(this);
|
||||||
this.setStyle(this._project.getCurrentStyle());
|
this.setStyle(this._project.getCurrentStyle());
|
||||||
|
this._matrix = new Matrix();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -715,6 +716,8 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
if (this.hasOwnProperty(key))
|
if (this.hasOwnProperty(key))
|
||||||
copy[key] = this[key];
|
copy[key] = this[key];
|
||||||
}
|
}
|
||||||
|
// Use Matrix#initialize to easily copy over values.
|
||||||
|
copy._matrix.initialize(this._matrix);
|
||||||
// Copy over the selection state, use setSelected so the item
|
// Copy over the selection state, use setSelected so the item
|
||||||
// is also added to Project#selectedItems if it is selected.
|
// is also added to Project#selectedItems if it is selected.
|
||||||
copy.setSelected(this._selected);
|
copy.setSelected(this._selected);
|
||||||
|
@ -1303,6 +1306,10 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// Scriptographer behaves weirdly then too.
|
// Scriptographer behaves weirdly then too.
|
||||||
if (!children || children.length == 0)
|
if (!children || children.length == 0)
|
||||||
return new Rectangle();
|
return new Rectangle();
|
||||||
|
// Concate the nate the passed matrix with the inner one, or start with
|
||||||
|
// one.
|
||||||
|
matrix = matrix ? matrix.clone().concatenate(this._matrix)
|
||||||
|
: this._matrix;
|
||||||
var x1 = Infinity,
|
var x1 = Infinity,
|
||||||
x2 = -x1,
|
x2 = -x1,
|
||||||
y1 = x1,
|
y1 = x1,
|
||||||
|
|
|
@ -101,8 +101,7 @@ var PlacedSymbol = this.PlacedSymbol = PlacedItem.extend(/** @lends PlacedSymbol
|
||||||
|
|
||||||
draw: function(ctx, param) {
|
draw: function(ctx, param) {
|
||||||
if (param.selection) {
|
if (param.selection) {
|
||||||
Item.drawSelectedBounds(this.symbol._definition.getStrokeBounds(),
|
Item.drawSelectedBounds(this._getBounds('bounds'), ctx, this._matrix);
|
||||||
ctx, this._matrix);
|
|
||||||
} else {
|
} else {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
this._matrix.applyToContext(ctx);
|
this._matrix.applyToContext(ctx);
|
||||||
|
|
|
@ -55,7 +55,6 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
||||||
/*#*/ } // options.server
|
/*#*/ } // options.server
|
||||||
this.setImage(object);
|
this.setImage(object);
|
||||||
}
|
}
|
||||||
this._matrix = new Matrix();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function() {
|
||||||
|
@ -67,7 +66,6 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
||||||
image.getContext('2d').drawImage(this._canvas, 0, 0);
|
image.getContext('2d').drawImage(this._canvas, 0, 0);
|
||||||
}
|
}
|
||||||
var copy = new Raster(image);
|
var copy = new Raster(image);
|
||||||
copy._matrix = this._matrix.clone();
|
|
||||||
return this._clone(copy);
|
return this._clone(copy);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,7 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function() {
|
||||||
var copy = this._clone(new PointText(this._point));
|
return this._clone(new PointText(this._point));
|
||||||
// Use Matrix#initialize to easily copy over values.
|
|
||||||
copy._matrix.initialize(this._matrix);
|
|
||||||
return copy;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue