2011-03-06 19:50:44 -05:00
|
|
|
/*
|
|
|
|
* Paper.js
|
|
|
|
*
|
|
|
|
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
|
|
|
|
* based on Scriptographer.org and designed to be largely API compatible.
|
|
|
|
* http://scriptographer.org/
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://lehni.org/ & http://jonathanpuckey.com/
|
|
|
|
*
|
|
|
|
* All rights reserved. See LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
2011-03-04 08:34:31 -05:00
|
|
|
var PlacedSymbol = this.PlacedSymbol = Item.extend({
|
2011-02-20 12:34:38 -05:00
|
|
|
beans: true,
|
2011-03-03 17:45:17 -05:00
|
|
|
|
2011-02-20 12:34:38 -05:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
},
|
2011-03-03 17:45:17 -05:00
|
|
|
|
2011-03-03 07:47:55 -05:00
|
|
|
_transform: function(matrix, flags) {
|
2011-03-04 20:26:12 -05:00
|
|
|
// In order to set the right context transformation when drawing the
|
|
|
|
// raster, simply preconcatenate the internal matrix with the provided
|
|
|
|
// one.
|
2011-02-20 12:34:38 -05:00
|
|
|
this.matrix.preConcatenate(matrix);
|
|
|
|
},
|
2011-03-03 17:45:17 -05:00
|
|
|
|
2011-02-20 12:34:38 -05:00
|
|
|
getBounds: function() {
|
2011-03-06 16:26:38 -05:00
|
|
|
return this.symbol._definition.getStrokeBounds(this.matrix);
|
|
|
|
},
|
|
|
|
|
|
|
|
getStrokeBounds: function() {
|
|
|
|
return this.getBounds();
|
2011-03-03 07:19:43 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
draw: function(ctx, param) {
|
|
|
|
// TODO: we need to preserve strokewidth
|
|
|
|
ctx.save();
|
|
|
|
this.matrix.applyToContext(ctx);
|
2011-03-04 20:26:12 -05:00
|
|
|
Item.draw(this.symbol.getDefinition(), ctx, param);
|
2011-03-03 07:19:43 -05:00
|
|
|
ctx.restore();
|
2011-02-20 12:34:38 -05:00
|
|
|
}
|
2011-03-03 07:19:43 -05:00
|
|
|
|
2011-02-20 12:34:38 -05:00
|
|
|
// TODO:
|
|
|
|
// embed()
|
2011-03-03 11:32:55 -05:00
|
|
|
});
|