Creates a new animation
The frames to create the animation from
Optionaloptions: AnimationOptionsSee AnimationOptions
How many times to repeat the animation (-1 = forever, 0 = play once)
The animation's duration (in ms)
The animation's frames: an array that changes the animation when it's changed (e.g. push(), splice(), or
setting an index), and can be replaced as a whole
The animation's height
The animation's width
StaticdecodeDecodes an animated GIF, APNG or WebP into fully composited frames (still images become a single frame)
The binary data to decode
Optionaloptions: AnimationDecodeOptionsDecodes an animated GIF, APNG or WebP into fully composited frames (still images become a single frame)
The binary data to decode
OptionalonlyExtractFirstFrame: booleanWhether to stop decoding after the first frame
Encodes the animation as APNG (animated PNG, lossless and with full alpha). Viewers without APNG support show
the first frame. Each frame is stored as the area that changed since the frame before, identical frames are
merged (unless the optimize option is false): the file shows exactly the same animation, but doesn't
necessarily decode to the same frames
Optionaloptions: APNGEncodeOptionsEncodes the animation as APNG (animated PNG, lossless and with full alpha). Viewers without APNG support show
the first frame. Each frame is stored as the area that changed since the frame before, identical frames are
merged (unless the optimize option is false): the file shows exactly the same animation, but doesn't
necessarily decode to the same frames
Optionalcompression: numberThe zlib compression level (0-9), higher is smaller but slower
Encodes the animation as GIF. Like all encoders, it stores each frame as the area that changed since the frame
before and merges identical frames (unless the optimize option is false), so the file decodes to what the
animation shows, but not necessarily to the same frames. Semi-transparent pixels become opaque or transparent
after the frames are composited
Optionaloptions: GIFEncodeOptionsSee GIFEncodeOptions
Encodes the animation as GIF. Like all encoders, it stores each frame as the area that changed since the frame
before and merges identical frames (unless the optimize option is false), so the file decodes to what the
animation shows, but not necessarily to the same frames. Semi-transparent pixels become opaque or transparent
after the frames are composited
Optionalquality: number1-100, scales the palette size from 8 colors (1) to 256 colors (90 and above)
Encodes the animation as lossless animated WebP. Each frame is stored as the area that changed since the frame
before, identical frames are merged (unless the optimize option is false): the file shows exactly the same
animation, but doesn't necessarily decode to the same frames
Resizes the animation to the given dimensions, scaling every frame and its offsets proportionally. Use Image.RESIZE_AUTO as either width or height to automatically preserve the aspect ratio.
Optionaloptions: ResizeOptionsResizes the animation to the given dimensions, scaling every frame and its offsets proportionally. Use Image.RESIZE_AUTO as either width or height to automatically preserve the aspect ratio.
Optionalmode: ResizeModeReturns a new animation of the same class containing a range of this one's frames (same semantics as Array.prototype.slice)
Optionalstart: numberOptionalend: numberA short description for debugging, e.g. Animation<64x64x1000ms>
An animation: frames (Animation.frames) that can be decoded from and encoded to GIF, APNG and WebP.
The animation itself is an array of its frames too (
animation[0],animation.map(...)), which is deprecated: in 4.0 it won't extendArrayanymore, use Animation.frames instead. Array methods like map and filter return plain arrays.