From 76938b535f135f14e983d3ee06851784118c1f50 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Thu, 24 Nov 2022 11:54:30 -0300 Subject: [PATCH 1/2] img2img fix and better custom slider rendering Signed-off-by: Victor Seiji Hariki Former-commit-id: eb961230a2eeb352dd6097c7010ed0775f1dd3ce --- js/settingsbar.js | 5 ++--- js/ui/toolbar.js | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/js/settingsbar.js b/js/settingsbar.js index 895eaae..6258425 100644 --- a/js/settingsbar.js +++ b/js/settingsbar.js @@ -93,9 +93,8 @@ function createSlider(name, wrapper, options = {}) { phantomRange.value = val; value = parseFloat(phantomRange.value); bar.style.width = `${ - wrapper.offsetWidth * - ((value - options.min) / (options.max - options.min)) - }px`; + 100 * ((value - options.min) / (options.max - options.min)) + }%`; textEl.value = `${name}: ${value}`; options.valuecb && options.valuecb(value); }; diff --git a/js/ui/toolbar.js b/js/ui/toolbar.js index a45d186..91fba77 100644 --- a/js/ui/toolbar.js +++ b/js/ui/toolbar.js @@ -134,7 +134,15 @@ const _toolbar_input = { return {checkbox, label}; }, - slider: (state, dataKey, text, min = 0, max = 1, step = 0.1) => { + slider: ( + state, + dataKey, + text, + min = 0, + max = 1, + step = 0.1, + defaultValue = 0.3 + ) => { const slider = document.createElement("div"); const value = createSlider(text, slider, { @@ -144,6 +152,7 @@ const _toolbar_input = { valuecb: (v) => { state[dataKey] = v; }, + defaultValue, }); return { @@ -226,7 +235,8 @@ tools.dream = toolbar.registerTool( "Overmask px", 0, 128, - 1 + 1, + 64 ).slider; } @@ -329,32 +339,25 @@ tools.img2img = toolbar.registerTool( "Denoising Strength", 0, 1, - 0.05 + 0.05, + 0.7 ).slider; - // Use Border Mask Checkbox - state.ctxmenu.useBorderMaskSlider = _toolbar_input.checkbox( - state, - "useBorderMask", - "Use Border Mask" - ).label; // Border Mask Size Slider - state.ctxmenu.borderMaskSize = _toolbar_input.slider( + state.ctxmenu.borderMaskSlider = _toolbar_input.slider( state, "borderMaskSize", "Border Mask Size", 0, 128, - 1 + 1, + 64 ).slider; } menu.appendChild(state.ctxmenu.snapToGridLabel); menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.denoisingStrengthSlider); - menu.appendChild(document.createElement("br")); - menu.appendChild(state.ctxmenu.useBorderMaskLabel); - menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.borderMaskSlider); }, shortcut: "I", @@ -438,7 +441,8 @@ tools.maskbrush = toolbar.registerTool( "Brush Size", state.config.minBrushSize, state.config.maxBrushSize, - 1 + 1, + 64 ); state.ctxmenu.brushSizeSlider = brushSizeSlider.slider; state.setBrushSize = brushSizeSlider.setValue; From 2fdcdc7f0c2af8bdb46117432edc97a843e81e78 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Thu, 24 Nov 2022 12:17:29 -0300 Subject: [PATCH 2/2] remove usebordermask box Signed-off-by: Victor Seiji Hariki Former-commit-id: f194ab10ed3caa63d3e8468de035b70d414244bf --- js/ui/toolbar.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/js/ui/toolbar.js b/js/ui/toolbar.js index d188a29..3296afa 100644 --- a/js/ui/toolbar.js +++ b/js/ui/toolbar.js @@ -275,7 +275,6 @@ tools.img2img = toolbar.registerTool( state.snapToGrid = true; state.denoisingStrength = 0.7; - state.useBorderMask = true; state.borderMaskSize = 64; state.mousemovecb = (evn) => { @@ -294,7 +293,7 @@ tools.img2img = toolbar.registerTool( auxCanvas.height = bb.h; const auxCtx = auxCanvas.getContext("2d"); - if (state.useBorderMask) { + if (state.borderMaskSize > 0) { auxCtx.fillStyle = "#FF6A6A50"; auxCtx.fillRect(0, 0, state.borderMaskSize, bb.h); auxCtx.fillRect(0, 0, bb.w, state.borderMaskSize); @@ -358,14 +357,7 @@ tools.img2img = toolbar.registerTool( menu.appendChild(state.ctxmenu.snapToGridLabel); menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.denoisingStrengthSlider); -<<<<<<< HEAD menu.appendChild(state.ctxmenu.borderMaskSlider); -======= - menu.appendChild(document.createElement("br")); - menu.appendChild(state.ctxmenu.useBorderMaskSlider); - menu.appendChild(document.createElement("br")); - menu.appendChild(state.ctxmenu.borderMaskSize); ->>>>>>> main }, shortcut: "I", }