Interface: ICanvas
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:94
Common interface for HTMLCanvasElement, OffscreenCanvas, and other custom canvas classes.
Advanced
Extends
ICanvas.Partial<EventTarget>
Properties
addEventListener?
> optional addEventListener?: {(type, listener, options?): void; <K>(type, listener, options?): void; }
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:157
Adds the listener for the specified event.
Call Signature
> (type, listener, options?): void
Parameters
type
string
listener
EventListenerOrEventListenerObject
options?
boolean | AddEventListenerOptions
Returns
void
Call Signature
> <K>(type, listener, options?): void
Type Parameters
K
K extends keyof WebGLContextEventMap
Parameters
type
K
listener
(this, ev) => any
options?
boolean | AddEventListenerOptions
Returns
void
Param
The type of event to listen for.
Param
The callback to invoke when the event is fired.
Param
The options for adding event listener.
Returns
Overrides
Partial.addEventListener
height
> height: number
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:98
Height of the canvas.
parentNode?
> readonly optional parentNode?: ICanvasParentNode | null
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:180
Parent node of the canvas.
removeEventListener?
> optional removeEventListener?: {(type, listener, options?): void; <K>(type, listener, options?): void; }
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:168
Removes the listener for the specified event.
Call Signature
> (type, listener, options?): void
Parameters
type
string
listener
EventListenerOrEventListenerObject
options?
boolean | EventListenerOptions
Returns
void
Call Signature
> <K>(type, listener, options?): void
Type Parameters
K
K extends keyof WebGLContextEventMap
Parameters
type
K
listener
(this, ev) => any
options?
boolean | EventListenerOptions
Returns
void
Param
The type of event to listen for.
Param
The callback to invoke when the event is fired.
Param
The options for removing event listener.
Returns
Overrides
Partial.removeEventListener
style?
> readonly optional style?: ICanvasStyle
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:182
Style of the canvas.
width
> width: number
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:96
Width of the canvas.
Methods
convertToBlob()?
> optional convertToBlob(options?): Promise<Blob>
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:146
Get the content of the canvas as Blob.
Parameters
options?
The options for creating Blob.
quality?
number
A number between 0 and 1 indicating the image quality to be used when
creating images using file formats that support lossy compression (such as image/jpeg or image/webp).
A user agent will use its default quality value if this option is not specified, or if the number
is outside the allowed range.
type?
string
A string indicating the image format. The default type is image/png;
that type is also used if the given type isn't supported.
Returns
Promise<Blob>
A Promise returning a Blob object representing the image contained in the canvas.
dispatchEvent()
> dispatchEvent(event): boolean
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:178
Dispatches a event.
Parameters
event
Event
The Event object to dispatch. Its Event.target property will be set to the current EventTarget.
Returns
boolean
Returns false if event is cancelable, and at least one of the event handlers which received event called Event.preventDefault(). Otherwise true.
Overrides
AccessibleHTMLElement.dispatchEvent
getBoundingClientRect()?
> optional getBoundingClientRect(): ICanvasRect
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:187
Get the position and the size of the canvas.
Returns
The smallest rectangle which contains the entire canvas.
getContext()
Call Signature
> getContext(contextId, options?): ICanvasRenderingContext2D | null
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:105
Get rendering context of the canvas.
Parameters
contextId
"2d"
The identifier of the type of context to create.
options?
ICanvasRenderingContext2DSettings
The options for creating context.
Returns
ICanvasRenderingContext2D | null
The created context, or null if contextId is not supported.
Call Signature
> getContext(contextId, options?): ImageBitmapRenderingContext | null
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:106
Parameters
contextId
"bitmaprenderer"
options?
ImageBitmapRenderingContextSettings
Returns
ImageBitmapRenderingContext | null
Call Signature
> getContext(contextId, options?): WebGLRenderingContext | null
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:107
Parameters
contextId
"webgl" | "experimental-webgl"
options?
WebGLContextAttributes
Returns
WebGLRenderingContext | null
Call Signature
> getContext(contextId, options?): WebGL2RenderingContext | null
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:108
Parameters
contextId
"webgl2" | "experimental-webgl2"
options?
WebGLContextAttributes
Returns
WebGL2RenderingContext | null
Call Signature
> getContext(contextId): GPUCanvasContext | null
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:109
Parameters
contextId
"webgpu"
Returns
GPUCanvasContext | null
Call Signature
> getContext(contextId, options?): RenderingContext | null
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:110
Parameters
contextId
options?
Returns
RenderingContext | null
toBlob()?
> optional toBlob(callback, type?, quality?): void
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:134
Creates a Blob from the content of the canvas.
Parameters
callback
(blob) => void
A callback function with the resulting Blob object
as a single argument. null may be passed if the image cannot be created for any reason.
type?
string
A string indicating the image format. The default type is image/png;
that type is also used if the given type isn't supported.
quality?
number
A number between 0 and 1 indicating the image quality to be used when
creating images using file formats that support lossy compression (such as image/jpeg or image/webp).
A user agent will use its default quality value if this option is not specified, or if the number
is outside the allowed range.
Returns
void
toDataURL()?
> optional toDataURL(type?, quality?): string
Defined in: node_modules/pixi.js/lib/environment/canvas/ICanvas.d.ts:121
Get the content of the canvas as data URL.
Parameters
type?
string
A string indicating the image format. The default type is image/png;
that type is also used if the given type isn't supported.
quality?
number
A number between 0 and 1 indicating the image quality to be used when
creating images using file formats that support lossy compression (such as image/jpeg or image/webp).
A user agent will use its default quality value if this option is not specified, or if the number
is outside the allowed range.
Returns
string
A string containing the requested data URL.