Merge branch 'main' into manual-scripts

# Conflicts:
#	index.html
This commit is contained in:
tim h 2023-01-23 21:36:50 -06:00
commit 06f4e82347
6 changed files with 65 additions and 67 deletions

View file

@ -209,7 +209,7 @@
<br />
<span id="version">
<a href="https://github.com/zero01101/openOutpaint" target="_blank">
Alpha release v0.0.13
Alpha release v0.0.13.1
</a>
<br />
<a
@ -270,7 +270,7 @@
<button
type="button"
title="Add Layer"
onclick="commands.runCommand('addLayer', 'Added Layer')"
onclick="commands.runCommand('addLayer', 'Added Layer', {})"
class="ui icon button">
<div class="icon-file-plus"></div>
</button>
@ -393,7 +393,7 @@
<script src="js/lib/ui.js?v=fe9b702" type="text/javascript"></script>
<script
src="js/initalize/layers.populate.js?v=8bc8815"
src="js/initalize/layers.populate.js?v=066dc8e"
type="text/javascript"></script>
<!-- Configuration -->
@ -402,7 +402,7 @@
<!-- Content -->
<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
src="js/ui/floating/history.js?v=fc92d14"
@ -416,12 +416,12 @@
src="js/ui/tool/generic.js?v=3e678e0"
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
src="js/ui/tool/maskbrush.js?v=1e8a893"
src="js/ui/tool/maskbrush.js?v=d88810f"
type="text/javascript"></script>
<script
src="js/ui/tool/colorbrush.js?v=3f8c01a"
src="js/ui/tool/colorbrush.js?v=6f1d2f4"
type="text/javascript"></script>
<script
src="js/ui/tool/select.js?v=f290e83"

View file

@ -846,26 +846,6 @@ function drawBackground() {
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() {
@ -881,36 +861,48 @@ async function getUpscalers() {
*/
// hacky way to get the correct list of upscalers
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
var empty_image = new Image(1, 1);
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
upscaling_resize: 2,
upscaler_1: "fake_upscaler",
image: empty_image.src,
};
// 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
// 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
// upscaling_resize: 2,
// upscaler_1: "fake_upscaler",
// image: empty_image.toDataURL(),
// };
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 {
const response = await fetch(extras_url, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify(purposefully_incorrect_data),
});
const data = await response.json();
// const response = await fetch(extras_url, {
// method: "POST",
// headers: {
// Accept: "application/json",
// "Content-Type": "application/json",
// },
// body: JSON.stringify(purposefully_incorrect_data),
// });
// const data = await response.json();
console.log(
"[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
const upscalersPlusNone = data.detail
.split(": ")[1]
.split(",")
.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
// console.log(
// "[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
// const upscalersPlusNone = data.detail
// .split(": ")[1]
// .split(",")
// .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
// upscalersPlusNone.push([
// "Latent",
// "Latent (antialiased)",
@ -918,6 +910,8 @@ async function getUpscalers() {
// "Latent (bicubic, antialiased)",
// "Latent (nearest)",
// ]);
const upscalersPlusNone = [...upscalers];
upscalersPlusNone.unshift("None"); //this is absurd
upscalersPlusNone.push("Latent");
upscalersPlusNone.push("Latent (antialiased)");
upscalersPlusNone.push("Latent (bicubic)");

View file

@ -307,28 +307,28 @@ mouse.listen.camera.onwheel.on((evn) => {
evn.evn.preventDefault();
// Get cursor world position
const cursorPosition = viewport.viewToCanvas(evn.x, evn.y);
const wcursor = viewport.viewToCanvas(evn.x, evn.y);
// Get viewport center
const pcx = viewport.cx;
const pcy = viewport.cy;
const wcx = viewport.cx;
const wcy = viewport.cy;
// Apply zoom
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)
viewport.cx = pcx;
viewport.cy = pcy;
viewport.cx = wcx;
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);
// 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();
});

View file

@ -22,8 +22,10 @@ const _color_brush_draw_callback = (evn, state) => {
};
const _color_brush_erase_callback = (evn, state, ctx) => {
ctx.save();
ctx.strokeStyle = "black";
ctx.filter = "blur(" + state.brushBlur + "px)";
ctx.lineWidth = state.brushSize;
ctx.beginPath();
ctx.moveTo(
@ -33,6 +35,7 @@ const _color_brush_erase_callback = (evn, state, ctx) => {
ctx.lineTo(evn.x, evn.y);
ctx.lineJoin = ctx.lineCap = "round";
ctx.stroke();
ctx.restore();
};
const colorBrushTool = () =>

View file

@ -531,6 +531,7 @@ const _generate = async (endpoint, request, bb, options = {}) => {
images.splice(at, 1);
seeds.splice(at, 1);
if (at > images.length - 1) prevImg();
if (images.length - 1 === 0) discardImg();
imageindextxt.textContent = `${at}/${images.length - 1}`;
var seed = seeds[at];
seedbtn.title = "Use seed " + seed;

View file

@ -133,7 +133,7 @@ const maskBrushTool = () =>
state.movecb = (evn) => {
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;