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.

Public Methods


addEventListener NodeCanvasElement.ts:268
addEventListener(type: string, listener: (...args: any[]) => void) → {}

Adds the listener for the specified event.

Parameters:
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 NodeCanvasElement.ts:293
dispatchEvent(event: { type : string, [key: string]: any }) → {}

Dispatches the specified event.

Parameters:
Name Type Description
event { type : string, [key: string]: any }

The event to emit.

event.type

The type of event.

removeEventListener NodeCanvasElement.ts:278
removeEventListener(type: string, listener: (...args: any[]) => void) → {}

Removes the listener for the specified event.

Parameters:
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 NodeCanvasElement.ts:197
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.

Parameters:
Name Type Description
cb (err: Error | null, result: PIXI.Buffer) => void
Returns:
Type Description
void
toBuffer NodeCanvasElement.ts:205
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.

Returns:
Type Description
PIXI.Buffer
toBuffer NodeCanvasElement.ts:214
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.

Parameters:
Name Type Description
mimeType "raw"
Returns:
Type Description
PIXI.Buffer
toBuffer NodeCanvasElement.ts:220
toBuffer(args: any) → {PIXI.Buffer}

Returns a buffer of the canvas contents.

Parameters:
Name Type Description
args any

the arguments to pass to the toBuffer method

Returns:
Type Description
PIXI.Buffer
toDataURL NodeCanvasElement.ts:237
toDataURL() → {string}

Defaults to PNG image.

Returns:
Type Description
string
toDataURL NodeCanvasElement.ts:241
toDataURL(cb: (err: Error | null, result: string) => void) → {void}

Non-standard. Defaults to PNG image.

Parameters:
Name Type Description
cb (err: Error | null, result: string) => void
Returns:
Type Description
void
void">
void"> toDataURL NodeCanvasElement.ts:243
toDataURL(mimeType: "image/png", cb: (err: Error | null, result: string) => void) → {void}

Non-standard.

Parameters:
Name Type Description
mimeType "image/png"
cb (err: Error | null, result: string) => void
Returns:
Type Description
void
void">
void"> toDataURL NodeCanvasElement.ts:245
toDataURL(mimeType: "image/jpeg", cb: (err: Error | null, result: string) => void) → {void}

Non-standard.

Parameters:
Name Type Description
mimeType "image/jpeg"
cb (err: Error | null, result: string) => void
Returns:
Type Description
void
void">
void"> toDataURL NodeCanvasElement.ts:247
toDataURL(mimeType: "image/jpeg", config: JpegConfig, cb: (err: Error | null, result: string) => void) → {void}

Non-standard.

Parameters:
Name Type Description
mimeType "image/jpeg"
config JpegConfig
cb (err: Error | null, result: string) => void
Returns:
Type Description
void
void">
void"> toDataURL NodeCanvasElement.ts:249
toDataURL(mimeType: "image/jpeg", quality: number, cb: (err: Error | null, result: string) => void) → {void}

Non-standard.

Parameters:
Name Type Description
mimeType "image/jpeg"
quality number
cb (err: Error | null, result: string) => void
Returns:
Type Description
void
toDataURL NodeCanvasElement.ts:251
toDataURL(args: any) → {string}

Returns a base64 encoded string representation of the canvas.

Parameters:
Name Type Description
args any

The arguments to pass to the toDataURL method.

Returns:
Type Description
string

Powered by webdoc!