From 750e4d6261c1af2d167cbec7f24bf74379ebd7ee 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 99c36508..8b04b80f 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; @@ -242,6 +240,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;