Implement todos about using strokeBounds instead of bounds.

This commit is contained in:
Jonathan Puckey 2011-03-03 14:43:37 +01:00
parent 941c3c7346
commit 2f9531810c
3 changed files with 5 additions and 7 deletions

View file

@ -540,8 +540,7 @@ var Item = Base.extend({
// question for now.
if (!resolution)
resolution = 72;
// TODO: use strokebounds for this:
var bounds = this.bounds;
var bounds = this.strokeBounds;
var scale = resolution / 72;
var canvas = CanvasProvider.getCanvas(bounds.size.multiply(scale));
var context = canvas.getContext('2d');

View file

@ -19,8 +19,7 @@ var PlacedSymbol = Item.extend({
} else {
this.matrix = new Matrix();
}
// TODO: this should use strokeBounds:
this._bounds = this.symbol.definition.bounds.clone();
this._bounds = this.symbol.definition.strokeBounds.clone();
// TODO: should size be cached here, or on Symbol?
this._size = this._bounds.size;
},

View file

@ -8,17 +8,17 @@ test('placedSymbol bounds', function() {
// These tests currently fail because we haven't implemented
// Item#strokeBounds yet.
compareRectangles(placedSymbol.bounds,
compareRectangles(placedSymbol.strokeBounds,
new Rectangle(-50.5, -50.5, 101, 101),
'PlacedSymbol initial bounds.');
placedSymbol.scale(0.5);
compareRectangles(placedSymbol.bounds,
compareRectangles(placedSymbol.strokeBounds,
{ x: -25.5, y: -25.5, width: 51, height: 51 },
'Bounds after scale.');
placedSymbol.rotate(40);
compareRectangles(placedSymbol.bounds,
compareRectangles(placedSymbol.strokeBounds,
{ x: -25.50049, y: -25.50049, width: 51.00098, height: 51.00098 },
'Bounds after rotation.');
});