diff --git a/src/item/Item.js b/src/item/Item.js index 1496b70b..d3a2b99d 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1961,7 +1961,6 @@ function(name) { scale = (fill ? itemRatio > rectRatio : itemRatio < rectRatio) ? rectangle.width / bounds.width : rectangle.height / bounds.height, - delta = rectangle.getCenter().subtract(bounds.getCenter()), newBounds = new Rectangle(new Point(), Size.create(bounds.width * scale, bounds.height * scale)); newBounds.setCenter(rectangle.getCenter()); diff --git a/src/path/Path.js b/src/path/Path.js index 52da17f2..2d2efd36 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -68,6 +68,11 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ delete this._length; // Clockwise state becomes undefined as soon as geometry changes. delete this._clockwise; + // Curves are no longer valid + if (this._curves != null) { + for (var i = 0; i < this._curves.length; i++) + this._curves[i]._changed(Change.GEOMETRY) + } } else if (flags & ChangeFlag.STROKE) { // TODO: We could preserve the purely geometric bounds that are not // affected by stroke: _bounds.bounds and _bounds.handleBounds diff --git a/test/tests/Path_Curves.js b/test/tests/Path_Curves.js index dd16d6ea..7b21d68f 100644 --- a/test/tests/Path_Curves.js +++ b/test/tests/Path_Curves.js @@ -38,6 +38,12 @@ test('path.curves Synchronisation', function() { path.removeSegments(1, 2); equals(path.segments.toString(), "{ point: { x: 0, y: 100 } },{ point: { x: 100, y: 100 } }", "path.segments: path.add(new Point(100, 100));\npath.removeSegments(1, 2);"); equals(path.curves.toString(), "{ point1: { x: 0, y: 100 }, point2: { x: 100, y: 100 } },{ point1: { x: 100, y: 100 }, point2: { x: 0, y: 100 } }", "path.curves: path.add(new Point(100, 100));\npath.removeSegments(1, 2);"); + + // Transform the path, and the curves length should be invalidated (first, force-cache the first segment's length by accessing it + path.curves[0].length; + ok(path.curves[0]._length, 'Curve length does not appear to be cached'); + path.scale(2, [0, 0]); + equals(path.curves[0].length, 200, 'Curve length should be updated when path is transformed') }); test('path.flatten(maxDistance)', function() { @@ -53,4 +59,4 @@ test('path.flatten(maxDistance)', function() { equals(function() { return path.lastSegment.point.toString() != path.segments[path.segments.length - 2].point.toString(); }, true, 'The points of the last and before last segments should not be so close, that calling toString on them returns the same string value.'); -}); \ No newline at end of file +});