From c4cc20882cc2b6eff9a1a303977316dc3cea6311 Mon Sep 17 00:00:00 2001 From: zk-phi Date: Mon, 24 Jun 2024 20:22:30 +0900 Subject: [PATCH] Fix palette --- src/gifworker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gifworker.ts b/src/gifworker.ts index 2c8cb92f..68113239 100644 --- a/src/gifworker.ts +++ b/src/gifworker.ts @@ -49,7 +49,7 @@ ctx.addEventListener("message", (msg) => { palette.pop(); } const colorFinder = genColorFinder(palette); - const transparentIndex = palette.length; + const transparentIndex = palette.length; // entry will be added later frames.forEach((frame, frameIx) => { // dither and binarize transparency first if (transparent) { @@ -65,7 +65,7 @@ ctx.addEventListener("message", (msg) => { } } encoder.writeFrame(indexed, width, height, { - palette: frameIx === 0 ? palette : undefined, + palette: frameIx === 0 ? (transparent ? [...palette, [0, 0, 0]] : palette) : undefined, delay, transparent, transparentIndex,