mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-04 13:55:06 +08:00
reduce complexity
remove the overly complex option of radius / area brush size change mode
This commit is contained in:
parent
3a1497aaf1
commit
2eef345743
@ -474,25 +474,16 @@ onUiLoaded(async() => {
|
|||||||
if (input) {
|
if (input) {
|
||||||
input.click();
|
input.click();
|
||||||
if (!withoutValue) {
|
if (!withoutValue) {
|
||||||
const maxValue =
|
const maxValue = parseFloat(input.getAttribute("max")) || 100;
|
||||||
parseFloat(input.getAttribute("max")) || 100;
|
const brush_factor = deltaY > 0 ? 1 - opts.canvas_hotkey_brush_factor : 1 + opts.canvas_hotkey_brush_factor;
|
||||||
if (opts.canvas_hotkey_brush_factor_mode === "Radius") {
|
const currentRadius = parseFloat(input.value);
|
||||||
const changeAmount = maxValue * (percentage / 100);
|
let delta = Math.sqrt(currentRadius ** 2 * brush_factor) - currentRadius;
|
||||||
const newValue =
|
// minimum brush size step of 1
|
||||||
parseFloat(input.value) +
|
if (Math.abs(delta) < 1) {
|
||||||
(deltaY > 0 ? -changeAmount : changeAmount);
|
delta = deltaY > 0 ? -1 : 1;
|
||||||
input.value = Math.min(Math.max(newValue, 0), maxValue);
|
|
||||||
} else {
|
|
||||||
const brush_factor = deltaY > 0 ? 1 - opts.canvas_hotkey_brush_factor : 1 + opts.canvas_hotkey_brush_factor;
|
|
||||||
const currentRadius = parseFloat(input.value);
|
|
||||||
let delta = Math.sqrt(currentRadius ** 2 * brush_factor) - currentRadius;
|
|
||||||
// gradio seems to have a minimum brush size step of 1
|
|
||||||
if (Math.abs(delta) < 1) {
|
|
||||||
delta = delta > 0 ? 1 : -1;
|
|
||||||
}
|
|
||||||
const newValue = currentRadius + delta;
|
|
||||||
input.value = Math.min(Math.max(newValue, 0), maxValue);
|
|
||||||
}
|
}
|
||||||
|
let newValue = currentRadius + delta;
|
||||||
|
input.value = Math.min(Math.max(newValue, 1), maxValue);
|
||||||
input.dispatchEvent(new Event("change"));
|
input.dispatchEvent(new Event("change"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,5 @@ shared.options_templates.update(shared.options_section(('canvas_hotkey', "Canvas
|
|||||||
"canvas_auto_expand": shared.OptionInfo(True, "Automatically expands an image that does not fit completely in the canvas area, similar to manually pressing the S and R buttons"),
|
"canvas_auto_expand": shared.OptionInfo(True, "Automatically expands an image that does not fit completely in the canvas area, similar to manually pressing the S and R buttons"),
|
||||||
"canvas_blur_prompt": shared.OptionInfo(False, "Take the focus off the prompt when working with a canvas"),
|
"canvas_blur_prompt": shared.OptionInfo(False, "Take the focus off the prompt when working with a canvas"),
|
||||||
"canvas_disabled_functions": shared.OptionInfo(["Overlap"], "Disable function that you don't use", gr.CheckboxGroup, {"choices": ["Zoom", "Adjust brush size", "Hotkey enlarge brush", "Hotkey shrink brush", "Undo", "Clear", "Moving canvas", "Fullscreen", "Reset Zoom", "Overlap"]}),
|
"canvas_disabled_functions": shared.OptionInfo(["Overlap"], "Disable function that you don't use", gr.CheckboxGroup, {"choices": ["Zoom", "Adjust brush size", "Hotkey enlarge brush", "Hotkey shrink brush", "Undo", "Clear", "Moving canvas", "Fullscreen", "Reset Zoom", "Overlap"]}),
|
||||||
"canvas_hotkey_brush_factor_mode": shared.OptionInfo("Area", "Brush size adjustment mode", gr.Radio, {"choices": ["Area", "Radius"]}),
|
"canvas_hotkey_brush_factor": shared.OptionInfo(0.1, "Brush size change rate", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.01}).info('controls how much the brush size is changed when using hotkeys or scroll wheel'),
|
||||||
"canvas_hotkey_brush_factor": shared.OptionInfo(0.1, "Brush factor", gr.Slider, {"minimum": 0, "maximum": 2, "step": 0.01})
|
|
||||||
}))
|
}))
|
||||||
|
Loading…
Reference in New Issue
Block a user