hex-engine icon indicating copy to clipboard operation
hex-engine copied to clipboard

Animated GIF component

Open suchipi opened this issue 4 years ago • 0 comments

It would be nice to have a component that can expose the frames of an animated GIF image using the Animation interface; I'm picturing something like this:

import { useType, useNewComponent, GIF, useDraw } from "@hex-engine/2d";
import someGifFile from "./whatever.gif";

function MyComponent() {
  useType(MyComponent);

  const gif = useNewComponent(() => GIF(someGifFile));
  gif.play(); // `gif` has the same interface as AnimationAPI

  useDraw((context) => {
    gif.drawCurrentFrame(context, { x: 0, y: 0 });
  });
}

suchipi avatar Apr 12 '20 04:04 suchipi