module:Image

Image class
image demo

Constructor

new module:Image(positionDefinition, source, optionsopt)

Image constructor

Parameters:
NameTypeAttributesDescription
positionDefinitionPositionDefinition

Top-left corner of the image

sourceString | Image | HTMLImageElement

Link to an image file, another Image instance or the image file itself

optionsComponentOptions<optional>

Drawing options

Extends

Members

(static) defaultOptions :ImageOptions

Type:
  • ImageOptions

file :HTMLImageElement

Type:
  • HTMLImageElement

isLoaded :Boolean

Type:
  • Boolean

url

Change the image URL

url

Get the image URL

Methods

(static) from(definition) → {Image}

Parameters:
NameTypeDescription
definitionObject

Image definition

Returns:
Type: 
Image

(static) load(url) → {Promise.<HTMLImageElement>}

Promise to load an image file.

Parameters:
NameTypeDescription
urlString | Array.<String>

Link or an array of links to image files

Returns:
Type: 
Promise.<HTMLImageElement>

draw(ctx) → {Image}

Draw the image itself

Parameters:
NameTypeDescription
ctxCanvasRenderingContext2D

Drawing context

Returns:

Itself

Type: 
Image

makePath(ctx) → {Image}

Draw it on a context

Parameters:
NameTypeDescription
ctxCanvasRenderingContext2D

Drawing context

Returns:

Itself

Type: 
Image

Type Definitions

ImageOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
fillString | ColorDefinition<optional>
null

Color used as background

descriptionString<optional>
""

Description of the image (can be used to for better accessibility)