Familiar territory. Graphics keeps the RPG Maker MZ API, so existing MZ knowledge, tutorials and plugin code apply. Reactor's additions are marked with descriptions below.
The static class that carries out graphics processing.
function Graphics()
Quick Reference
Setup & Creation 11
| initialize() | Initializes the graphics system. |
| _createAllElements() | Creates the all elements. |
| _makeErrorHtml() | Makes the error html. |
| _createErrorPrinter() | Creates the error printer. |
| _createCanvas() | Creates the canvas. |
| _createLoadingSpinner() | Creates the loading spinner. |
| _createFPSCounter() | Creates the fps counter. |
| _setupEventHandlers() | Setup event handlers. |
| _createPixiApp() | Creates the pixi app. |
| _setupPixi() | Setup pixi. |
| _createEffekseerContext() | Creates the effekseer context. |
Checks (True / False) 4
| isInsideCanvas() | Checks whether the specified point is inside the game canvas area. |
| _canRender() | Whether it can render. |
| isUpscaled() | Whether the canvas is shown larger than its backing store. |
| _isFullScreen() | Whether it is full screen. |
Actions 17
| setTickHandler() | Register a handler for tick events. |
| startGameLoop() | Starts the game loop. |
| stopGameLoop() | Stops the game loop. |
| setStage() | Sets the stage to be rendered. |
| startLoading() | Shows the loading spinner. |
| endLoading() | Erases the loading spinner. |
| showRetryButton() | Displays a button to try to reload resources. |
| showScreen() | Shows the game screen. |
| hideScreen() | Hides the game screen. |
| requestRedraw() | Draw the composite on the next refresh, update or not. |
| _applyUpscaleFilter() | Give an on-screen canvas the enlargement filter in use, or none when it is not enlarged. |
| showEffekseerOverlay() | Show the Effekseer overlay only while it carries screen effects. |
| _disableContextMenu() | Disables the context menu. |
| _applyCanvasFilter() | Applies the canvas filter. |
| _clearCanvasFilter() | Clears the canvas filter. |
| _requestFullScreen() | Requests the full screen. |
| _restoreEffekseerContext() | The overlay's context came back after a loss: effects loaded into the old one are gone with it, so a new Effe… |
Events, Commands & Input 4
| _onTick() | Called when tick happens. |
| _onWindowResize() | Called when window resize happens. |
| _onKeyDown() | Called when key down happens. |
| _listenEffekseerStateResets() | Listen effekseer state resets. |
Updating & Drawing 8
| _updateAllElements() | Updates the all elements each frame. |
| _updateReactor3DCanvas() | Keep the 3D canvas the same size and place as the game canvas. |
| _updateRealScale() | Updates the real scale each frame. |
| _updateErrorPrinter() | Updates the error printer each frame. |
| _updateCanvas() | Updates the canvas each frame. |
| _updateEffekseerCanvas() | Updates the effekseer canvas each frame. |
| _updateVideo() | Updates the video each frame. |
| rendererModeName() | "WebGL", "WebGPU", or "Canvas" for a PIXI renderer, or "" when it cannot be told. |
Other 31
| printError() | Displays the error text to the screen. |
| eraseError() | Erases the loading error text. |
| pageToCanvasX() | Converts an x coordinate on the page to the corresponding x coordinate on the canvas area. |
| pageToCanvasY() | Converts a y coordinate on the page to the corresponding y coordinate on the canvas area. |
| resize() | Changes the size of the game screen. |
| _watchTextureSources() | Count texture sources taking new pixels (update()): none of them touches the sprite showing it. |
| _stageWork() | The render work the stage has queued, as two numbers that only grow between composites: its render groups, an… |
| _groupWork() | One render group's share of _stageWork and its child groups' (a method: this runs twice a refresh). |
| _frameChanged() | Whether this refresh draws: updates is what the tick handler returned. |
| _noteComposite() | What the composite just drawn left behind, for the next refresh to compare with. |
| realClockDelta() | Real clock delta. |
| _mustComposite() | A composite owed whatever the pacing says: the first, a new stage, or one asked for. |
| canvasPixelRatio() | Backing-store scale for the game canvas: how many physical pixels back one game pixel on screen. |
| displayPixelRatio() | Screen pixels per CSS pixel, 1 when the browser does not say. |
| upscaleFilterInUse() | The filter the setting resolves to right now. |
| scalingReport() | One line saying how the frame reaches the screen right now: the canvas store and its ratio, the 3D pass size… |
| _sampleGpuTier() | Sample gpu tier. |
| _stretchWidth() | Stretch width. |
| _stretchHeight() | Stretch height. |
| _defaultStretchMode() | Default stretch mode. |
| _centerElement() | Center element. |
| _switchFPSCounter() | Switch fps counter. |
| _switchStretchMode() | Switch stretch mode. |
| _switchFullScreen() | Switch full screen. |
| _cancelFullScreen() | Cancel full screen. |
| blitSceneBehindEffects() | Draw the composited scene — the 3D canvas when a map renders in 3D, then the game canvas — into the Effekseer… |
| rearmEffekseerState() | Make the next Effekseer draw read back and restore the context's GL state. |
| settleEffekseerState() | After endDraw(): the restoring draw has happened, stop paying for it. |
| FPSCounter() | Fps counter. |
| graphicsDeviceName() | The graphics device's name, short ("RTX 5070", "SwiftShader"), read once; "" when it will not say. |
| graphicsBackendName() | How the browser reaches the graphics device, as its renderer string says ("Direct3D 11", "Direct3D 11 on 12",… |
Setup & Creation
initialize
static sourceGraphics.initialize()
Initializes the graphics system.
Details
Initializes the graphics system.
_createAllElements
static internal sourceGraphics._createAllElements()
Creates the all elements. (Same as the RPG Maker MZ method of this name.)
_makeErrorHtml
static internal sourceGraphics._makeErrorHtml(name, message /*, error*/)
Makes the error html. (Same as the RPG Maker MZ method of this name.)
_createErrorPrinter
static internal sourceGraphics._createErrorPrinter()
Creates the error printer. (Same as the RPG Maker MZ method of this name.)
_createCanvas
static internal sourceGraphics._createCanvas()
Creates the canvas. (Same as the RPG Maker MZ method of this name.)
_createLoadingSpinner
static internal sourceGraphics._createLoadingSpinner()
Creates the loading spinner. (Same as the RPG Maker MZ method of this name.)
_createFPSCounter
static internal sourceGraphics._createFPSCounter()
Creates the fps counter. (Same as the RPG Maker MZ method of this name.)
_setupEventHandlers
static internal sourceGraphics._setupEventHandlers()
Setup event handlers. (Same as the RPG Maker MZ method of this name.)
_createPixiApp
static internal sourceGraphics._createPixiApp()
Creates the pixi app. (Same as the RPG Maker MZ method of this name.)
_setupPixi
static internal sourceGraphics._setupPixi()
Setup pixi. (Same as the RPG Maker MZ method of this name.)
_createEffekseerContext
static internal sourceGraphics._createEffekseerContext()
Creates the effekseer context. (Same as the RPG Maker MZ method of this name.)
Checks (True / False)
isInsideCanvas
static sourceGraphics.isInsideCanvas(x, y)
Checks whether the specified point is inside the game canvas area.
Details
Checks whether the specified point is inside the game canvas area.
_canRender
static internal sourceGraphics._canRender()
Whether it can render. (Same as the RPG Maker MZ method of this name.)
isUpscaled
static sourceGraphics.isUpscaled()
Whether the canvas is shown larger than its backing store.
_isFullScreen
static internal sourceGraphics._isFullScreen()
Whether it is full screen. (Same as the RPG Maker MZ method of this name.)
Actions
setTickHandler
static sourceGraphics.setTickHandler(handler)
Register a handler for tick events.
Details
Register a handler for tick events.
startGameLoop
static sourceGraphics.startGameLoop()
Starts the game loop.
stopGameLoop
static sourceGraphics.stopGameLoop()
Stops the game loop.
setStage
static sourceGraphics.setStage(stage)
Sets the stage to be rendered.
Details
Sets the stage to be rendered.
startLoading
static sourceGraphics.startLoading()
Shows the loading spinner.
endLoading
static sourceGraphics.endLoading()
Erases the loading spinner.
Details
Erases the loading spinner.
showRetryButton
static sourceGraphics.showRetryButton(retry)
Displays a button to try to reload resources.
Details
Displays a button to try to reload resources.
showScreen
static sourceGraphics.showScreen()
Shows the game screen.
hideScreen
static sourceGraphics.hideScreen()
Hides the game screen.
requestRedraw
static sourceGraphics.requestRedraw()
Draw the composite on the next refresh, update or not.
_applyUpscaleFilter
static internal sourceGraphics._applyUpscaleFilter(element)
Give an on-screen canvas the enlargement filter in use, or none when it is not enlarged.
showEffekseerOverlay
static sourceGraphics.showEffekseerOverlay(visible)
Show the Effekseer overlay only while it carries screen effects.
Details
Show the Effekseer overlay only while it carries screen effects. A hidden canvas still draws into its buffer (the in-scene effects are drawn there and copied out), but the compositor stops blending a full-screen transparent layer over the game every frame. Only a change touches the style.
_disableContextMenu
static internal sourceGraphics._disableContextMenu()
Disables the context menu. (Same as the RPG Maker MZ method of this name.)
_applyCanvasFilter
static internal sourceGraphics._applyCanvasFilter()
Applies the canvas filter. (Same as the RPG Maker MZ method of this name.)
_clearCanvasFilter
static internal sourceGraphics._clearCanvasFilter()
Clears the canvas filter. (Same as the RPG Maker MZ method of this name.)
_requestFullScreen
static internal sourceGraphics._requestFullScreen()
Requests the full screen. (Same as the RPG Maker MZ method of this name.)
_restoreEffekseerContext
static internal sourceGraphics._restoreEffekseerContext()
The overlay's context came back after a loss: effects loaded into the old one are gone with it, so a new Effekseer context starts and every effect loads again on its next play.
Details
The overlay's context came back after a loss: effects loaded into the old one are gone with it, so a new Effekseer context starts and every effect loads again on its next play. Effects playing at the loss end there.
Events, Commands & Input
_onTick
static internal sourceGraphics._onTick(deltaTime)
Called when tick happens. (Same as the RPG Maker MZ method of this name.)
_onWindowResize
static internal sourceGraphics._onWindowResize()
Called when window resize happens. (Same as the RPG Maker MZ method of this name.)
_onKeyDown
static internal sourceGraphics._onKeyDown(event)
Called when key down happens. (Same as the RPG Maker MZ method of this name.)
_listenEffekseerStateResets
static internal sourceGraphics._listenEffekseerStateResets()
Listen effekseer state resets. (Same as the RPG Maker MZ method of this name.)
Updating & Drawing
_updateAllElements
static internal sourceGraphics._updateAllElements()
Updates the all elements each frame. (Same as the RPG Maker MZ method of this name.)
_updateReactor3DCanvas
static internal sourceGraphics._updateReactor3DCanvas()
Keep the 3D canvas the same size and place as the game canvas.
Details
Keep the 3D canvas the same size and place as the game canvas.
It is a sibling of the game canvas rather than one of Graphics' own elements, so it was missed whenever the window changed: going fullscreen scaled the game canvas up and left the 3D one at its old size, drawing the world as a small rectangle in the middle of a black screen.
_updateRealScale
static internal sourceGraphics._updateRealScale()
Updates the real scale each frame. (Same as the RPG Maker MZ method of this name.)
_updateErrorPrinter
static internal sourceGraphics._updateErrorPrinter()
Updates the error printer each frame. (Same as the RPG Maker MZ method of this name.)
_updateCanvas
static internal sourceGraphics._updateCanvas()
Updates the canvas each frame. (Same as the RPG Maker MZ method of this name.)
_updateEffekseerCanvas
static internal sourceGraphics._updateEffekseerCanvas()
Updates the effekseer canvas each frame. (Same as the RPG Maker MZ method of this name.)
_updateVideo
static internal sourceGraphics._updateVideo()
Updates the video each frame. (Same as the RPG Maker MZ method of this name.)
rendererModeName
static sourceGraphics.rendererModeName(renderer)
"WebGL", "WebGPU", or "Canvas" for a PIXI renderer, or "" when it cannot be told.
Details
"WebGL", "WebGPU", or "Canvas" for a PIXI renderer, or "" when it cannot
be told. Polymorphic across PIXI versions: v8 renderers carry a name
("webgl"/"webgpu") and RendererType (1 WebGL, 2 WebGPU, 4 Canvas), v5-v7
use PIXI.RENDERER_TYPE (1 WebGL, 2 Canvas) — the numbers collide, so the
string is preferred and the enum is read from whichever PIXI is loaded.
Other
printError
static sourceGraphics.printError(name, message, error = null)
Displays the error text to the screen.
Details
Displays the error text to the screen.
eraseError
static sourceGraphics.eraseError()
Erases the loading error text.
pageToCanvasX
static sourceGraphics.pageToCanvasX(x)
Converts an x coordinate on the page to the corresponding x coordinate on the canvas area.
Details
Converts an x coordinate on the page to the corresponding x coordinate on the canvas area.
pageToCanvasY
static sourceGraphics.pageToCanvasY(y)
Converts a y coordinate on the page to the corresponding y coordinate on the canvas area.
Details
Converts a y coordinate on the page to the corresponding y coordinate on the canvas area.
resize
static sourceGraphics.resize(width, height)
Changes the size of the game screen.
Details
Changes the size of the game screen.
_watchTextureSources
static internal sourceGraphics._watchTextureSources()
Count texture sources taking new pixels (update()): none of them touches the sprite showing it.
_stageWork
static internal sourceGraphics._stageWork(stage, into)
The render work the stage has queued, as two numbers that only grow between composites: its render groups, and every group's pending transform, view and structure updates (PIXI 8 queues each change there, and a composite consumes the queues).
Details
The render work the stage has queued, as two numbers that only grow between composites: its render groups, and every group's pending transform, view and structure updates (PIXI 8 queues each change there, and a composite consumes the queues). Null where the stage has no render group to read.
_groupWork
static internal sourceGraphics._groupWork(group, into)
One render group's share of _stageWork and its child groups' (a method: this runs twice a refresh).
_frameChanged
static internal sourceGraphics._frameChanged(updates)
Whether this refresh draws: updates is what the tick handler returned.
_noteComposite
static internal sourceGraphics._noteComposite()
What the composite just drawn left behind, for the next refresh to compare with.
realClockDelta
static sourceGraphics.realClockDelta(tickerDelta)
Real clock delta. (Same as the RPG Maker MZ method of this name.)
_mustComposite
static internal sourceGraphics._mustComposite()
A composite owed whatever the pacing says: the first, a new stage, or one asked for.
canvasPixelRatio
static sourceGraphics.canvasPixelRatio()
Backing-store scale for the game canvas: how many physical pixels back one game pixel on screen.
Details
Backing-store scale for the game canvas: how many physical pixels back one game pixel on screen. Fullscreen used to stretch the finished frame with the browser's bilinear filter — a blur layer over the whole game. Rendering the backing store at the on-screen size instead leaves nothing to stretch: 3D geometry comes out native-sharp while UI bitmaps (windows, text, pictures) still enlarge through the GPU's smooth sampling and look exactly as soft as before. 1 when the frame is not enlarged — shrinking keeps a 1:1 store — and capped so a video wall cannot demand an enormous framebuffer.
displayPixelRatio
static sourceGraphics.displayPixelRatio()
Screen pixels per CSS pixel, 1 when the browser does not say.
upscaleFilterInUse
static sourceGraphics.upscaleFilterInUse()
The filter the setting resolves to right now.
scalingReport
static sourceGraphics.scalingReport()
One line saying how the frame reaches the screen right now: the canvas store and its ratio, the 3D pass size and its filter, the display scale and the GPU tier.
Details
One line saying how the frame reaches the screen right now: the canvas store and its ratio, the 3D pass size and its filter, the display scale and the GPU tier. Logged at debug level whenever it changes (a resize, F4), so a report of "it looks blurry" can carry the numbers.
_sampleGpuTier
static internal sourceGraphics._sampleGpuTier(renderer)
Sample gpu tier. (Same as the RPG Maker MZ method of this name.)
_stretchWidth
static internal sourceGraphics._stretchWidth()
Stretch width. (Same as the RPG Maker MZ method of this name.)
_stretchHeight
static internal sourceGraphics._stretchHeight()
Stretch height. (Same as the RPG Maker MZ method of this name.)
_defaultStretchMode
static internal sourceGraphics._defaultStretchMode()
Default stretch mode. (Same as the RPG Maker MZ method of this name.)
_centerElement
static internal sourceGraphics._centerElement(element)
Center element. (Same as the RPG Maker MZ method of this name.)
_switchFPSCounter
static internal sourceGraphics._switchFPSCounter()
Switch fps counter. (Same as the RPG Maker MZ method of this name.)
_switchStretchMode
static internal sourceGraphics._switchStretchMode()
Switch stretch mode. (Same as the RPG Maker MZ method of this name.)
_switchFullScreen
static internal sourceGraphics._switchFullScreen()
Switch full screen. (Same as the RPG Maker MZ method of this name.)
_cancelFullScreen
static internal sourceGraphics._cancelFullScreen()
Cancel full screen. (Same as the RPG Maker MZ method of this name.)
blitSceneBehindEffects
static sourceGraphics.blitSceneBehindEffects()
Draw the composited scene — the 3D canvas when a map renders in 3D, then the game canvas — into the Effekseer overlay's framebuffer.
Details
Draw the composited scene — the 3D canvas when a map renders in 3D, then the game canvas — into the Effekseer overlay's framebuffer. Effects with distortion or darkening layers sample a captured background; on its own transparent overlay canvas that background is empty, so those layers rendered as solid black. The scene is blitted, captured into Effekseer's background texture, and cleared away again before the effects draw.
rearmEffekseerState
static sourceGraphics.rearmEffekseerState()
Make the next Effekseer draw read back and restore the context's GL state.
settleEffekseerState
static sourceGraphics.settleEffekseerState()
After endDraw(): the restoring draw has happened, stop paying for it.
FPSCounter
static sourceGraphics.FPSCounter()
Fps counter. (Same as the RPG Maker MZ method of this name.)
graphicsDeviceName
static sourceGraphics.graphicsDeviceName(renderer)
The graphics device's name, short ("RTX 5070", "SwiftShader"), read once; "" when it will not say.
graphicsBackendName
static sourceGraphics.graphicsBackendName()
How the browser reaches the graphics device, as its renderer string says ("Direct3D 11", "Direct3D 11 on 12", "OpenGL", "Vulkan", "Metal"); "" where it does not say or draws in software.
Details
How the browser reaches the graphics device, as its renderer string says ("Direct3D 11", "Direct3D 11 on 12", "OpenGL", "Vulkan", "Metal"); "" where it does not say or draws in software. Read after graphicsDeviceName.