Merge branch 'main' into manual-scripts
# Conflicts: # index.html
This commit is contained in:
commit
06f4e82347
6 changed files with 65 additions and 67 deletions
14
index.html
14
index.html
|
@ -209,7 +209,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.13
|
Alpha release v0.0.13.1
|
||||||
</a>
|
</a>
|
||||||
<br />
|
<br />
|
||||||
<a
|
<a
|
||||||
|
@ -270,7 +270,7 @@
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
title="Add Layer"
|
title="Add Layer"
|
||||||
onclick="commands.runCommand('addLayer', 'Added Layer')"
|
onclick="commands.runCommand('addLayer', 'Added Layer', {})"
|
||||||
class="ui icon button">
|
class="ui icon button">
|
||||||
<div class="icon-file-plus"></div>
|
<div class="icon-file-plus"></div>
|
||||||
</button>
|
</button>
|
||||||
|
@ -393,7 +393,7 @@
|
||||||
<script src="js/lib/ui.js?v=fe9b702" type="text/javascript"></script>
|
<script src="js/lib/ui.js?v=fe9b702" type="text/javascript"></script>
|
||||||
|
|
||||||
<script
|
<script
|
||||||
src="js/initalize/layers.populate.js?v=8bc8815"
|
src="js/initalize/layers.populate.js?v=066dc8e"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
|
|
||||||
<!-- Configuration -->
|
<!-- Configuration -->
|
||||||
|
@ -402,7 +402,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=c07453c" type="text/javascript"></script>
|
<script src="js/index.js?v=8ffbad8" type="text/javascript"></script>
|
||||||
|
|
||||||
<script
|
<script
|
||||||
src="js/ui/floating/history.js?v=fc92d14"
|
src="js/ui/floating/history.js?v=fc92d14"
|
||||||
|
@ -416,12 +416,12 @@
|
||||||
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=302f0bb" type="text/javascript"></script>
|
<script src="js/ui/tool/dream.js?v=07abfe8" type="text/javascript"></script>
|
||||||
<script
|
<script
|
||||||
src="js/ui/tool/maskbrush.js?v=1e8a893"
|
src="js/ui/tool/maskbrush.js?v=d88810f"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script
|
<script
|
||||||
src="js/ui/tool/colorbrush.js?v=3f8c01a"
|
src="js/ui/tool/colorbrush.js?v=6f1d2f4"
|
||||||
type="text/javascript"></script>
|
type="text/javascript"></script>
|
||||||
<script
|
<script
|
||||||
src="js/ui/tool/select.js?v=f290e83"
|
src="js/ui/tool/select.js?v=f290e83"
|
||||||
|
|
88
js/index.js
88
js/index.js
|
@ -846,26 +846,6 @@ function drawBackground() {
|
||||||
bgLayer.canvas.style.backgroundImage = `url(${url})`;
|
bgLayer.canvas.style.backgroundImage = `url(${url})`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
// Checkerboard
|
|
||||||
let darkTileColor = "#333";
|
|
||||||
let lightTileColor = "#555";
|
|
||||||
for (
|
|
||||||
var x = -bgLayer.origin.x - 64;
|
|
||||||
x < bgLayer.canvas.width - bgLayer.origin.x;
|
|
||||||
x += 64
|
|
||||||
) {
|
|
||||||
for (
|
|
||||||
var y = -bgLayer.origin.y - 64;
|
|
||||||
y < bgLayer.canvas.height - bgLayer.origin.y;
|
|
||||||
y += 64
|
|
||||||
) {
|
|
||||||
bgLayer.ctx.fillStyle =
|
|
||||||
(x + y) % 128 === 0 ? lightTileColor : darkTileColor;
|
|
||||||
bgLayer.ctx.fillRect(x, y, 64, 64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUpscalers() {
|
async function getUpscalers() {
|
||||||
|
@ -881,36 +861,48 @@ async function getUpscalers() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// hacky way to get the correct list of upscalers
|
// hacky way to get the correct list of upscalers
|
||||||
var extras_url =
|
// var extras_url =
|
||||||
document.getElementById("host").value + "/sdapi/v1/extra-single-image/"; // endpoint for upscaling, needed for the hacky way to get the correct list of upscalers
|
// document.getElementById("host").value + "/sdapi/v1/extra-single-image/"; // endpoint for upscaling, needed for the hacky way to get the correct list of upscalers
|
||||||
var empty_image = new Image(1, 1);
|
// var purposefully_incorrect_data = {
|
||||||
var purposefully_incorrect_data = {
|
// resize_mode: 0, // 0 = just resize, 1 = crop and resize, 2 = resize and fill i assume based on theimg2img tabs options
|
||||||
"resize-mode": 0, // 0 = just resize, 1 = crop and resize, 2 = resize and fill i assume based on theimg2img tabs options
|
// upscaling_resize: 2,
|
||||||
upscaling_resize: 2,
|
// upscaler_1: "fake_upscaler",
|
||||||
upscaler_1: "fake_upscaler",
|
// image: empty_image.toDataURL(),
|
||||||
image: empty_image.src,
|
// };
|
||||||
};
|
|
||||||
|
upscalers = [
|
||||||
|
"Lanczos",
|
||||||
|
"Nearest",
|
||||||
|
"LDSR",
|
||||||
|
"SwinIR",
|
||||||
|
"R-ESRGAN General 4xV3",
|
||||||
|
"R-ESRGAN General WDN 4xV3",
|
||||||
|
"R-ESRGAN AnimeVideo",
|
||||||
|
"R-ESRGAN 4x+",
|
||||||
|
"R-ESRGAN 4x+ Anime6B",
|
||||||
|
"R-ESRGAN 2x+",
|
||||||
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(extras_url, {
|
// const response = await fetch(extras_url, {
|
||||||
method: "POST",
|
// method: "POST",
|
||||||
headers: {
|
// headers: {
|
||||||
Accept: "application/json",
|
// Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
// "Content-Type": "application/json",
|
||||||
},
|
// },
|
||||||
body: JSON.stringify(purposefully_incorrect_data),
|
// body: JSON.stringify(purposefully_incorrect_data),
|
||||||
});
|
// });
|
||||||
const data = await response.json();
|
// const data = await response.json();
|
||||||
|
|
||||||
console.log(
|
// console.log(
|
||||||
"[index] purposefully_incorrect_data response, ignore above error"
|
// "[index] purposefully_incorrect_data response, ignore above error"
|
||||||
);
|
// );
|
||||||
// result = purposefully_incorrect_data response: Invalid upscaler, needs to be on of these: None , Lanczos , Nearest , LDSR , BSRGAN , R-ESRGAN General 4xV3 , R-ESRGAN 4x+ Anime6B , ScuNET , ScuNET PSNR , SwinIR_4x
|
// // result = purposefully_incorrect_data response: Invalid upscaler, needs to be on of these: None , Lanczos , Nearest , LDSR , BSRGAN , R-ESRGAN General 4xV3 , R-ESRGAN 4x+ Anime6B , ScuNET , ScuNET PSNR , SwinIR_4x
|
||||||
const upscalersPlusNone = data.detail
|
// const upscalersPlusNone = data.detail
|
||||||
.split(": ")[1]
|
// .split(": ")[1]
|
||||||
.split(",")
|
// .split(",")
|
||||||
.map((v) => v.trim()); // need "None" for stupid hrfix changes razza frazza
|
// .map((v) => v.trim()); // need "None" for stupid hrfix changes razza frazza
|
||||||
const upscalers = upscalersPlusNone.filter((v) => v !== "None"); // converting the result to a list of upscalers
|
// const upscalers = upscalersPlusNone.filter((v) => v !== "None"); // converting the result to a list of upscalers
|
||||||
// upscalersPlusNone.push([
|
// upscalersPlusNone.push([
|
||||||
// "Latent",
|
// "Latent",
|
||||||
// "Latent (antialiased)",
|
// "Latent (antialiased)",
|
||||||
|
@ -918,6 +910,8 @@ async function getUpscalers() {
|
||||||
// "Latent (bicubic, antialiased)",
|
// "Latent (bicubic, antialiased)",
|
||||||
// "Latent (nearest)",
|
// "Latent (nearest)",
|
||||||
// ]);
|
// ]);
|
||||||
|
const upscalersPlusNone = [...upscalers];
|
||||||
|
upscalersPlusNone.unshift("None"); //this is absurd
|
||||||
upscalersPlusNone.push("Latent");
|
upscalersPlusNone.push("Latent");
|
||||||
upscalersPlusNone.push("Latent (antialiased)");
|
upscalersPlusNone.push("Latent (antialiased)");
|
||||||
upscalersPlusNone.push("Latent (bicubic)");
|
upscalersPlusNone.push("Latent (bicubic)");
|
||||||
|
|
|
@ -307,28 +307,28 @@ mouse.listen.camera.onwheel.on((evn) => {
|
||||||
evn.evn.preventDefault();
|
evn.evn.preventDefault();
|
||||||
|
|
||||||
// Get cursor world position
|
// Get cursor world position
|
||||||
const cursorPosition = viewport.viewToCanvas(evn.x, evn.y);
|
const wcursor = viewport.viewToCanvas(evn.x, evn.y);
|
||||||
|
|
||||||
// Get viewport center
|
// Get viewport center
|
||||||
const pcx = viewport.cx;
|
const wcx = viewport.cx;
|
||||||
const pcy = viewport.cy;
|
const wcy = viewport.cy;
|
||||||
|
|
||||||
// Apply zoom
|
// Apply zoom
|
||||||
viewport.zoom *= 1 + evn.delta * 0.0002;
|
viewport.zoom *= 1 + evn.delta * 0.0002;
|
||||||
|
|
||||||
|
// Get cursor new world position
|
||||||
|
const nwcursor = viewport.viewToCanvas(evn.x, evn.y);
|
||||||
|
|
||||||
// Apply normal zoom (center of viewport)
|
// Apply normal zoom (center of viewport)
|
||||||
viewport.cx = pcx;
|
viewport.cx = wcx;
|
||||||
viewport.cy = pcy;
|
viewport.cy = wcy;
|
||||||
|
|
||||||
|
// Move viewport to keep cursor in same location
|
||||||
|
viewport.cx += wcursor.x - nwcursor.x;
|
||||||
|
viewport.cy += wcursor.y - nwcursor.y;
|
||||||
|
|
||||||
viewport.transform(imageCollection.element);
|
viewport.transform(imageCollection.element);
|
||||||
|
|
||||||
// Calculate new viewport center and move
|
|
||||||
//const newCursorPosition = viewport.viewToCanvas(evn.x, evn.y);
|
|
||||||
//viewport.cx = pcx - (newCursorPosition.x - cursorPosition.x);
|
|
||||||
//viewport.cy = pcy - (newCursorPosition.y - cursorPosition.y);
|
|
||||||
|
|
||||||
//viewport.transform(imageCollection.element);
|
|
||||||
|
|
||||||
toolbar._current_tool.redrawui && toolbar._current_tool.redrawui();
|
toolbar._current_tool.redrawui && toolbar._current_tool.redrawui();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,10 @@ const _color_brush_draw_callback = (evn, state) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const _color_brush_erase_callback = (evn, state, ctx) => {
|
const _color_brush_erase_callback = (evn, state, ctx) => {
|
||||||
|
ctx.save();
|
||||||
ctx.strokeStyle = "black";
|
ctx.strokeStyle = "black";
|
||||||
|
|
||||||
|
ctx.filter = "blur(" + state.brushBlur + "px)";
|
||||||
ctx.lineWidth = state.brushSize;
|
ctx.lineWidth = state.brushSize;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(
|
ctx.moveTo(
|
||||||
|
@ -33,6 +35,7 @@ const _color_brush_erase_callback = (evn, state, ctx) => {
|
||||||
ctx.lineTo(evn.x, evn.y);
|
ctx.lineTo(evn.x, evn.y);
|
||||||
ctx.lineJoin = ctx.lineCap = "round";
|
ctx.lineJoin = ctx.lineCap = "round";
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
|
ctx.restore();
|
||||||
};
|
};
|
||||||
|
|
||||||
const colorBrushTool = () =>
|
const colorBrushTool = () =>
|
||||||
|
|
|
@ -531,6 +531,7 @@ const _generate = async (endpoint, request, bb, options = {}) => {
|
||||||
images.splice(at, 1);
|
images.splice(at, 1);
|
||||||
seeds.splice(at, 1);
|
seeds.splice(at, 1);
|
||||||
if (at > images.length - 1) prevImg();
|
if (at > images.length - 1) prevImg();
|
||||||
|
if (images.length - 1 === 0) discardImg();
|
||||||
imageindextxt.textContent = `${at}/${images.length - 1}`;
|
imageindextxt.textContent = `${at}/${images.length - 1}`;
|
||||||
var seed = seeds[at];
|
var seed = seeds[at];
|
||||||
seedbtn.title = "Use seed " + seed;
|
seedbtn.title = "Use seed " + seed;
|
||||||
|
|
|
@ -133,7 +133,7 @@ const maskBrushTool = () =>
|
||||||
|
|
||||||
state.movecb = (evn) => {
|
state.movecb = (evn) => {
|
||||||
const vcp = {x: evn.evn.clientX, y: evn.evn.clientY};
|
const vcp = {x: evn.evn.clientX, y: evn.evn.clientY};
|
||||||
const scp = state.brushSize * viewport.zoom;
|
const scp = state.brushSize / viewport.zoom;
|
||||||
|
|
||||||
state.clearPrevCursor();
|
state.clearPrevCursor();
|
||||||
state;
|
state;
|
||||||
|
|
Loading…
Reference in a new issue