2011-02-20 12:34:38 -05:00
|
|
|
PlacedSymbol = Item.extend({
|
|
|
|
beans: true,
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
this.base();
|
|
|
|
if (arguments[0] instanceof Symbol) {
|
|
|
|
this.symbol = arguments[0];
|
|
|
|
} else {
|
|
|
|
this.symbol = new Symbol(arguments[0]);
|
|
|
|
}
|
|
|
|
if (arguments.length > 1) {
|
|
|
|
var arg = arguments[1];
|
|
|
|
if (arg instanceof Matrix) {
|
2011-02-21 13:04:51 -05:00
|
|
|
this.matrix = arguments[2];
|
2011-02-20 12:34:38 -05:00
|
|
|
} else {
|
|
|
|
var offset = Point.read(arguments, 1);
|
|
|
|
this.matrix = new Matrix().translate(offset);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.matrix = new Matrix();
|
|
|
|
}
|
|
|
|
this._bounds = this.symbol.definition.bounds.clone();
|
|
|
|
},
|
|
|
|
|
|
|
|
transformContent: function(matrix, flags) {
|
|
|
|
var bounds = this.bounds;
|
|
|
|
var coords = [bounds.x, bounds.y,
|
|
|
|
bounds.x + bounds.width, bounds.y + bounds.height];
|
|
|
|
matrix.transform(coords, 0, coords, 0, 2);
|
|
|
|
this.matrix.preConcatenate(matrix);
|
|
|
|
bounds.x = coords[0];
|
|
|
|
bounds.y = coords[1];
|
|
|
|
bounds.width = coords[2] - coords[0];
|
|
|
|
bounds.height = coords[3] - coords[1];
|
|
|
|
},
|
|
|
|
|
|
|
|
getBounds: function() {
|
|
|
|
return this._bounds;
|
|
|
|
},
|
|
|
|
|
2011-02-25 06:46:45 -05:00
|
|
|
draw: function(ctx, param) {
|
2011-02-25 07:28:35 -05:00
|
|
|
// TODO: BlendMode isn't working yet for PlacedSymbols.
|
2011-02-25 06:46:45 -05:00
|
|
|
if(this.blendMode != 'normal' && !param.ignoreBlendMode) {
|
|
|
|
BlendMode.process(ctx, this, param);
|
|
|
|
} else {
|
|
|
|
param.ignoreBlendMode = false;
|
|
|
|
// TODO: we need to preserve strokewidth, but still transform the fill
|
|
|
|
ctx.save();
|
|
|
|
this.matrix.applyToContext(ctx);
|
2011-02-25 07:13:46 -05:00
|
|
|
this.symbol.definition.draw(ctx, param);
|
2011-02-25 06:46:45 -05:00
|
|
|
ctx.restore();
|
|
|
|
}
|
2011-02-20 12:34:38 -05:00
|
|
|
}
|
|
|
|
// TODO:
|
|
|
|
// embed()
|
|
|
|
});
|