Class: GifSource

GifSource

Resource provided to GifSprite instances. This is very similar to using a shared Texture between Sprites. This source contains all the frames and animation needed to support playback.

new GifSource (frames)

Name Type Description
frames GifFrame[]

Array of GifFrame instances.

Members

duration number readonly

The total time to play the animation in milliseconds

frames GifFrame[] readonly

Animation frames

height number readonly

Height of the animation

textures Texture<CanvasSource>[] readonly

Textures

totalFrames number readonly

Total number of frames in the animation

width number readonly

Width of the animation

Methods

from (buffer, options) GifSource static

Create an animated GIF animation from a GIF image's ArrayBuffer. The easiest way to get the buffer is to use Assets.

Name Type Attributes Description
buffer ArrayBuffer

GIF image arraybuffer from Assets.

options GifBufferOptions <optional>

Optional options to use when building from buffer.

Returns:
Type Description
GifSource
Example
 import { GifSource, GifSprite } from 'pixi.js/gif';

 const buffer = await fetch('./file.gif').then(res => res.arrayBuffer());
 const source = GifSource.from(buffer);
 const sprite = new GifSprite(source);

destroy ()

Destroy animation data and don't use after this