Merge pull request #48 from seijihariki/img2img-fix
Img2img fix Former-commit-id: 41e77e074e5ff68b933dff66b85a119bdde71014
This commit is contained in:
commit
869bb6d126
2 changed files with 23 additions and 21 deletions
|
@ -93,9 +93,8 @@ function createSlider(name, wrapper, options = {}) {
|
||||||
phantomRange.value = val;
|
phantomRange.value = val;
|
||||||
value = parseFloat(phantomRange.value);
|
value = parseFloat(phantomRange.value);
|
||||||
bar.style.width = `${
|
bar.style.width = `${
|
||||||
wrapper.offsetWidth *
|
100 * ((value - options.min) / (options.max - options.min))
|
||||||
((value - options.min) / (options.max - options.min))
|
}%`;
|
||||||
}px`;
|
|
||||||
textEl.value = `${name}: ${value}`;
|
textEl.value = `${name}: ${value}`;
|
||||||
options.valuecb && options.valuecb(value);
|
options.valuecb && options.valuecb(value);
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,7 +134,15 @@ const _toolbar_input = {
|
||||||
return {checkbox, label};
|
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 slider = document.createElement("div");
|
||||||
|
|
||||||
const value = createSlider(text, slider, {
|
const value = createSlider(text, slider, {
|
||||||
|
@ -144,6 +152,7 @@ const _toolbar_input = {
|
||||||
valuecb: (v) => {
|
valuecb: (v) => {
|
||||||
state[dataKey] = v;
|
state[dataKey] = v;
|
||||||
},
|
},
|
||||||
|
defaultValue,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -226,7 +235,8 @@ tools.dream = toolbar.registerTool(
|
||||||
"Overmask px",
|
"Overmask px",
|
||||||
0,
|
0,
|
||||||
128,
|
128,
|
||||||
1
|
1,
|
||||||
|
64
|
||||||
).slider;
|
).slider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +275,6 @@ tools.img2img = toolbar.registerTool(
|
||||||
state.snapToGrid = true;
|
state.snapToGrid = true;
|
||||||
state.denoisingStrength = 0.7;
|
state.denoisingStrength = 0.7;
|
||||||
|
|
||||||
state.useBorderMask = true;
|
|
||||||
state.borderMaskSize = 64;
|
state.borderMaskSize = 64;
|
||||||
|
|
||||||
state.mousemovecb = (evn) => {
|
state.mousemovecb = (evn) => {
|
||||||
|
@ -284,7 +293,7 @@ tools.img2img = toolbar.registerTool(
|
||||||
auxCanvas.height = bb.h;
|
auxCanvas.height = bb.h;
|
||||||
const auxCtx = auxCanvas.getContext("2d");
|
const auxCtx = auxCanvas.getContext("2d");
|
||||||
|
|
||||||
if (state.useBorderMask) {
|
if (state.borderMaskSize > 0) {
|
||||||
auxCtx.fillStyle = "#FF6A6A50";
|
auxCtx.fillStyle = "#FF6A6A50";
|
||||||
auxCtx.fillRect(0, 0, state.borderMaskSize, bb.h);
|
auxCtx.fillRect(0, 0, state.borderMaskSize, bb.h);
|
||||||
auxCtx.fillRect(0, 0, bb.w, state.borderMaskSize);
|
auxCtx.fillRect(0, 0, bb.w, state.borderMaskSize);
|
||||||
|
@ -329,33 +338,26 @@ tools.img2img = toolbar.registerTool(
|
||||||
"Denoising Strength",
|
"Denoising Strength",
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
0.05
|
0.05,
|
||||||
|
0.7
|
||||||
).slider;
|
).slider;
|
||||||
|
|
||||||
// Use Border Mask Checkbox
|
|
||||||
state.ctxmenu.useBorderMaskSlider = _toolbar_input.checkbox(
|
|
||||||
state,
|
|
||||||
"useBorderMask",
|
|
||||||
"Use Border Mask"
|
|
||||||
).label;
|
|
||||||
// Border Mask Size Slider
|
// Border Mask Size Slider
|
||||||
state.ctxmenu.borderMaskSize = _toolbar_input.slider(
|
state.ctxmenu.borderMaskSlider = _toolbar_input.slider(
|
||||||
state,
|
state,
|
||||||
"borderMaskSize",
|
"borderMaskSize",
|
||||||
"Border Mask Size",
|
"Border Mask Size",
|
||||||
0,
|
0,
|
||||||
128,
|
128,
|
||||||
1
|
1,
|
||||||
|
64
|
||||||
).slider;
|
).slider;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.appendChild(state.ctxmenu.snapToGridLabel);
|
menu.appendChild(state.ctxmenu.snapToGridLabel);
|
||||||
menu.appendChild(document.createElement("br"));
|
menu.appendChild(document.createElement("br"));
|
||||||
menu.appendChild(state.ctxmenu.denoisingStrengthSlider);
|
menu.appendChild(state.ctxmenu.denoisingStrengthSlider);
|
||||||
menu.appendChild(document.createElement("br"));
|
menu.appendChild(state.ctxmenu.borderMaskSlider);
|
||||||
menu.appendChild(state.ctxmenu.useBorderMaskSlider);
|
|
||||||
menu.appendChild(document.createElement("br"));
|
|
||||||
menu.appendChild(state.ctxmenu.borderMaskSize);
|
|
||||||
},
|
},
|
||||||
shortcut: "I",
|
shortcut: "I",
|
||||||
}
|
}
|
||||||
|
@ -438,7 +440,8 @@ tools.maskbrush = toolbar.registerTool(
|
||||||
"Brush Size",
|
"Brush Size",
|
||||||
state.config.minBrushSize,
|
state.config.minBrushSize,
|
||||||
state.config.maxBrushSize,
|
state.config.maxBrushSize,
|
||||||
1
|
1,
|
||||||
|
64
|
||||||
);
|
);
|
||||||
state.ctxmenu.brushSizeSlider = brushSizeSlider.slider;
|
state.ctxmenu.brushSizeSlider = brushSizeSlider.slider;
|
||||||
state.setBrushSize = brushSizeSlider.setValue;
|
state.setBrushSize = brushSizeSlider.setValue;
|
||||||
|
|
Loading…
Reference in a new issue