the desired width of the canvas
the desired height of the canvas
The attributes to create both the canvas and context
OptionalantiAlias?: booleanWhether to enable anti-aliasing, use false (default) for a pixelated effect.
Optionalcontext?: booleanthe context type to be created ("2d", "webgl", "webgl2")
OptionaloffscreenCanvas?: booleanwill create an offscreenCanvas if true instead of a standard canvas
OptionalwillReadFrequently?: booleanIndicates whether or not a lot of read-back operations are planned
The height of this canvas texture in pixels
The height of this render target in pixels.
The width of this canvas texture in pixels
The width of this render target in pixels.
Bind this render target as the active draw destination. All subsequent draw calls will render into this target until unbind is called. No-op by default — subclasses override for GPU render targets (e.g. WebGL FBOs).
Clears the content of the canvas texture
Returns an ImageData object representing the underlying pixel data for a specified portion of this canvas texture.
(Note: when using getImageData(), it is highly recommended to use the willReadFrequently attribute when creatimg the corresponding canvas texture)
The x-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
The y-axis coordinate of the top-left corner of the rectangle from which the ImageData will be extracted
The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left
The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up
The ImageData extracted from this CanvasRenderTarget.
invalidate the current CanvasRenderTarget, and force a reupload of the corresponding texture (call this if you modify the canvas content between two draw calls)
the renderer to which this canvas texture is attached
Resizes the canvas texture to the given width and height.
the desired width
the desired height
enable/disable image smoothing (scaling interpolation)
Optionalenable: boolean = falsewhether to enable or not image smoothing (scaling interpolation)
Creates a Blob directly from the canvas (avoids the getImageData round-trip).
Optionaltype: string = "image/png"A string indicating the image format
Optionalquality: numberA number between 0 and 1 for lossy formats (image/jpeg, image/webp)
A Promise resolving to a Blob
Returns a data URL directly from the canvas (avoids the getImageData/Blob round-trip). Note: not supported by OffscreenCanvas — falls back to the base implementation.
Optionaltype: string = "image/png"A string indicating the image format
Optionalquality: numberA number between 0 and 1 for lossy formats (image/jpeg, image/webp)
A Promise resolving to a data URL string
Creates an ImageBitmap directly from the canvas (avoids the getImageData round-trip).
A Promise resolving to an ImageBitmap
Unbind this render target, restoring the default (screen) output. No-op by default — subclasses override for GPU render targets.
Deprecated
since 17.1.0
See
CanvasRenderTarget