p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
Only the first frame of the gif plays. This is because p5.Image::_animateGif tries to access pInst._lastRealFrameTime, which exists on the main canvas but doesn't on the graphic.
Snippet:
let gif;
// Load the image.
let cnv;
function preload() {
gif = loadImage('assets/nancy-liang-wind-loop-forever.gif');
}
function setup() {
createCanvas(100, 100);
cnv = createGraphics(100, 100);
}
function draw() {
// manually update the time of the graphic
cnv._lastRealFrameTime = millis()
cnv.background(255);
cnv.image(gif, 0, 0);
image(cnv, 0, 0);
}
Note that as a quick workaround, one can manually set the time on the graphic:
let gif;
// Load the image.
let cnv;
function preload() {
gif = loadImage('assets/nancy-liang-wind-loop-forever.gif');
}
function setup() {
createCanvas(100, 100);
cnv = createGraphics(100, 100);
}
function draw() {
+ // manually update the time of the graphic
+ cnv._lastRealFrameTime = millis()
cnv.background(255);
cnv.image(gif, 0, 0);
image(cnv, 0, 0);
}
Most appropriate sub-area of p5.js?
p5.js version
1.9.2
Web browser and version
Firefox 117
Operating system
MacOS 14.2.1
Steps to reproduce this
Steps:
Only the first frame of the gif plays. This is because
p5.Image::_animateGif
tries to accesspInst._lastRealFrameTime
, which exists on the main canvas but doesn't on the graphic.Snippet:
Note that as a quick workaround, one can manually set the time on the graphic: