Hey friends, long time no see!
I’ve been pretty excited about the saveGif()
function, but I’m having trouble getting it to work as expected.
Here’s some code I’m trying:
let colors = ['red', 'yellow', 'orange', 'green', 'blue', 'purple'];
function setup() {
createCanvas(400, 400);
background(32);
noSmooth();
}
function draw() {
noStroke();
fill(random(colors));
circle(random(width), random(height), random(10, 20));
}
function mousePressed(){
saveGif('test', 5);
}
(View the sketch in the p5.js editor here)
The screen fills up with randomly colored circles (I limited the colors in case the issue is related to the gif color palette limitations), and when I press the mouse, I expect a gif of those circles to be saved.
Here’s the GIF exported using a tool called Screen to Gif:
However, if I press my mouse to trigger the saveGif()
function, I get something like this:
The gif appears to only contain a single color, although I think maybe I have a mix of yellow and black circles. It might also be worth noting that it’s a different color every time I click:
The replies to the tweet announcing this feature seem to include a mix of folks with multi-colored gifs, and folks with gifs like mine.
I’ve tried both Firefox and Chrome on Windows, and Chrome on Android.
Can anybody help me understand what’s happening? Is this a known behavior of the saveGif()
function? Can I do anything to make sure my gifs export correctly?