From eab5bd744ff23fa92e456f62f0ce9a19e27f1f1f Mon Sep 17 00:00:00 2001 From: Jochen Derwae Date: Tue, 12 Nov 2019 20:10:23 +0100 Subject: [PATCH] Added fill style for transparent background (erase buffer to full transparency) --- index.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 74b970e..fd73a99 100644 --- a/index.html +++ b/index.html @@ -696,14 +696,18 @@ //canvas.height = settings["screenHeight"]; // Invert background if needed - if (settings["backgroundColor"] != "transparent") { + if (settings["backgroundColor"] == "transparent") { + ctx.fillStyle = "rgba(0,0,0,0.0)"; + ctx.globalCompositeOperation = 'copy'; + } else { if (settings["invertColors"]){ settings["backgroundColor"] == "white" ? ctx.fillStyle = "black" : ctx.fillStyle = "white"; - }else{ + } else { ctx.fillStyle = settings["backgroundColor"]; } - ctx.fillRect(0, 0, canvas.width, canvas.height); + ctx.globalCompositeOperation = 'source-over'; } + ctx.fillRect(0, 0, canvas.width, canvas.height); // Offset used for centering the image when requested var offset_x = 0;