Preparing search index...

    Class RenderState

    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.

    Index

    Constructors

    Properties

    currentBlendMode: string

    current blend mode

    currentColor: Color

    current fill & stroke style color

    currentScissor: Int32Array<ArrayBufferLike>

    current scissor/clipping rectangle [x, y, width, height]

    currentTint: Color

    current tint applied to sprites

    currentTransform: Matrix2d

    current transformation matrix

    Methods

    • 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).

      Parameters

      • canvasWidth: number

        current canvas width (used when scissor was inactive)

      • canvasHeight: number

        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

    • Save the current state onto the stack (zero allocations).

      Parameters

      • OptionalscissorTestActive: boolean = false

        whether scissor/clip is currently enabled

      Returns void