Protected ReadonlydataThe image data. Each byte contains two 4-bit color pixels.
Protected ReadonlyheightThe image height in pixels.
Protected ReadonlywidthThe image width in pixels.
Creates and returns an animation player for this animation. The actual drawing is done by the specified callback which is called for each frame and receives the image to render.
Callback to call on each frame update. This callback is responsible for actually showing the animation frame to the user.
The created animation player. You have to call the start() method on it to start the animation.
Draws the image onto the given rendering context.
The rendering context to draw the image to.
Optional horizontal target position. Defaults to 0.
Optional vertical target position. Defaults to 0.
Returns the RGBA color at the specified position.
The horizontal pixel position.
The vertical pixel position.
The RGBA color at the specified position.
RangeError if coordinates are outside of the image boundaries.
Returns a copy of the image data. Each byte contains two 4-bit color values.
The image data.
The image height in pixels.
Returns the animation script with the given index.
Animation script index.
The animation script.
RangeError if the index is out of bounds.
The number of animation scripts.
Returns the animation update with the given index.
Animation update index.
The animation update.
RangeError if the index is out of bounds.
The image width in pixels.
Resets the given canvas to the image size and fills the canvas with the image. This does not create a new canvas so any canvas implementation can be used and existing canvas objects can be re-used.
In a browser you do this:
const canvas = image.toCanvas(document.createElement("canvas"))`;
In Node.js (with node-canvas) you do this:
import { createCanvas} from "canvas";
const canvas = image.toCanvas(createCanvas());
The canvas to reset and fill.
The passed canvas for method chaining.
Copies the opaque pixels of this image into the given image data and returns the modified image data.
The image data to copy the opaque pixels of this image to.
The image data.
StaticfromReads a single portrait record from the given array.
The array to read the portrait from.
The byte offset of the portrait record.
The parsed portrait.
Staticfrom
An animated portrait image. Contains the base frame image but also provides methods to access the animation information. To simply play the animation it is recommended to use the PortraitPlayer class.