Skip to content

Initialize the canvas

To use the canvas you must first initialize it. This is done by calling the initialize method on the canvas object.

The initialize method takes the following arguments:

  • element: The HTML element to append the canvas to.
  • options: This is equivalent to the options you can use when initializing a PixiJS Application. The following options are mandatory:
    • width: The width of the canvas.
    • height: The height of the canvas.
  • devtoolsOptions: This is equivalent to the options you can use when initializing the PixiJS Devtools.
ts
import { canvas } from '@drincs/pixi-vn'

// Canvas setup with PIXI
const body = document.body
if (!body) {
    throw new Error('body element not found')
}

canvas.initialize(body, {
    width: 1920,
    height: 1080,
    backgroundColor: "#303030"
}).then(() => {
    // ...
})