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. // question for now.
if (!resolution) if (!resolution)
resolution = 72; resolution = 72;
// TODO: use strokebounds for this: var bounds = this.strokeBounds;
var bounds = this.bounds;
var scale = resolution / 72; var scale = resolution / 72;
var canvas = CanvasProvider.getCanvas(bounds.size.multiply(scale)); var canvas = CanvasProvider.getCanvas(bounds.size.multiply(scale));
var context = canvas.getContext('2d'); var context = canvas.getContext('2d');

View file

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

View file

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