Skip to content

Interface: CanvasImage ​

Defined in: types/desktop-engine.d.ts:1398

A canvas image texture (similar to HTMLImageElement; used only for canvas drawing, not a view)

Extends ​

Properties ​

complete ​

ts
readonly complete: boolean;

Defined in: types/desktop-engine.d.ts:1409

Whether the image loaded successfully


height ​

ts
readonly height: number;

Defined in: types/desktop-engine.d.ts:1407

Texture height


nodeName ​

ts
readonly nodeName: string;

Defined in: types/desktop-engine.d.ts:1411

Always "IMG"


onerror ​

ts
onerror: 
  | EventHandler<CanvasImage, void>
  | null
  | undefined;

Defined in: types/desktop-engine.d.ts:1420

error callback


onload ​

ts
onload: 
  | EventHandler<CanvasImage, void>
  | null
  | undefined;

Defined in: types/desktop-engine.d.ts:1418

load callback


src ​

ts
src: string;

Defined in: types/desktop-engine.d.ts:1403

Image source: an http(s) URL, a data URI or a FilePath (in the package, like /a.png, ./a.png or a.png, or in the sandbox); other paths fire error. Assign an empty string to release the texture


tagName ​

ts
readonly tagName: string;

Defined in: types/desktop-engine.d.ts:1413

Always "IMG"


width ​

ts
readonly width: number;

Defined in: types/desktop-engine.d.ts:1405

Texture width

Methods ​

addEventListener() ​

ts
addEventListener<K>(type, listener): void;

Defined in: types/desktop-engine.d.ts:143

Adds an event listener; type may be given with or without the on prefix

Type Parameters ​

Type Parameter
K extends "error" | "load"

Parameters ​

ParameterType
typeK | `on${K}`
listenerEventHandler<CanvasImage, CanvasImageEventMap[K]>

Returns ​

void

Inherited from ​

EventedObject.addEventListener


destroy() ​

ts
destroy(): void;

Defined in: types/desktop-engine.d.ts:147

Clears all event listeners and on callbacks so the object can be garbage-collected; components also process their children recursively

Returns ​

void

Inherited from ​

EventedObject.destroy


loadFromLocal() ​

ts
loadFromLocal(path): void;

Defined in: types/desktop-engine.d.ts:1415

Loads a local image (a FilePath) synchronously, with deferred decoding, then fires load or error

Parameters ​

ParameterType
pathstring

Returns ​

void


offerror() ​

ts
offerror(): void;

Defined in: types/desktop-engine.d.ts:1424

Removes the onerror callback

Returns ​

void


offload() ​

ts
offload(): void;

Defined in: types/desktop-engine.d.ts:1422

Removes the onload callback

Returns ​

void


removeEventListener() ​

ts
removeEventListener<K>(type, listener): void;

Defined in: types/desktop-engine.d.ts:145

Removes the given event listener

Type Parameters ​

Type Parameter
K extends "error" | "load"

Parameters ​

ParameterType
typeK | `on${K}`
listenerEventHandler<CanvasImage, CanvasImageEventMap[K]>

Returns ​

void

Inherited from ​

EventedObject.removeEventListener

The SDK is released under the Apache License 2.0