Image

Image

A component that displays an image loaded from a URL.

Constructor

# new Image(parent, x, y, url)

Constructor
Parameters:
Name Type Description
parent HTMLElement The element to add this image to.
x number The x position of the image. Default 0.
y number The y position of the image. Default 0.
url string The URL of the image to display. Default empty string.
Source:
Example
const panel = new Panel(document.body, 20, 20, 200, 200);
new Image(panel, 20, 20, "http://www.example.com/someimage.png");

Extends

Classes

Image

Members

# (static) width

Default width of all images.
Source:

# enabled

Sets and gets whether or not this component is enabled. Non-enabled components will be faded out and not respond to events.
Overrides:

# height

Sets and gets the height of this component.
Overrides:

# url

Gets and sets the url of the image to be displayed. Setting this value will trigger the load of the new image.
Source:

# width

Sets and gets the width of this component.
Overrides:

# x

Sets and gets the x position of this component.
Overrides:

# y

Sets and gets the y position of this component.
Overrides:

Methods

# getEnabled()

Gets whether the component is enabled.
Returns:
Whether or not the component is enabled.

# getHeight()

Gets the height of the component.
Overrides:
Returns:
The height of the component.

# getURL()

Source:
Returns:
the current url.

# getWidth()

Gets the width of the component.
Overrides:
Returns:
The width of the component.

# getX()

Gets the x position of the component.
Overrides:
Returns:
The x position of the component.

# getY()

Gets the y position of the component.
Overrides:
Returns:
The y position of the component.

# move(x, y)

Moves the component to a specified position.
Parameters:
Name Type Description
x number The new x position of the component.
y number The new y position of the component.
Overrides:
Returns:
This instance, suitable for chaining.

# rotate(rad)

Rotates the component.
Parameters:
Name Type Description
rad number The number of radians to rotate the component by.
Overrides:
Returns:
This instance, suitable for chaining.

# rotateDeg(deg)

Rotates the component.
Parameters:
Name Type Description
deg number The number of degrees to rotate the component by.
Overrides:
Returns:
This instance, suitable for chaining.

# setEnabled(enabled)

Sets the enabled state of this component.
Parameters:
Name Type Description
enabled boolean Whether or not the component will be enabled.
Returns:
This instance, suitable for chaining.

# setHeight()

Sets the height of the image. This is has no action because the height will be set according to the assigned width and the aspect ratio of the loaded image.
Overrides:
Source:
Returns:
This instance, suitable for chaining.

# setSize(w, h)

Sizes the component.
Parameters:
Name Type Description
w number The new width of the component.
h number The new height of the component.
Overrides:
Returns:
This instance, suitable for chaining.

# setURL(url)

Sets the url of the image to be displayed. Setting this value will trigger the load of the new image.
Parameters:
Name Type Description
url string The url of the image to load.
Source:
Returns:
This instance, suitable for chaining.

# setWidth(width)

Sets the width of the image. When the image is loaded, it will be set to the assigned width. The height will be set according to the assigned with and the aspect ratio of the loaded image.
Parameters:
Name Type Description
width number The width of the image as displayed.
Overrides:
Source:
Returns:
This instance, suitable for chaining.

# setX(x)

Sets the x position of this component.
Parameters:
Name Type Description
x number The x position of this component.
Overrides:
Returns:
This instance, suitable for chaining.

# setY(y)

Sets the y position of this component.
Parameters:
Name Type Description
y number The y position of this component.
Overrides:
Returns:
this instance, suitable for chaining.