Start implementing Item#matrix, work in progress.

This commit is contained in:
Jürg Lehni 2011-11-26 10:15:01 +01:00
parent 92066a6ecb
commit de4b5a0d87
4 changed files with 9 additions and 8 deletions

View file

@ -110,6 +110,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
paper.project.activeLayer.addChild(this);
this._style = PathStyle.create(this);
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))
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
// is also added to Project#selectedItems if it is selected.
copy.setSelected(this._selected);
@ -1303,6 +1306,10 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
// Scriptographer behaves weirdly then too.
if (!children || children.length == 0)
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,
x2 = -x1,
y1 = x1,

View file

@ -101,8 +101,7 @@ var PlacedSymbol = this.PlacedSymbol = PlacedItem.extend(/** @lends PlacedSymbol
draw: function(ctx, param) {
if (param.selection) {
Item.drawSelectedBounds(this.symbol._definition.getStrokeBounds(),
ctx, this._matrix);
Item.drawSelectedBounds(this._getBounds('bounds'), ctx, this._matrix);
} else {
ctx.save();
this._matrix.applyToContext(ctx);

View file

@ -55,7 +55,6 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
/*#*/ } // options.server
this.setImage(object);
}
this._matrix = new Matrix();
},
clone: function() {
@ -67,7 +66,6 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
image.getContext('2d').drawImage(this._canvas, 0, 0);
}
var copy = new Raster(image);
copy._matrix = this._matrix.clone();
return this._clone(copy);
},

View file

@ -42,10 +42,7 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
},
clone: function() {
var copy = this._clone(new PointText(this._point));
// Use Matrix#initialize to easily copy over values.
copy._matrix.initialize(this._matrix);
return copy;
return this._clone(new PointText(this._point));
},
/**