From 6c2f72d30a245e08eab19a1ed75591a3d0582d78 Mon Sep 17 00:00:00 2001 From: Zeno Zeng Date: Wed, 7 Jul 2021 00:07:55 +0800 Subject: [PATCH] fix: push/pop transformMatrixStack when save/restore, for https://github.com/zenozeng/p5.js-svg/issues/191 --- context.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/context.js b/context.js index 78965b5..9410415 100644 --- a/context.js +++ b/context.js @@ -486,6 +486,10 @@ export default (function () { parent.appendChild(group); this.__currentElement = group; this.__stack.push(this.__getStyleState()); + if (!this.__transformMatrixStack) { + this.__transformMatrixStack = []; + } + this.__transformMatrixStack.push(this.getTransform()); }; /** @@ -500,6 +504,9 @@ export default (function () { } var state = this.__stack.pop(); this.__applyStyleState(state); + if (this.__transformMatrixStack && this.__transformMatrixStack.length > 0) { + this.setTransform(this.__transformMatrixStack.pop()) + } }; /**