Examples
// Canvas2DRendererPlugin registers clearCanvas2d in the update flow.
app.registerPlugin(new Canvas2DRendererPlugin())
// Once the main window canvas exists, it is cleared before the Canvas 2D
// material systems draw their frame.Function
clearCanvas2d(world: World): voidClears the active Canvas 2D frame before the
Canvas2DRendererPlugin render systems run.
Canvas2DRendererPlugin registers this function directly in the
update schedule’s CoreSystems.Start system group. It queries the
first entity matching [EntityHandle, Window, MainWindow]; that query
requires the Window component and MainWindow marker, then
uses the entity handle to look up its canvas in the Windows resource.
The window component’s stored dimensions are not read; successful clearing
uses the canvas’s own width and height.
If no entity matches the main-window query, the system warns and returns. If
Windows#getWindow has no canvas for the matching entity, it returns
without drawing or warning. If canvas.getContext('2d') returns no context,
it warns and returns. Otherwise it calls ctx.clearRect(0, 0, canvas.width, canvas.height) to clear the full canvas backing surface.
// Canvas2DRendererPlugin registers clearCanvas2d in the update flow.
app.registerPlugin(new Canvas2DRendererPlugin())
// Once the main window canvas exists, it is cleared before the Canvas 2D
// material systems draw their frame.