I'm using the very handy javascript canvas to gif script from here: https://github.com/antimatter15/jsgif
But I can't seem to get transparent backgrounds to work. It just comes out black.
HTML:
<canvas id="canvas" width="960" height="540" />
Javascript:
const canvas = document.getElementById("canvas"); // get canvas
const context = canvas.getContext('2d') //get context
ctx.fillStyle = "#000000"; // set bg color to black
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height) // fill the background
var encoder = new window.GIFEncoder()
encoder.setRepeat(0);
encoder.setQuality(200)
encoder.setTransparent(0x000000) // set black to be transparent
encoder.start();
encoder.setDelay(delay);
encoder.addFrame(ctx);
encoder.finish();
encoder.download("download.gif");
But the result is just a gif with black background rather than transparent. What am I doing wrong?
Thanks!