Merge branch 'main' into manual-scripts
# Conflicts: # index.html
This commit is contained in:
commit
c0e936f216
2 changed files with 121 additions and 25 deletions
10
index.html
10
index.html
|
@ -251,7 +251,7 @@
|
||||||
<br />
|
<br />
|
||||||
<span id="version">
|
<span id="version">
|
||||||
<a href="https://github.com/zero01101/openOutpaint" target="_blank">
|
<a href="https://github.com/zero01101/openOutpaint" target="_blank">
|
||||||
Alpha release v0.0.14.2
|
Alpha release v0.0.15
|
||||||
</a>
|
</a>
|
||||||
<br />
|
<br />
|
||||||
<a
|
<a
|
||||||
|
@ -463,7 +463,7 @@
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
<script src="js/prompt.js?v=7a1c68c" type="text/javascript"></script>
|
<script src="js/prompt.js?v=7a1c68c" type="text/javascript"></script>
|
||||||
<script src="js/index.js?v=ef5a869" type="text/javascript"></script>
|
<script src="js/index.js?v=16bbb46" type="text/javascript"></script>
|
||||||
|
|
||||||
<script
|
<script
|
||||||
src="js/ui/floating/history.js?v=4f29db4"
|
src="js/ui/floating/history.js?v=4f29db4"
|
||||||
|
@ -477,17 +477,17 @@
|
||||||
src="js/ui/tool/generic.js?v=3e678e0"
|
src="js/ui/tool/generic.js?v=3e678e0"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
|
|
||||||
<script src="js/ui/tool/dream.js?v=5330f89" type="text/javascript"></script>
|
<script src="js/ui/tool/dream.js?v=b021d0d" type="text/javascript"></script>
|
||||||
<script
|
<script
|
||||||
src="js/ui/tool/maskbrush.js?v=e9bd0eb"
|
src="js/ui/tool/maskbrush.js?v=e9bd0eb"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script
|
<script
|
||||||
src="js/ui/tool/colorbrush.js?v=20bc06d"
|
src="js/ui/tool/colorbrush.js?v=84ff9fa"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script
|
<script
|
||||||
src="js/ui/tool/select.js?v=b84bf02"
|
src="js/ui/tool/select.js?v=b84bf02"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script src="js/ui/tool/stamp.js?v=75341ec" type="text/javascript"></script>
|
<script src="js/ui/tool/stamp.js?v=5e07542" type="text/javascript"></script>
|
||||||
<script
|
<script
|
||||||
src="js/ui/tool/interrogate.js?v=a9f8585"
|
src="js/ui/tool/interrogate.js?v=a9f8585"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
|
|
|
@ -363,6 +363,7 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
/** @type {Array<string|null>} */
|
/** @type {Array<string|null>} */
|
||||||
const images = [null];
|
const images = [null];
|
||||||
const seeds = [-1];
|
const seeds = [-1];
|
||||||
|
const markedImages=[null]; //A sparse array of booleans indicating which images have been marked, by index
|
||||||
/** @type {HTMLDivElement} */
|
/** @type {HTMLDivElement} */
|
||||||
let imageSelectMenu = null;
|
let imageSelectMenu = null;
|
||||||
// Layer for the images
|
// Layer for the images
|
||||||
|
@ -491,28 +492,47 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
at--;
|
at--;
|
||||||
if (at < 0) at = images.length - 1;
|
if (at < 0) at = images.length - 1;
|
||||||
|
|
||||||
imageindextxt.textContent = `${at}/${images.length - 1}`;
|
activateImgAt(at);
|
||||||
var seed = seeds[at];
|
|
||||||
seedbtn.title = "Use seed " + seed;
|
|
||||||
redraw();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const prevImgEvent = (evn) => {
|
||||||
|
if (evn.shiftKey) {
|
||||||
|
prevMarkedImg();
|
||||||
|
} else {
|
||||||
|
prevImg();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const nextImg = () => {
|
const nextImg = () => {
|
||||||
at++;
|
at++;
|
||||||
if (at >= images.length) at = 0;
|
if (at >= images.length) at = 0;
|
||||||
|
|
||||||
highestNavigatedImageIndex = Math.max(at, highestNavigatedImageIndex);
|
highestNavigatedImageIndex = Math.max(at, highestNavigatedImageIndex);
|
||||||
|
|
||||||
imageindextxt.textContent = `${at}/${images.length - 1}`;
|
activateImgAt(at);
|
||||||
var seed = seeds[at];
|
|
||||||
seedbtn.title = "Use seed " + seed;
|
|
||||||
redraw();
|
|
||||||
|
|
||||||
if (needMoreGenerations() && !isGenerationPending()) {
|
if (needMoreGenerations() && !isGenerationPending()) {
|
||||||
makeMore();
|
makeMore();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const nextImgEvent = (evn) => {
|
||||||
|
if (evn.shiftKey) {
|
||||||
|
nextMarkedImg();
|
||||||
|
} else {
|
||||||
|
nextImg();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const activateImgAt = (at) => {
|
||||||
|
updateImageIndexText();
|
||||||
|
var seed = seeds[at];
|
||||||
|
seedbtn.title = "Use seed " + seed;
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const applyImg = async () => {
|
const applyImg = async () => {
|
||||||
if (!images[at]) return;
|
if (!images[at]) return;
|
||||||
|
|
||||||
|
@ -599,14 +619,79 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
if (!images[at]) return;
|
if (!images[at]) return;
|
||||||
images.splice(at, 1);
|
images.splice(at, 1);
|
||||||
seeds.splice(at, 1);
|
seeds.splice(at, 1);
|
||||||
|
markedImages.splice(at,1);
|
||||||
if (at > images.length - 1) prevImg();
|
if (at > images.length - 1) prevImg();
|
||||||
if (images.length - 1 === 0) discardImg();
|
if (images.length - 1 === 0) discardImg();
|
||||||
imageindextxt.textContent = `${at}/${images.length - 1}`;
|
updateImageIndexText();
|
||||||
var seed = seeds[at];
|
var seed = seeds[at];
|
||||||
seedbtn.title = "Use seed " + seed;
|
seedbtn.title = "Use seed " + seed;
|
||||||
redraw();
|
redraw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleMarkedImg = async () => {
|
||||||
|
markedImages[at] = markedImages[at] == true ? null : true;
|
||||||
|
activateImgAt(at); //redraw just to update caption
|
||||||
|
};
|
||||||
|
|
||||||
|
const nextMarkedImg = () => {
|
||||||
|
var nextIndex = getNextMarkedImage(at);
|
||||||
|
if (nextIndex == null) {
|
||||||
|
//If no next marked image, and we're not currently on a marked image, then return the last marked image in the list, if any, rather than doing nothing
|
||||||
|
if (markedImages[at] == true) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
nextIndex = getPrevMarkedImage(at);
|
||||||
|
if (nextIndex == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
at = nextIndex;
|
||||||
|
activateImgAt(at);
|
||||||
|
}
|
||||||
|
|
||||||
|
const prevMarkedImg = () => {
|
||||||
|
var nextIndex = getPrevMarkedImage(at);
|
||||||
|
if (nextIndex == null) {
|
||||||
|
//If no previous marked image, and we're not currently on a marked image, then return the next image in the list, if any, rather than doing nothing
|
||||||
|
if (markedImages[at] == true) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
nextIndex = getNextMarkedImage(at);
|
||||||
|
if (nextIndex == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
at = nextIndex;
|
||||||
|
activateImgAt(at);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getNextMarkedImage = (at) => {
|
||||||
|
for (let i = at+1; i < markedImages.length; i++) {
|
||||||
|
if (markedImages[i] != null) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPrevMarkedImage = (at) => {
|
||||||
|
for (let i = at-1; i >= 0; --i) {
|
||||||
|
if (markedImages[i] != null) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateImageIndexText = () => {
|
||||||
|
var markedImageIndicator = markedImages[at] == true ? "*" : "";
|
||||||
|
imageindextxt.textContent = `${markedImageIndicator}${at}/${images.length - 1}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const makeMore = async () => {
|
const makeMore = async () => {
|
||||||
const moreQ = await waitQueue();
|
const moreQ = await waitQueue();
|
||||||
try {
|
try {
|
||||||
|
@ -621,7 +706,7 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
dreamData = await _dream(endpoint, requestCopy);
|
dreamData = await _dream(endpoint, requestCopy);
|
||||||
images.push(...dreamData.images);
|
images.push(...dreamData.images);
|
||||||
seeds.push(...dreamData.seeds);
|
seeds.push(...dreamData.seeds);
|
||||||
imageindextxt.textContent = `${at}/${images.length - 1}`;
|
updateImageIndexText();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (alertCount < 2) {
|
if (alertCount < 2) {
|
||||||
notifications.notify(
|
notifications.notify(
|
||||||
|
@ -693,13 +778,16 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
case "-":
|
case "-":
|
||||||
removeImg();
|
removeImg();
|
||||||
break;
|
break;
|
||||||
|
case "*":
|
||||||
|
toggleMarkedImg();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
switch (evn.code) {
|
switch (evn.code) {
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
nextImg();
|
nextImgEvent(evn.evn);
|
||||||
break;
|
break;
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
prevImg();
|
prevImgEvent(evn.evn);
|
||||||
break;
|
break;
|
||||||
case "Enter":
|
case "Enter":
|
||||||
applyImg();
|
applyImg();
|
||||||
|
@ -781,8 +869,10 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
const onwheelhandler = mouse.listen.world.onwheel.on(
|
const onwheelhandler = mouse.listen.world.onwheel.on(
|
||||||
(evn, state) => {
|
(evn, state) => {
|
||||||
if (!state.dream_processed && bb.contains(evn.x, evn.y)) {
|
if (!state.dream_processed && bb.contains(evn.x, evn.y)) {
|
||||||
if (evn.delta < 0) nextImg();
|
|
||||||
else prevImg();
|
if (evn.delta < 0) {
|
||||||
|
nextImgEvent(evn.evn);
|
||||||
|
} else prevImgEvent(evn.evn);
|
||||||
state.dream_processed = true;
|
state.dream_processed = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -817,25 +907,25 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
imageSelectMenu = makeElement("div", bb.x, bb.y + bb.h);
|
imageSelectMenu = makeElement("div", bb.x, bb.y + bb.h);
|
||||||
|
|
||||||
const imageindextxt = document.createElement("button");
|
const imageindextxt = document.createElement("button");
|
||||||
imageindextxt.textContent = `${at}/${images.length - 1}`;
|
updateImageIndexText();
|
||||||
|
|
||||||
imageindextxt.addEventListener("click", () => {
|
imageindextxt.addEventListener("click", () => {
|
||||||
at = 0;
|
at = 0;
|
||||||
|
updateImageIndexText();
|
||||||
imageindextxt.textContent = `${at}/${images.length - 1}`;
|
|
||||||
redraw();
|
redraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
const backbtn = document.createElement("button");
|
const backbtn = document.createElement("button");
|
||||||
backbtn.textContent = "<";
|
backbtn.textContent = "<";
|
||||||
backbtn.title = "Previous Image";
|
backbtn.title = "Previous Image";
|
||||||
backbtn.addEventListener("click", prevImg);
|
backbtn.addEventListener("click", prevImgEvent);
|
||||||
imageSelectMenu.appendChild(backbtn);
|
imageSelectMenu.appendChild(backbtn);
|
||||||
imageSelectMenu.appendChild(imageindextxt);
|
imageSelectMenu.appendChild(imageindextxt);
|
||||||
|
|
||||||
const nextbtn = document.createElement("button");
|
const nextbtn = document.createElement("button");
|
||||||
nextbtn.textContent = ">";
|
nextbtn.textContent = ">";
|
||||||
nextbtn.title = "Next Image";
|
nextbtn.title = "Next Image";
|
||||||
nextbtn.addEventListener("click", nextImg);
|
nextbtn.addEventListener("click", nextImgEvent);
|
||||||
imageSelectMenu.appendChild(nextbtn);
|
imageSelectMenu.appendChild(nextbtn);
|
||||||
|
|
||||||
const morebtn = document.createElement("button");
|
const morebtn = document.createElement("button");
|
||||||
|
@ -898,6 +988,12 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
});
|
});
|
||||||
imageSelectMenu.appendChild(seedbtn);
|
imageSelectMenu.appendChild(seedbtn);
|
||||||
|
|
||||||
|
const toggleMarkedButton = document.createElement("button");
|
||||||
|
toggleMarkedButton.textContent = "*";
|
||||||
|
toggleMarkedButton.title = "Mark/Unmark";
|
||||||
|
toggleMarkedButton.addEventListener("click", toggleMarkedImg);
|
||||||
|
imageSelectMenu.appendChild(toggleMarkedButton);
|
||||||
|
|
||||||
nextQueue(initialQ);
|
nextQueue(initialQ);
|
||||||
|
|
||||||
//Start the next batch after the initial generation
|
//Start the next batch after the initial generation
|
||||||
|
|
Loading…
Reference in a new issue