diff --git a/src/item/Item.js b/src/item/Item.js index ff7cee37..5aaa3b9f 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -3940,6 +3940,7 @@ var Item = Base.extend(Emitter, /** @lends Item# */{ // Get the transformation matrix for non-scaling strokes. var strokeMatrix = parentStrokeMatrix ? parentStrokeMatrix.chain(matrix) + // pass `true` for dontMerge : !this.getStrokeScaling(true) && getViewMatrix(globalMatrix), // If we're drawing into a separate canvas and a clipItem is defined // for the current rendering loop, we need to draw the clip item diff --git a/src/item/Shape.js b/src/item/Shape.js index 27bfb383..374d1bd0 100644 --- a/src/item/Shape.js +++ b/src/item/Shape.js @@ -272,14 +272,17 @@ var Shape = Item.extend(/** @lends Shape# */{ _getBounds: function(getter, matrix) { var rect = new Rectangle(this._size).setCenter(0, 0), - expandStrokeWidth = getter !== 'getBounds' && this.hasStroke() - && this.getStrokeWidth(); - if (expandStrokeWidth && this.getStrokeScaling(true)) - rect = rect.expand(expandStrokeWidth); + strokeWidth = getter === 'getStrokeBounds' && this.hasStroke() + && this.getStrokeWidth(), + scaling = strokeWidth && this.getStrokeScaling(); + // If we're getting the strokeBounds, include the stroke width before + // or after transforming the rect, based on strokeScaling. + if (strokeWidth && scaling) + rect = rect.expand(strokeWidth); if (matrix) rect = matrix._transformBounds(rect); - if (expandStrokeWidth && !this.getStrokeScaling(true)) - rect = rect.expand(expandStrokeWidth); + if (strokeWidth && !scaling) + rect = rect.expand(strokeWidth); return rect; } }, diff --git a/test/tests/Item_Bounds.js b/test/tests/Item_Bounds.js index 8ee4cf8a..0991383c 100644 --- a/test/tests/Item_Bounds.js +++ b/test/tests/Item_Bounds.js @@ -77,7 +77,7 @@ test('path.bounds when contained in a transformed group', function() { equals(path.bounds, new Rectangle(110, 110, 50, 50), 'path.bounds after group translation'); }); -test('shape.strokeBounds when scale with strokeScaling is false', function(){ +test('shape.strokeBounds when scaled with strokeScaling set to false', function(){ var shape = new Shape.Rectangle({ point: [5, 5], size: [20, 20], @@ -85,9 +85,9 @@ test('shape.strokeBounds when scale with strokeScaling is false', function(){ strokeColor: 'black', strokeWidth: 10 }); - equals(shape.getStrokeBounds(), new Rectangle(0, 0, 30, 30), 'shape.strokeBounds before scaling'); + equals(shape.strokeBounds, new Rectangle(0, 0, 30, 30), 'shape.strokeBounds before scaling'); shape.scale(2, 2, [5, 5]); - equals(shape.getStrokeBounds(), new Rectangle(0, 0, 50, 50), 'shape.strokeBounds after scaling'); + equals(shape.strokeBounds, new Rectangle(0, 0, 50, 50), 'shape.strokeBounds after scaling'); }); test('text.bounds', function() {