Class: Jmage

Jmage(jbbInstance)

Represents a drawable image, which can be a single static image, an animated spritesheet, or a blank canvas for off-screen rendering.

Constructor

new Jmage(jbbInstance)

Parameters:
Name Type Description
jbbInstance object A reference to the main jBB class instance.
Source:

Classes

Jmage

Members

el

The underlying drawable element (either an HTMLImageElement or an off-screen HTMLCanvasElement).
Source:

handle

The current drawing handle of the image.
Source:

height

The height of a single frame of the image.
Source:

rotation

The current rotation of the image in degrees.
Source:

scaleFactor

The current scale factor of the image.
Source:

width

The width of a single frame of the image.
Source:

Methods

load(path) → {Promise.<Jmage>}

Loads a static image from a given path.
Parameters:
Name Type Description
path string The URL or path to the image file.
Source:
Returns:
A promise that resolves with this Jmage instance when loading is complete.
Type
Promise.<Jmage>

loadAnim(path, width, height, first, count) → {Promise.<Jmage>}

Loads an image strip for animation.
Parameters:
Name Type Description
path string The URL or path to the spritesheet file.
width number The width of a single animation frame.
height number The height of a single animation frame.
first number The index of the first frame to use in the animation (1-based).
count number The total number of frames in the animation.
Source:
Returns:
A promise that resolves with this Jmage instance when loading is complete.
Type
Promise.<Jmage>

midHandle()

Sets the image's drawing handle to its center. If the image is not yet loaded, this action is deferred until loading is complete.
Source:

rotate(value)

Rotates the image by a given number of degrees.
Parameters:
Name Type Description
value number The rotation in degrees (0-360).
Source:

scale(xopt, yopt)

Scales the image. A negative value will flip the image on that axis.
Parameters:
Name Type Attributes Default Description
x number <optional>
1.0 The horizontal scale factor.
y number <optional>
1.0 The vertical scale factor.
Source:

setHandle(x, y)

Sets the image's drawing handle to a specific coordinate.
Parameters:
Name Type Description
x number The x-coordinate of the handle.
y number The y-coordinate of the handle.
Source: