Canvas2DRendererPlugin

View source

ExtendsPlugin

Installs the Canvas 2D rendering backend in an App.

The plugin prepares TextureCache for image assets and registers Canvas2DMaterialPlugin for BasicMaterial. The default renderer uses GlobalTransform2D, RenderLists2D, Camera, and OrthographicProjection to draw visible 2D meshes as filled paths using their material color. Meshes without position data are skipped. Register another Canvas2DMaterialPlugin when an application needs a different material type or draw function.

Before drawing, the renderer clears the main Window canvas. If no main window, canvas, or 2D context is available, it does not draw. WindowPlugin provides the window state and the canvas is stored in Windows.

The plugin directly requires CorePlugin, ReflectPlugin, and WindowPlugin. Its material support also uses RenderCorePlugin and Transform2DPlugin through Canvas2DMaterialPlugin. Register the required plugins before starting the app; missing dependencies are not installed automatically.

Examples

import { App, Canvas2DRendererPlugin } from 'wima'

new App()
  .registerPlugin(new Canvas2DRendererPlugin())
  .run()

Constructor


constructor()

Methods


register(app: App): void

View source

Adds Canvas 2D rendering resources and basic material support to an app.

The plugin provides a shared TextureCache, connects BasicMaterial to Canvas 2D drawing, and clears the main window’s canvas before a frame is drawn. Applications can add another Canvas2DMaterialPlugin for a custom material and draw callback.

Parameters

NameDescriptionDefault
app

App receiving the Canvas 2D renderer.

—