Class in reactor_core.js

Graphics

31 public functions in 5 groups · show internal (_) functions

Core runtime: data, input and the ReactorEvents feed.

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.

@namespace
function Graphics()

Quick Reference

Setup & Creation 1

initialize() Initializes the graphics system.

Checks (True / False) 2

isInsideCanvas() Checks whether the specified point is inside the game canvas area.
isUpscaled() Whether the canvas is shown larger than its backing store.

Actions 11

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.
showEffekseerOverlay() Show the Effekseer overlay only while it carries screen effects.

Updating & Drawing 1

rendererModeName() "WebGL", "WebGPU", or "Canvas" for a PIXI renderer, or "" when it cannot be told.

Other 16

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.
realClockDelta() Real clock delta.
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…
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 source
Graphics.initialize()

Initializes the graphics system.

Details

Initializes the graphics system.

@returns
boolean True if the graphics system is available.

Checks (True / False)

isInsideCanvas

static source
Graphics.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.

@param
x number The x coordinate on the canvas area.
@param
y number The y coordinate on the canvas area.
@returns
boolean True if the specified point is inside the game canvas area.

isUpscaled

static source
Graphics.isUpscaled()

Whether the canvas is shown larger than its backing store.

Actions

setTickHandler

static source
Graphics.setTickHandler(handler)

Register a handler for tick events.

Details

Register a handler for tick events.

@param
handler function The listener function to be added for updates.

startGameLoop

static source
Graphics.startGameLoop()

Starts the game loop.

stopGameLoop

static source
Graphics.stopGameLoop()

Stops the game loop.

setStage

static source
Graphics.setStage(stage)

Sets the stage to be rendered.

Details

Sets the stage to be rendered.

@param
stage Stage The stage object to be rendered.

startLoading

static source
Graphics.startLoading()

Shows the loading spinner.

endLoading

static source
Graphics.endLoading()

Erases the loading spinner.

Details

Erases the loading spinner.

@returns
boolean True if the loading spinner was active.

showRetryButton

static source
Graphics.showRetryButton(retry)

Displays a button to try to reload resources.

Details

Displays a button to try to reload resources.

@param
retry function The callback function to be called when the button is pressed.

showScreen

static source
Graphics.showScreen()

Shows the game screen.

hideScreen

static source
Graphics.hideScreen()

Hides the game screen.

requestRedraw

static source
Graphics.requestRedraw()

Draw the composite on the next refresh, update or not.

showEffekseerOverlay

static source
Graphics.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.

Updating & Drawing

rendererModeName

static source
Graphics.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 source
Graphics.printError(name, message, error = null)

Displays the error text to the screen.

Details

Displays the error text to the screen.

@param
name string The name of the error.
@param
message string The message of the error.
@param
[error] Error The error object.

eraseError

static source
Graphics.eraseError()

Erases the loading error text.

pageToCanvasX

static source
Graphics.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.

@param
x number The x coordinate on the page to be converted.
@returns
number The x coordinate on the canvas area.

pageToCanvasY

static source
Graphics.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.

@param
y number The y coordinate on the page to be converted.
@returns
number The y coordinate on the canvas area.

resize

static source
Graphics.resize(width, height)

Changes the size of the game screen.

Details

Changes the size of the game screen.

@param
width number The width of the game screen.
@param
height number The height of the game screen.

realClockDelta

static source
Graphics.realClockDelta(tickerDelta)

Real clock delta. (Same as the RPG Maker MZ method of this name.)

canvasPixelRatio

static source
Graphics.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 source
Graphics.displayPixelRatio()

Screen pixels per CSS pixel, 1 when the browser does not say.

upscaleFilterInUse

static source
Graphics.upscaleFilterInUse()

The filter the setting resolves to right now.

scalingReport

static source
Graphics.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.

blitSceneBehindEffects

static source
Graphics.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 source
Graphics.rearmEffekseerState()

Make the next Effekseer draw read back and restore the context's GL state.

settleEffekseerState

static source
Graphics.settleEffekseerState()

After endDraw(): the restoring draw has happened, stop paying for it.

FPSCounter

static source
Graphics.FPSCounter()

Fps counter. (Same as the RPG Maker MZ method of this name.)

graphicsDeviceName

static source
Graphics.graphicsDeviceName(renderer)

The graphics device's name, short ("RTX 5070", "SwiftShader"), read once; "" when it will not say.

graphicsBackendName

static source
Graphics.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.