Hey All,
I was poking around in 1.0 of p5.js and saw that gif loading was supposed to be working:
https://medium.com/processing-foundation/p5-js-1-0-is-here-b7267140753a
So I tried looking in the source for how it worked, as I couldn’t find any documentation:
and
and
https://github.com/processing/p5.js/commit/3a500615a63a5b18a02de2b4ab94ada0a5fb0e34
I managed to get the following code to work with an animated gif!
in preload(), just load the animated gif as an image as normal:
function preload() {
gifFile = loadImage("../gifs/perfectBlueRedNoodleLoop.gif");
}
then in draw():
gifFile.pause();
for (let i = 0; i < gifFile.numFrames(); i++) {
gifFile.setFrame(i);
image(gifFile, i * 30, 0, 100, 100);
}
Works great! I’ll post an example working in the p5js editor when I’ve made it. Next I’m going to try to slice the frames in interesting ways. It seems there are quite a few undocumented features in 1.0, I’d be happy to help out adding documentation for it.