Methods
note
All Module methods are available in this class.
render
Renders content on the canvas only if canRender === true.
If the canvas has zero size, the render callback will be skipped.
const instance = new Canvas();
instance.render(({ canvas, ctx, dpr, width, height }) => {
// Draw your scene here
});
resize
Triggers a canvas resize based on container or viewport dimensions.
const instance = new Canvas();
instance.resize();
updateProps
Updates instance properties.
const instance = new Canvas();
instance.updateProps({
width: 100,
height: 100,
});
destroy
Destroys the instance and cleans up resources.
const instance = new Canvas();
instance.destroy();