Skip to content

Commit

Permalink
set min brush size to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
w-e-w committed Nov 22, 2024
1 parent 1b9dea7 commit 6613227
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,17 @@ onUiLoaded(async() => {
input.click();
if (!withoutValue) {
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
const canvasImg = gradioApp().querySelector(`${elemId} img`);
if (canvasImg) {
const maxDiameter = Math.sqrt(canvasImg.naturalWidth ** 2 + canvasImg.naturalHeight ** 2) / 2;
if (maxDiameter > maxValue) {
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 currentRadius = parseFloat(input.value);
Expand Down

0 comments on commit 6613227

Please sign in to comment.