MCPcopy Create free account
hub / github.com/melonjs/melonJS / save

Method save

packages/melonjs/src/video/renderstate.js:133–157  ·  view source on GitHub ↗

* Save the current state onto the stack (zero allocations). * @param {boolean} [scissorTestActive=false] - whether scissor/clip is currently enabled

(scissorTestActive = false)

Source from the content-addressed store, hash-verified

131 * @param {boolean} [scissorTestActive=false] - whether scissor/clip is currently enabled
132 */
133 save(scissorTestActive = false) {
134 const depth = this._stackDepth;
135
136 if (depth >= this._stackCapacity) {
137 this._growStacks();
138 }
139
140 this._colorStack[depth].copy(this.currentColor);
141 this._tintStack[depth].copy(this.currentTint);
142 this._matrixStack[depth].copy(this.currentTransform);
143 this._gradientStack[depth] = this.currentGradient;
144 this._lineDashStack[depth] = this.lineDash;
145 this._blendStack[depth] = this.currentBlendMode;
146 this._shaderStack[depth] = this.currentShader;
147 this._depthStack[depth] = this.currentDepth;
148
149 if (scissorTestActive) {
150 this._scissorStack[depth].set(this.currentScissor);
151 this._scissorActive[depth] = 1;
152 } else {
153 this._scissorActive[depth] = 0;
154 }
155
156 this._stackDepth = depth + 1;
157 }
158
159 /**
160 * Inspect the scissor box that the next `restore()` would install,

Callers

nothing calls this directly

Calls 3

_growStacksMethod · 0.95
copyMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected