PIXI.NodeCanvasElement
class NodeCanvasElement extends Canvas
A node implementation of a canvas element. Uses node-canvas and gl packages to provide the same functionality as a normal HTMLCanvasElement.
Summary
Methods from NodeCanvasElement
Public Methods
addEventListener(type: string, listener: (...args: any[]) => void) → {}
Adds the listener for the specified event.
Name | Type | Description |
---|---|---|
type | string |
The type of event to listen for. |
listener | (...args: any[]) => void |
The callback to invoke when the event is fired. |
dispatchEvent(event: { type : string, [key: string]: any }) → {}
Dispatches the specified event.
Name | Type | Description |
---|---|---|
event | { type : string, [key: string]: any } |
The event to emit. |
event.type |
The type of event. |
removeEventListener(type: string, listener: (...args: any[]) => void) → {}
Removes the listener for the specified event.
Name | Type | Description |
---|---|---|
type | string |
The type of event to listen for. |
listener | (...args: any[]) => void |
The callback to invoke when the event is fired. |
toBuffer(cb: (err: Error | null, result: PIXI.Buffer) => void) → {void}
For image canvases, encodes the canvas as a PNG. For PDF canvases, encodes the canvas as a PDF. For SVG canvases, encodes the canvas as an SVG.
Name | Type | Description |
---|---|---|
cb | (err: Error | null, result: PIXI.Buffer) => void |
Type | Description |
---|---|
void |
toBuffer() → {PIXI.Buffer}
For image canvases, encodes the canvas as a PNG. For PDF canvases, encodes the canvas as a PDF. For SVG canvases, encodes the canvas as an SVG.
Type | Description |
---|---|
PIXI.Buffer |
toBuffer(mimeType: "raw") → {PIXI.Buffer}
Returns the unencoded pixel data, top-to-bottom. On little-endian (most) systems, the array will be ordered BGRA; on big-endian systems, it will be ARGB.
Name | Type | Description |
---|---|---|
mimeType | "raw" |
Type | Description |
---|---|
PIXI.Buffer |
toBuffer(args: any) → {PIXI.Buffer}
Returns a buffer of the canvas contents.
Name | Type | Description |
---|---|---|
args | any |
the arguments to pass to the toBuffer method |
Type | Description |
---|---|
PIXI.Buffer |
toDataURL() → {string}
Defaults to PNG image.
Type | Description |
---|---|
string |
toDataURL(cb: (err: Error | null, result: string) => void) → {void}
Non-standard. Defaults to PNG image.
Name | Type | Description |
---|---|---|
cb | (err: Error | null, result: string) => void |
Type | Description |
---|---|
void |
toDataURL(mimeType: "image/png", cb: (err: Error | null, result: string) => void) → {void}
Non-standard.
Name | Type | Description |
---|---|---|
mimeType | "image/png" | |
cb | (err: Error | null, result: string) => void |
Type | Description |
---|---|
void |
toDataURL(mimeType: "image/jpeg", cb: (err: Error | null, result: string) => void) → {void}
Non-standard.
Name | Type | Description |
---|---|---|
mimeType | "image/jpeg" | |
cb | (err: Error | null, result: string) => void |
Type | Description |
---|---|
void |
toDataURL(mimeType: "image/jpeg", config: JpegConfig, cb: (err: Error | null, result: string) => void) → {void}
Non-standard.
Name | Type | Description |
---|---|---|
mimeType | "image/jpeg" | |
config | JpegConfig | |
cb | (err: Error | null, result: string) => void |
Type | Description |
---|---|
void |
toDataURL(mimeType: "image/jpeg", quality: number, cb: (err: Error | null, result: string) => void) → {void}
Non-standard.
Name | Type | Description |
---|---|---|
mimeType | "image/jpeg" | |
quality | number | |
cb | (err: Error | null, result: string) => void |
Type | Description |
---|---|
void |
toDataURL(args: any) → {string}
Returns a base64 encoded string representation of the canvas.
Name | Type | Description |
---|---|---|
args | any |
The arguments to pass to the toDataURL method. |
Type | Description |
---|---|
string |