From b2188be567e7faaed523e63f16725745ece91150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 29 Oct 2013 17:37:45 +0100 Subject: [PATCH] Make sure _globalMatrix is not set to false values in Item#rasterize(). --- src/item/Item.js | 4 +++- src/project/Project.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index cbe93a0c..02ece697 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -3160,7 +3160,9 @@ var Item = Base.extend(Callback, /** @lends Item# */{ var transforms = param.transforms, parentMatrix = transforms[transforms.length - 1], globalMatrix = parentMatrix.clone().concatenate(this._matrix); - transforms.push(this._globalMatrix = globalMatrix); + // Only keep track of transformation if told so. See Project#draw() + if (param.trackTransforms) + transforms.push(this._globalMatrix = globalMatrix); // If the item has a blendMode or is defining an opacity, draw it on // a temporary canvas first and composite the canvas afterwards. // Paths with an opacity < 1 that both define a fillColor diff --git a/src/project/Project.js b/src/project/Project.js index 45b55407..eac46372 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -370,7 +370,12 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{ offset: new Point(0, 0), // A stack of concatenated matrices, to keep track of the current // global matrix, since Canvas is not able tell us (yet). - transforms: [matrix] + transforms: [matrix], + // Tell the drawing routine that we want to track nested matrices + // in param.transforms, and that we want it to set _globalMatrix + // as used below. Item#rasterize() and Raster#getAverageColor() do + // not need to set this. + trackTransforms: true }); for (var i = 0, l = this.layers.length; i < l; i++) this.layers[i].draw(ctx, param);