diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 670b491..a2999aa 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -47,13 +47,11 @@ const dream_generate_callback = (evn, state) => { // Get init image auxCtx.fillRect(0, 0, bb.w, bb.h); auxCtx.drawImage(imgCanvas, bb.x, bb.y, bb.w, bb.h, 0, 0, bb.w, bb.h); - // console.log("drawImage imgCanvas:\n" + auxCanvas.toDataURL()); request.init_images = [auxCanvas.toDataURL()]; // Get mask image auxCtx.fillStyle = "#000F"; auxCtx.fillRect(0, 0, bb.w, bb.h); - // console.log("auxCtx fillRect #000F:\n" + auxCanvas.toDataURL()); if (state.invertMask) { // overmasking by definition is entirely pointless with an inverted mask outpaint // since it should explicitly avoid brushed masks too, we just won't even bother @@ -69,29 +67,20 @@ const dream_generate_callback = (evn, state) => { bb.w, bb.h ); - // console.log( - // "invertMask drawImage maskPaintCanvas dest-in:\n" + - // auxCanvas.toDataURL() - // ); auxCtx.globalCompositeOperation = "destination-in"; auxCtx.drawImage(imgCanvas, bb.x, bb.y, bb.w, bb.h, 0, 0, bb.w, bb.h); - // console.log( - // "invertMask drawImage imgCanvas dest-in:\n" + auxCanvas.toDataURL() - // ); } else { auxCtx.globalCompositeOperation = "destination-in"; auxCtx.drawImage(imgCanvas, bb.x, bb.y, bb.w, bb.h, 0, 0, bb.w, bb.h); - // console.log("drawImage imgCanvas dest-in:\n" + auxCanvas.toDataURL()); - // here's where to overmask to avoid including the brushed mask - 99% of my issues were from failing to set source-over for the overmask blotches + // here's where to overmask to avoid including the brushed mask + // 99% of my issues were from failing to set source-over for the overmask blotches if (state.overMaskPx > 0) { // transparent to white first auxCtx.globalCompositeOperation = "destination-atop"; auxCtx.fillStyle = "#FFFF"; auxCtx.fillRect(0, 0, bb.w, bb.h); - // console.log("pre-overmask fillRect #FFFF:\n" + auxCanvas.toDataURL()); applyOvermask(auxCanvas, auxCtx, state.overMaskPx); - // console.log("overmask applied:\n" + auxCanvas.toDataURL()); } auxCtx.globalCompositeOperation = "destination-out"; // ??? @@ -106,14 +95,10 @@ const dream_generate_callback = (evn, state) => { bb.w, bb.h ); - // console.log( - // "drawImage maskPaintCanvas dest-out:\n" + auxCanvas.toDataURL() - // ); } auxCtx.globalCompositeOperation = "destination-atop"; auxCtx.fillStyle = "#FFFF"; auxCtx.fillRect(0, 0, bb.w, bb.h); - // console.log("fillRect #FFFF dest-atop:\n" + auxCanvas.toDataURL()); request.mask = auxCanvas.toDataURL(); // Dream dream(bb.x, bb.y, request, {method: "img2img", stopMarching, bb}); @@ -135,8 +120,8 @@ function applyOvermask(canvas, ctx, px) { // :badpokerface: look it might be all placebo but i like overmask lol // yes it's crushingly inefficient i knooow :( must fix // https://stackoverflow.com/a/30204783 was instrumental to this working or completely to blame for this disaster depending on your interpretation + ctx.globalCompositeOperation = "source-over"; var ctxImgData = ctx.getImageData(0, 0, canvas.width, canvas.height); - // console.log("submitted canvas to overmask:\n" + canvas.toDataURL()); for (i = 0; i < ctxImgData.data.length; i += 4) { if (ctxImgData.data[i] == 255) { // white pixel? @@ -153,12 +138,8 @@ function applyOvermask(canvas, ctx, px) { 2 * Math.PI, true ); - ctx.globalCompositeOperation = "source-over"; ctx.fillStyle = "#FFFF"; ctx.fill(); - // if (i % 100000 == 0) { - // console.log("blotched src-over:\n" + canvas.toDataURL()); - // } } } }