fix: push/pop transformMatrixStack when save/restore, for https://github.com/zenozeng/p5.js-svg/issues/191

This commit is contained in:
Zeno Zeng 2021-07-07 00:07:55 +08:00
parent c01d698447
commit 6c2f72d30a

View File

@ -486,6 +486,10 @@ export default (function () {
parent.appendChild(group); parent.appendChild(group);
this.__currentElement = group; this.__currentElement = group;
this.__stack.push(this.__getStyleState()); 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(); var state = this.__stack.pop();
this.__applyStyleState(state); this.__applyStyleState(state);
if (this.__transformMatrixStack && this.__transformMatrixStack.length > 0) {
this.setTransform(this.__transformMatrixStack.pop())
}
}; };
/** /**