From 26450143c5115a587c022ddd88f7dc7dd9778611 Mon Sep 17 00:00:00 2001 From: Danil Boldyrev Date: Tue, 12 Dec 2023 23:26:16 +0300 Subject: [PATCH] Added the ability to change the % of change in brush size --- README.MD | 4 ++++ javascript/canvas-zoom.js | 7 ++++--- scripts/config.py | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index f0c72f0..94e780e 100644 --- a/README.MD +++ b/README.MD @@ -89,6 +89,8 @@ In transparency mode, you can paint but the effect will not be what you expect, 8. In the settings you can turn off the tooltip and functionality that you do not need +9. You can adjust the size of the maximum size of the brush and the ability to change the % by which it is changed + ## Known bugs: 1. If a white image appears when you cancel on the Hotkey, press the cancel hotkey again and the image will return. @@ -199,6 +201,8 @@ Canvas Zoom поддерживает интеграцию с другими по 8. В настройках вы можете отключить подсказку и функционал которым вы не пользуетесь +9. Вы можете настроить размер максимального размера кисти и возможность изменения %, на который он изменяется + ## Известные баги: 1. Если при отмене на горячей клавише появляется белое изображение, нажмите горячую клавишу отмены еще раз, и изображение вернется. diff --git a/javascript/canvas-zoom.js b/javascript/canvas-zoom.js index 1646a07..8a82feb 100644 --- a/javascript/canvas-zoom.js +++ b/javascript/canvas-zoom.js @@ -322,6 +322,7 @@ onUiLoaded(async () => { canvas_zoom_add_buttons: false, canvas_zoom_inpaint_brushcolor: "#000000", canvas_zoom_transparency_level: 70, + canvas_zoom_brush_size_change: 5, canvas_zoom_brush_size: 200, canvas_zoom_disabled_functions: [], }; @@ -1105,8 +1106,8 @@ onUiLoaded(async () => { [hotkeysConfig.canvas_zoom_hotkey_fill]: fillCanvasWithColor, [hotkeysConfig.canvas_zoom_hotkey_transparency]: toggleOpacityMode, [hotkeysConfig.canvas_zoom_hotkey_undo]: undoLastAction, - [hotkeysConfig.canvas_zoom_inc_brush_size]: () => adjustBrushSize(elemId, -5, false), - [hotkeysConfig.canvas_zoom_dec_brush_size]: () => adjustBrushSize(elemId, 5, false), + [hotkeysConfig.canvas_zoom_inc_brush_size]: () => adjustBrushSize(elemId, -hotkeysConfig.canvas_zoom_brush_size_change, false), + [hotkeysConfig.canvas_zoom_dec_brush_size]: () => adjustBrushSize(elemId, hotkeysConfig.canvas_zoom_brush_size_change, false), }; const action = hotkeyActions[event.code]; @@ -1261,7 +1262,7 @@ onUiLoaded(async () => { if (!isModifierKey(e, hotkeysConfig.canvas_hotkey_adjust)) return; e.preventDefault(); - adjustBrushSize(elemId, e.deltaY); + adjustBrushSize(elemId, e.deltaY, false, hotkeysConfig.canvas_zoom_brush_size_change); }); /** diff --git a/scripts/config.py b/scripts/config.py index 5223705..7a10c28 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -23,6 +23,7 @@ shared.options_templates.update(shared.options_section(('canvas_zoom', "Canvas Z "canvas_auto_expand": shared.OptionInfo(True, "Automatic expansion of an image that does not fit completely within the canvas area, similar to manual S and R entry"), "canvas_zoom_enable_integration": shared.OptionInfo(True, "Enable integration with ControlNet, Regional Prompter and Latent Couple(Two Shot), Inpaint Anything"), "canvas_zoom_brush_size": shared.OptionInfo(200, "Increase % of the maximum brush size", gr.Slider, {"minimum": 100, "maximum": 1000, "step": 50}), + "canvas_zoom_brush_size_change": shared.OptionInfo(5, "Percentage at which the brush size changes, the higher the percentage the faster the brush changes its size", gr.Slider, {"minimum": 1, "maximum": 10, "step": 1}), "canvas_zoom_transparency_level": shared.OptionInfo(70, "Opacity level in inpaint.Works with webui 1.6 otherwise this setting will adjust the transparency in transparency mode from the extension", gr.Slider, {"minimum": 10, "maximum": 100, "step": 5}), "canvas_zoom_brush_opacity": shared.OptionInfo(False, "Makes the brush the same transparency as the mask"), # "canvas_zoom_inpaint_prevent_work": shared.OptionInfo(False, "Always prevent inpainting models work on txt2img tab by default"), #TODO