mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-02-01 03:03:00 +08:00
Canvas: Clear hotkey
This commit is contained in:
parent
e009f586a2
commit
c9f8953200
@ -227,6 +227,7 @@ onUiLoaded(async() => {
|
|||||||
canvas_auto_expand: true,
|
canvas_auto_expand: true,
|
||||||
canvas_blur_prompt: false,
|
canvas_blur_prompt: false,
|
||||||
canvas_hotkey_undo: "KeyZ",
|
canvas_hotkey_undo: "KeyZ",
|
||||||
|
canvas_hotkey_clear: "KeyC",
|
||||||
};
|
};
|
||||||
|
|
||||||
const functionMap = {
|
const functionMap = {
|
||||||
@ -323,6 +324,7 @@ onUiLoaded(async() => {
|
|||||||
keySuffix: " + wheel"
|
keySuffix: " + wheel"
|
||||||
},
|
},
|
||||||
{configKey: "canvas_hotkey_undo", action: "Undo brush stroke"},
|
{configKey: "canvas_hotkey_undo", action: "Undo brush stroke"},
|
||||||
|
{configKey: "canvas_hotkey_clear", action: "Clear canvas"},
|
||||||
{configKey: "canvas_hotkey_reset", action: "Reset zoom"},
|
{configKey: "canvas_hotkey_reset", action: "Reset zoom"},
|
||||||
{
|
{
|
||||||
configKey: "canvas_hotkey_fullscreen",
|
configKey: "canvas_hotkey_fullscreen",
|
||||||
@ -481,9 +483,7 @@ onUiLoaded(async() => {
|
|||||||
} else {
|
} else {
|
||||||
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);
|
||||||
const currentArea = currentRadius ** 2;
|
let delta = Math.sqrt(currentRadius ** 2 * brush_factor) - currentRadius;
|
||||||
const newArea = currentArea * brush_factor;
|
|
||||||
let delta = Math.sqrt(newArea) - currentRadius;
|
|
||||||
// gradio seems to have a minimum brush size step of 1
|
// gradio seems to have a minimum brush size step of 1
|
||||||
if (Math.abs(delta) < 1) {
|
if (Math.abs(delta) < 1) {
|
||||||
delta = delta > 0 ? 1 : -1;
|
delta = delta > 0 ? 1 : -1;
|
||||||
@ -501,6 +501,10 @@ onUiLoaded(async() => {
|
|||||||
gradioApp().querySelector(`${elemId} button[aria-label='Undo']`).click();
|
gradioApp().querySelector(`${elemId} button[aria-label='Undo']`).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearCanvas() {
|
||||||
|
gradioApp().querySelector(`${elemId} button[aria-label='Clear']`).click();
|
||||||
|
}
|
||||||
|
|
||||||
// Reset zoom when uploading a new image
|
// Reset zoom when uploading a new image
|
||||||
const fileInput = gradioApp().querySelector(
|
const fileInput = gradioApp().querySelector(
|
||||||
`${elemId} input[type="file"][accept="image/*"].svelte-116rqfv`
|
`${elemId} input[type="file"][accept="image/*"].svelte-116rqfv`
|
||||||
@ -721,7 +725,8 @@ onUiLoaded(async() => {
|
|||||||
[hotkeysConfig.canvas_hotkey_fullscreen]: fitToScreen,
|
[hotkeysConfig.canvas_hotkey_fullscreen]: fitToScreen,
|
||||||
[hotkeysConfig.canvas_hotkey_shrink_brush]: () => adjustBrushSize(elemId, 10),
|
[hotkeysConfig.canvas_hotkey_shrink_brush]: () => adjustBrushSize(elemId, 10),
|
||||||
[hotkeysConfig.canvas_hotkey_grow_brush]: () => adjustBrushSize(elemId, -10),
|
[hotkeysConfig.canvas_hotkey_grow_brush]: () => adjustBrushSize(elemId, -10),
|
||||||
[hotkeysConfig.canvas_hotkey_undo]: undoBrushStroke
|
[hotkeysConfig.canvas_hotkey_undo]: undoBrushStroke,
|
||||||
|
[hotkeysConfig.canvas_hotkey_clear]: clearCanvas
|
||||||
};
|
};
|
||||||
|
|
||||||
const action = hotkeyActions[event.code];
|
const action = hotkeyActions[event.code];
|
||||||
|
@ -8,6 +8,7 @@ shared.options_templates.update(shared.options_section(('canvas_hotkey', "Canvas
|
|||||||
"canvas_hotkey_grow_brush": shared.OptionInfo("W", "Enlarge the brush size"),
|
"canvas_hotkey_grow_brush": shared.OptionInfo("W", "Enlarge the brush size"),
|
||||||
"canvas_hotkey_move": shared.OptionInfo("F", "Moving the canvas").info("To work correctly in firefox, turn off 'Automatically search the page text when typing' in the browser settings"),
|
"canvas_hotkey_move": shared.OptionInfo("F", "Moving the canvas").info("To work correctly in firefox, turn off 'Automatically search the page text when typing' in the browser settings"),
|
||||||
"canvas_hotkey_undo": shared.OptionInfo("Z", "Undo brush stroke"),
|
"canvas_hotkey_undo": shared.OptionInfo("Z", "Undo brush stroke"),
|
||||||
|
"canvas_hotkey_clear": shared.OptionInfo("C", "Clear 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_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 position"),
|
"canvas_hotkey_reset": shared.OptionInfo("R", "Reset zoom and canvas position"),
|
||||||
"canvas_hotkey_overlap": shared.OptionInfo("O", "Toggle overlap").info("Technical button, needed for testing"),
|
"canvas_hotkey_overlap": shared.OptionInfo("O", "Toggle overlap").info("Technical button, needed for testing"),
|
||||||
|
Loading…
Reference in New Issue
Block a user