get the global background OffscreenCanvas's 2d-rendering context, and make it specialize in frequent reading (i.e. willReadFrequently is set to true).

if the offscreen-canvas has not been initialized prior, it will be initialized with your provided optional init_width and init_height dimensions. however, if it has been already initialized, then it will not resize to your provided size. thus, if you want a specific size, you should always set it manually yourself.

the reason why we don't resize here, is because resizing clears the canvas, and thus, you will lose your image if you were planning to read it back.

  • Parameters

    • Optionalinit_width: number
    • Optionalinit_height: number

    Returns OffscreenCanvasRenderingContext2D