/** * @import {Gradient} from "./gradient.js"; */ /** * Renderer-agnostic state container with a pre-allocated save/restore stack. * * Owns the mutable rendering state (color, tint, transform, scissor, blend mode) * and provides zero-allocation save()/restore() via index-based stacks. * Both CanvasRenderer and WebGLRenderer (and future WebGPU) delegate state * management here, keeping rendering-context-specific code in the renderers. */ export default class RenderState { /** * current fill & stroke style color * @type {Color} */ currentColor: Color; /** * current tint applied to sprites * @type {Color} */ currentTint: Color; /** * current transformation matrix * @type {Matrix3d} */ currentTransform: Matrix3d; /** * current scissor/clipping rectangle [x, y, width, height] * @type {Int32Array} */ currentScissor: Int32Array; /** * current gradient fill (null when using solid color) * @type {Gradient|null} */ currentGradient: Gradient | null; /** * current line dash pattern (empty array = solid line) * @type {number[]} */ lineDash: number[]; /** * current blend mode * @type {string} */ currentBlendMode: string; /** * current custom shader effect (undefined when using default shader) * @type {ShaderEffect|undefined} */ currentShader: ShaderEffect | undefined; /** * current per-renderable depth value, pushed into the vertex stream * by the WebGL batchers as the `z` component of each vertex. Has no * visible effect under the engine's default orthographic projection; * required for perspective (Camera3d) to scale sprites by distance. * Mirrors `renderable.depth`, set by `Renderable.preDraw` via * {@link Renderer#setDepth}. * @type {number} */ currentDepth: number; /** * Save the current state onto the stack (zero allocations). * @param {boolean} [scissorTestActive=false] - whether scissor/clip is currently enabled */ save(scissorTestActive?: boolean): void; /** * Restore state from the stack. * Color, tint, transform, and scissor are restored in place. * Blend mode is NOT applied to `currentBlendMode` — it is returned so the * renderer can call its own `setBlendMode()` (which has context-specific side effects). * @param {number} canvasWidth - current canvas width (used when scissor was inactive) * @param {number} canvasHeight - current canvas height (used when scissor was inactive) * @returns {{ blendMode: string, scissorActive: boolean } | null} restored blend mode and scissor flag, or null if stack was empty */ restore(canvasWidth: number, canvasHeight: number): { blendMode: string; scissorActive: boolean; } | null; /** * Reset all state to defaults and clear the stack. * @param {number} width - canvas width * @param {number} height - canvas height */ reset(width: number, height: number): void; } import { Color } from "./../math/color.ts"; import { Matrix3d } from "../math/matrix3d.ts"; import type { Gradient } from "./gradient.js"; //# sourceMappingURL=renderstate.d.ts.map