set min brush size to 1

This commit is contained in:
w-e-w 2024-11-23 06:59:19 +09:00
parent 1b9dea7d90
commit 661322707f

View File

@ -474,6 +474,7 @@ onUiLoaded(async() => {
input.click(); input.click();
if (!withoutValue) { if (!withoutValue) {
const maxValue = parseFloat(input.getAttribute("max")) || 100; const maxValue = parseFloat(input.getAttribute("max")) || 100;
const minValue = parseFloat(input.getAttribute("min")) || 1;
// allow brush size up to 1/2 diagonal of the image, beyond gradio's arbitrary limit // allow brush size up to 1/2 diagonal of the image, beyond gradio's arbitrary limit
const canvasImg = gradioApp().querySelector(`${elemId} img`); const canvasImg = gradioApp().querySelector(`${elemId} img`);
if (canvasImg) { if (canvasImg) {
@ -481,6 +482,9 @@ onUiLoaded(async() => {
if (maxDiameter > maxValue) { if (maxDiameter > maxValue) {
input.setAttribute("max", maxDiameter); input.setAttribute("max", maxDiameter);
} }
if (minValue > 1) {
input.setAttribute("min", '1');
}
} }
const brush_factor = deltaY > 0 ? 1 - opts.canvas_hotkey_brush_factor : 1 + opts.canvas_hotkey_brush_factor; const brush_factor = deltaY > 0 ? 1 - opts.canvas_hotkey_brush_factor : 1 + opts.canvas_hotkey_brush_factor;
const currentRadius = parseFloat(input.value); const currentRadius = parseFloat(input.value);