From 7dfd35839b6292fd74959040de09447edb1ad005 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Mon, 2 Jan 2023 23:31:25 -0300 Subject: [PATCH 1/3] generally fix black when outpainting using addons For some reason, when using some extensions, firefox just bugs out the context after running a toDataURL. We now create a separate canvas for mask drawing. --- js/ui/tool/dream.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index f0e1fab..30e73fd 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -816,16 +816,21 @@ const dream_generate_callback = async (bb, resolution, state) => { bbCanvas.height = bb.h; const bbCtx = bbCanvas.getContext("2d"); - const reqCanvas = document.createElement("canvas"); - reqCanvas.width = request.width; - reqCanvas.height = request.height; - const reqCtx = reqCanvas.getContext("2d"); + const maskCanvas = document.createElement("canvas"); + maskCanvas.width = request.width; + maskCanvas.height = request.height; + const maskCtx = maskCanvas.getContext("2d"); + + const initCanvas = document.createElement("canvas"); + initCanvas.width = request.width; + initCanvas.height = request.height; + const initCtx = initCanvas.getContext("2d"); bbCtx.fillStyle = "#000F"; // Get init image - reqCtx.fillRect(0, 0, request.width, request.height); - reqCtx.drawImage( + initCtx.fillRect(0, 0, request.width, request.height); + initCtx.drawImage( visibleCanvas, 0, 0, @@ -836,7 +841,7 @@ const dream_generate_callback = async (bb, resolution, state) => { request.width, request.height ); - request.init_images = [reqCanvas.toDataURL()]; + request.init_images = [initCanvas.toDataURL()]; // Get mask image bbCtx.fillStyle = "#000F"; @@ -890,8 +895,8 @@ const dream_generate_callback = async (bb, resolution, state) => { bbCtx.fillStyle = "#FFFF"; bbCtx.fillRect(0, 0, bb.w, bb.h); - reqCtx.clearRect(0, 0, reqCanvas.width, reqCanvas.height); - reqCtx.drawImage( + maskCtx.clearRect(0, 0, maskCanvas.width, maskCanvas.height); + maskCtx.drawImage( bbCanvas, 0, 0, @@ -902,7 +907,7 @@ const dream_generate_callback = async (bb, resolution, state) => { request.width, request.height ); - request.mask = reqCanvas.toDataURL(); + request.mask = maskCanvas.toDataURL(); // Dream _generate("img2img", request, bb, { From a1c2004a0817f2338479054aef5fcbc6e4a046b5 Mon Sep 17 00:00:00 2001 From: seijihariki Date: Tue, 3 Jan 2023 02:36:02 +0000 Subject: [PATCH 2/3] Fixed resource hashes --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 853d66d..25a4e67 100644 --- a/index.html +++ b/index.html @@ -351,7 +351,7 @@ src="js/ui/tool/generic.js?v=2bcd36d" type="text/javascript"> - + From 1d976fdd99728ebeb0551f981d7b53607e41d179 Mon Sep 17 00:00:00 2001 From: seijihariki Date: Tue, 3 Jan 2023 14:38:46 +0000 Subject: [PATCH 3/3] Fixed resource hashes --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 6bd3985..f1c7e36 100644 --- a/index.html +++ b/index.html @@ -354,7 +354,7 @@ src="js/ui/tool/generic.js?v=2bcd36d" type="text/javascript"> - +