Skip to content

Commit

Permalink
Fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtimebuddy committed Feb 16, 2024
1 parent 91eb9e5 commit 95f857f
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/AnimatedGIF.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { decompressFrames, ParsedFrame, parseGIF } from 'gifuct-js';
import { SCALE_MODE, Sprite, Texture, TextureSource, Ticker, UPDATE_PRIORITY } from 'pixi.js';
import { DOMAdapter, SCALE_MODE, Sprite, Texture, TextureSource, Ticker, UPDATE_PRIORITY } from 'pixi.js';

/** Represents a single frame of a GIF. Includes image and timing data. */
interface FrameObject
Expand Down Expand Up @@ -195,16 +195,13 @@ class AnimatedGIF extends Sprite
const frames: FrameObject[] = [];

// Temporary canvases required for compositing frames
const canvas = document.createElement('canvas');
const canvas = DOMAdapter.get().createCanvas(gif.lsd.width, gif.lsd.height) as HTMLCanvasElement;
const context = canvas.getContext('2d', {
willReadFrequently: true,
}) as CanvasRenderingContext2D;
const patchCanvas = document.createElement('canvas');
const patchCanvas = DOMAdapter.get().createCanvas() as HTMLCanvasElement;
const patchContext = patchCanvas.getContext('2d') as CanvasRenderingContext2D;

canvas.width = gif.lsd.width;
canvas.height = gif.lsd.height;

let time = 0;

// Some GIFs have a non-zero frame delay, so we need to calculate the fallback
Expand Down Expand Up @@ -269,12 +266,9 @@ class AnimatedGIF extends Sprite
);

// Create the texture
const canvas = document.createElement('canvas');
const canvas = DOMAdapter.get().createCanvas(width, height) as HTMLCanvasElement;
const context = canvas.getContext('2d') as CanvasRenderingContext2D;

canvas.width = width;
canvas.height = height;

this.texture = Texture.from(new TextureSource({
resource: canvas,
scaleMode,
Expand Down Expand Up @@ -511,7 +505,7 @@ class AnimatedGIF extends Sprite
autoUpdate: this._autoUpdate,
loop: this.loop,
autoPlay: this.autoPlay,
scaleMode: this.texture.baseTexture.scaleMode,
scaleMode: this.texture.source.scaleMode,
animationSpeed: this.animationSpeed,
width: this._context.canvas.width,
height: this._context.canvas.height,
Expand Down

0 comments on commit 95f857f

Please sign in to comment.