module:Image

module:Image

Image class
image demo

Constructor

# new module:Image(positionDefinition, source, optionsopt)

Image constructor

Parameters:
Name Type Attributes Description
positionDefinition PositionDefinition

Top-left corner of the image

source String | Image | HTMLImageElement

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

options ComponentOptions <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:
Name Type Description
definition Object

Image definition

Returns:
Type
Image

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

Promise to load an image file.

Parameters:
Name Type Description
url String | Array.<String>

Link or an array of links to image files

Returns:
Type
Promise.<HTMLImageElement>

# draw(ctx) → {Image}

Draw the image itself

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

Drawing context

Returns:

Itself

Type
Image

# makePath(ctx) → {Image}

Draw it on a context

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

Drawing context

Returns:

Itself

Type
Image

Type Definitions

# ImageOptions

Type:
  • Object
Properties
Name Type Attributes Default Description
fill String | ColorDefinition <optional>
null

Color used as background

description String <optional>
""

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