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.
get the global background
OffscreenCanvas
's 2d-rendering context, and make it specialize in frequent reading (i.e.willReadFrequently
is set totrue
).if the offscreen-canvas has not been initialized prior, it will be initialized with your provided optional
init_width
andinit_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.