From 7b59e6eb70c0b49959d2f5e57fec7ffb82404508 Mon Sep 17 00:00:00 2001 From: duanyll Date: Fri, 1 Aug 2025 12:54:15 +0800 Subject: [PATCH] feat: PainterNode ability to hide background in output --- PainterNode/js/painter_node.js | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/PainterNode/js/painter_node.js b/PainterNode/js/painter_node.js index 606b7a4..f67a8b3 100644 --- a/PainterNode/js/painter_node.js +++ b/PainterNode/js/painter_node.js @@ -643,12 +643,36 @@ class Painter { labelSaveImage.append(saveImageCheckbox); // end - Save image + // Hide Background in Output + const labelHideBackground = makeElement("label", { + textContent: "Hide Background in Output: ", + style: "font-size: 10px; display: block; text-align: right;", + title: "Hides the background layer in the final output image.", + }); + + const hideBackgroundCheckbox = makeElement("input", { + type: "checkbox", + class: ["hideBackground_checkbox"], + checked: + this.storageCls.settings_painter_node.settings?.hideBackground ?? false, // Default to false + onchange: (e) => { + const checked = !!e.target.checked; + this.storageCls.settings_painter_node.settings.hideBackground = checked; + + this.saveSettingsPainterNode(); + }, + }); + + labelHideBackground.append(hideBackgroundCheckbox); + // end - Hide Background in Output + settingsBox.append( makeElement("legend", { textContent: "Settings", style: "color: rgb(205, 202, 15);", }), - labelSaveImage + labelSaveImage, + labelHideBackground, ); // end - Settings fieldset @@ -2591,6 +2615,15 @@ class Painter { } } + if (this.storageCls.settings_painter_node.settings.hideBackground) { + if (this.canvas.backgroundImage) { + this.canvas.backgroundImage.set({ + opacity: 0, + }); + this.canvas.renderAll(); + } + } + this.canvasSaveSettingsPainter(); await new Promise((res) => { @@ -2635,6 +2668,13 @@ class Painter { activeObj.hasBorders = false; } } + if (this.storageCls.settings_painter_node.settings.hideBackground) { + if (this.canvas.backgroundImage) { + this.canvas.backgroundImage.set({ + opacity: 1, + }); + } + } this.canvas.renderAll(); this.saveSettingsPainterNode();