Added hotkeys for change brush size, increased the maximum brush size fixed the bug

Gradio-v4-updates
Danil Boldyrev 2023-09-26 19:08:17 +03:00
parent 120f46efe6
commit 36762c013e
6 changed files with 1148 additions and 1112 deletions

View File

@ -30,10 +30,12 @@ if os.path.isfile(config_path):
# Check if "canvas-zoom" is in the list of disabled_extensions
if "canvas-zoom" in config.get('disabled_extensions', []):
launch.run(f'"{python}" -m pip install --force-reinstall --no-deps gradio=={gradio_version}', desc=f"Uninstalling modified gradio for canvas-zoom", errdesc=f"Couldn't uninstall canvas-zoom", live=False)
os.remove(script_path)
# Check if disable_all_extensions is not "none"
if config.get('disable_all_extensions', 'none') == 'all':
launch.run(f'"{python}" -m pip install --force-reinstall --no-deps gradio=={gradio_version}', desc=f"Uninstalling modified gradio for canvas-zoom", errdesc=f"Couldn't uninstall canvas-zoom", live=False)
os.remove(script_path)
# Check if the folder exists
if not os.path.exists(canvasZoomPath) and gradio_version is not None:

View File

@ -22,10 +22,11 @@
export let container_height = 200;
export let shape;
if(window.maskOpacity) mask_opacity = window.maskOpacity
if (window.maskOpacity) mask_opacity = window.maskOpacity;
let colorPickerEnabled = localStorage.setItem("colorPickerEnable", false);
let transparentMask = localStorage.setItem("transparentMask", false);
let posX = 0;
let posY = 0;
let lineStartPoint = null;
@ -724,7 +725,7 @@
} else if (brush_radius > 20) {
ctx.lineWidth = 2; // Change the value to control the thickness of the border
} else {
ctx.lineWidth = 1;
ctx.lineWidth = 2;
}
}
@ -842,4 +843,4 @@
pointer-events: none;
color: var(--body-text-color-subdued);
}
</style>
</style>

View File

@ -15,6 +15,13 @@
export let mode: "mask" | "other" = "other";
export let brush_color = "#000";
let maxBrushSize = window.maxBrushSize;
if (maxBrushSize) {
maxBrushSize = maxBrushSize / 100;
} else {
maxBrushSize = 1;
}
brush_color_store.subscribe(($brush_color) => {
brush_color = $brush_color;
});
@ -35,7 +42,7 @@
bind:value={brush_radius}
type="range"
min={0.5 * (img_width / width)}
max={75 * (img_width / width)}
max={75 * (img_width / width) * maxBrushSize}
/>
{/if}
</span>
@ -88,4 +95,4 @@
right: calc(100% + 5px);
bottom: -4px;
}
</style>
</style>

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,8 @@ shared.options_templates.update(shared.options_section(('canvas_zoom', "Canvas Z
"canvas_hotkey_move": shared.OptionInfo("F", "Moving the canvas"),
"canvas_hotkey_fullscreen": shared.OptionInfo("S", "Fullscreen Mode, maximizes the picture so that it fits into the screen and stretches it to its full width "),
"canvas_hotkey_reset": shared.OptionInfo("R", "Reset zoom and canvas positon"),
"canvas_zoom_inc_brush_size": shared.OptionInfo("]", "Increase brush size"),
"canvas_zoom_dec_brush_size": shared.OptionInfo("[", "Decrease brush size"),
"canvas_zoom_hotkey_open_colorpanel": shared.OptionInfo("Q", "Quickly open the color panel"),
"canvas_zoom_hotkey_pin_colorpanel": shared.OptionInfo("T", "Attach the color panel to the mouse "),
"canvas_zoom_hotkey_dropper": shared.OptionInfo("A", "Toggle dropper ( Works in Sketch and Inpaint Sketch )"),
@ -20,9 +22,10 @@ shared.options_templates.update(shared.options_section(('canvas_zoom', "Canvas Z
"canvas_zoom_mask_clear": shared.OptionInfo(True, "Enable mask clearing in inpaint after any picture is moved in inpaint via buttons"),
"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_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"),
# "canvas_zoom_inpaint_prevent_work": shared.OptionInfo(False, "Always prevent inpainting models work on txt2img tab by default"), #TODO
"canvas_zoom_inpaint_label": shared.OptionInfo(True, "INPAINT - Show the label next to the model selection when you select an inpaint model"),
"canvas_zoom_inpaint_warning": shared.OptionInfo(True, "INPAINT - Show warning when you try to use inpaint model in txt2img mode(The model name must contain 'inpainting' or 'inpaint'.)"),
"canvas_zoom_inpaint_change_btn_color": shared.OptionInfo(False, "INPAINT - Enable button color change when inpaint model is selected"),