From 2f9531810cb8e0596578532f21c27af4bb00f321 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Thu, 3 Mar 2011 14:43:37 +0100 Subject: [PATCH] Implement todos about using strokeBounds instead of bounds. --- src/item/Item.js | 3 +-- src/item/PlacedSymbol.js | 3 +-- test/tests/PlacedSymbol.js | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 35428b11..469c4c42 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -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'); diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index 24da5078..547a86f0 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -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; }, diff --git a/test/tests/PlacedSymbol.js b/test/tests/PlacedSymbol.js index cb8f0051..cfd58f95 100644 --- a/test/tests/PlacedSymbol.js +++ b/test/tests/PlacedSymbol.js @@ -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.'); }); \ No newline at end of file