Merge remote-tracking branch 'zero/main' into testing
Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
commit
5cb3617907
3 changed files with 79 additions and 7 deletions
|
@ -99,6 +99,13 @@
|
|||
<br />
|
||||
<input type="checkbox" id="cbxHRFix" onchange="changeHiResFix()" />
|
||||
<label for="cbxHRFix">Auto txt2img HRfix</label>
|
||||
<br />
|
||||
<input
|
||||
type="checkbox"
|
||||
id="cbxSyncCursorSize"
|
||||
onchange="changeSyncCursorSize()" />
|
||||
<label for="cbxSyncCursorSize">Sync cursor size</label>
|
||||
<br />
|
||||
<div id="resolution"></div>
|
||||
<div id="steps"></div>
|
||||
<div id="cfgScale"></div>
|
||||
|
|
52
js/index.js
52
js/index.js
|
@ -101,6 +101,7 @@ function startup() {
|
|||
changeSmoothRendering();
|
||||
changeSeed();
|
||||
changeHiResFix();
|
||||
changeSyncCursorSize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -448,19 +449,20 @@ const upscalerAutoComplete = createAutoComplete(
|
|||
document.getElementById("upscaler-ac-select")
|
||||
);
|
||||
|
||||
makeSlider(
|
||||
const resSlider = makeSlider(
|
||||
"Resolution",
|
||||
document.getElementById("resolution"),
|
||||
"resolution",
|
||||
64,
|
||||
1024,
|
||||
64,
|
||||
128,
|
||||
2048,
|
||||
128,
|
||||
512,
|
||||
2,
|
||||
(v) => {
|
||||
stableDiffusionData.width = stableDiffusionData.height = v;
|
||||
stableDiffusionData.firstphase_width =
|
||||
stableDiffusionData.firstphase_height = v / 2;
|
||||
informCursorSizeSlider();
|
||||
}
|
||||
);
|
||||
makeSlider(
|
||||
|
@ -522,6 +524,20 @@ function changeHiResFix() {
|
|||
);
|
||||
localStorage.setItem("enable_hr", stableDiffusionData.enable_hr);
|
||||
}
|
||||
|
||||
function changeSyncCursorSize() {
|
||||
stableDiffusionData.sync_cursor_size = Boolean(
|
||||
document.getElementById("cbxSyncCursorSize").checked
|
||||
); //is this horribly hacky, putting it in SD data instead of making a gross global var?
|
||||
localStorage.setItem(
|
||||
"sync_cursor_size",
|
||||
stableDiffusionData.sync_cursor_size
|
||||
);
|
||||
if (stableDiffusionData.sync_cursor_size) {
|
||||
resSlider.value = stableDiffusionData.width;
|
||||
}
|
||||
}
|
||||
|
||||
function changeSmoothRendering() {
|
||||
const layers = document.getElementById("layer-render");
|
||||
if (document.getElementById("cbxSmooth").checked) {
|
||||
|
@ -894,7 +910,11 @@ function loadSettings() {
|
|||
: localStorage.getItem("enable_hr")
|
||||
);
|
||||
var _sync_cursor_size = Boolean(
|
||||
<<<<<<< HEAD
|
||||
localStorage.getItem("sync_cursor_size") == (null || "true")
|
||||
=======
|
||||
localStorage.getItem("sync_cursor_size") == (null || "false")
|
||||
>>>>>>> zero/main
|
||||
? false
|
||||
: localStorage.getItem("sync_cursor_size")
|
||||
);
|
||||
|
@ -903,12 +923,17 @@ function loadSettings() {
|
|||
document.getElementById("maskBlur").value = Number(_mask_blur);
|
||||
document.getElementById("seed").value = Number(_seed);
|
||||
document.getElementById("cbxHRFix").checked = Boolean(_enable_hr);
|
||||
document.getElementById("cbxSyncCursorSize").checked =
|
||||
Boolean(_sync_cursor_size);
|
||||
}
|
||||
|
||||
imageCollection.element.addEventListener(
|
||||
"wheel",
|
||||
(evn) => {
|
||||
evn.preventDefault();
|
||||
if (!evn.ctrlKey) {
|
||||
_resolution_onwheel(evn);
|
||||
}
|
||||
},
|
||||
{passive: false}
|
||||
);
|
||||
|
@ -926,3 +951,22 @@ function resetToDefaults() {
|
|||
localStorage.clear();
|
||||
}
|
||||
}
|
||||
|
||||
function informCursorSizeSlider() {
|
||||
if (stableDiffusionData.sync_cursor_size) {
|
||||
if (toolbar._current_tool) {
|
||||
if (!toolbar._current_tool.state.ignorePrevious) {
|
||||
toolbar._current_tool.state.setCursorSize(stableDiffusionData.width);
|
||||
}
|
||||
toolbar._current_tool.state.ignorePrevious = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const _resolution_onwheel = (evn) => {
|
||||
if (stableDiffusionData.sync_cursor_size) {
|
||||
toolbar._current_tool.state.ignorePrevious = true; //so hacky
|
||||
resSlider.value =
|
||||
stableDiffusionData.width - (128 * evn.deltaY) / Math.abs(evn.deltaY);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -958,6 +958,11 @@ const dreamTool = () =>
|
|||
|
||||
// Display Mask
|
||||
setMask(state.invertMask ? "hold" : "clear");
|
||||
|
||||
// update cursor size if matching is enabled
|
||||
if (stableDiffusionData.sync_cursor_size) {
|
||||
state.setCursorSize(stableDiffusionData.width);
|
||||
}
|
||||
},
|
||||
(state, opt) => {
|
||||
// Clear Listeners
|
||||
|
@ -978,7 +983,6 @@ const dreamTool = () =>
|
|||
};
|
||||
|
||||
state.cursorSize = 512;
|
||||
|
||||
state.snapToGrid = true;
|
||||
state.invertMask = false;
|
||||
state.overMaskPx = 0;
|
||||
|
@ -1026,10 +1030,16 @@ const dreamTool = () =>
|
|||
"cursorSize",
|
||||
"Cursor Size",
|
||||
{
|
||||
min: 0,
|
||||
min: 128,
|
||||
max: 2048,
|
||||
step: 128,
|
||||
textStep: 2,
|
||||
cb: () => {
|
||||
if (stableDiffusionData.sync_cursor_size) {
|
||||
state.ignorePrevious = true;
|
||||
resSlider.value = state.cursorSize;
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1097,6 +1107,11 @@ const img2imgTool = () =>
|
|||
|
||||
// Display Mask
|
||||
setMask(state.invertMask ? "hold" : "clear");
|
||||
|
||||
// update cursor size if matching is enabled
|
||||
if (stableDiffusionData.sync_cursor_size) {
|
||||
state.setCursorSize(stableDiffusionData.width);
|
||||
}
|
||||
},
|
||||
(state, opt) => {
|
||||
// Clear Listeners
|
||||
|
@ -1267,10 +1282,16 @@ const img2imgTool = () =>
|
|||
"cursorSize",
|
||||
"Cursor Size",
|
||||
{
|
||||
min: 0,
|
||||
min: 128,
|
||||
max: 2048,
|
||||
step: 128,
|
||||
textStep: 2,
|
||||
cb: () => {
|
||||
if (stableDiffusionData.sync_cursor_size) {
|
||||
state.ignorePrevious = true;
|
||||
resSlider.value = state.cursorSize;
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue