From 08252990a6491a135fd5deb681445e062c030bc0 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 13 Nov 2023 20:32:48 +0900 Subject: [PATCH] wasm: Set a GIF background color. Use a white background by default. --- src/bindings/wasm/tvgWasm.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bindings/wasm/tvgWasm.cpp b/src/bindings/wasm/tvgWasm.cpp index 1a954423..295c1463 100644 --- a/src/bindings/wasm/tvgWasm.cpp +++ b/src/bindings/wasm/tvgWasm.cpp @@ -22,8 +22,6 @@ #include #include -#include "tvgIteratorAccessor.h" - using namespace emscripten; using namespace std; @@ -232,6 +230,13 @@ public: return false; } + //set a white opaque background + auto bg = tvg::Shape::gen(); + bg->fill(255, 255, 255, 255); + bg->appendRect(0, 0, ow * scale, oh * scale); + + saver->background(std::move(bg)); + if (saver->save(std::move(animation), "output.gif", 100, fps) != tvg::Result::Success) { errorMsg = "save(), fail"; return false;