right-click erase, ensure webUI is running on startup
This commit is contained in:
parent
ce26af81c4
commit
dc472d49c3
2 changed files with 268 additions and 244 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>openOutpaint 0.0.5</title>
|
||||
<title>openOutpaint 0.0.5.1</title>
|
||||
<link href="css/index.css" rel="stylesheet" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
|
@ -132,7 +132,7 @@
|
|||
<input type="file" id="preloadImage" onchange="preloadImage()" accept="image/*" /><br />
|
||||
<button onclick="downloadCanvas()">dl canvas</button>
|
||||
</div>
|
||||
<div id="canvasHolder" class="canvasHolder">
|
||||
<div id="canvasHolder" class="canvasHolder" oncontextmenu="return false;">
|
||||
<canvas id="backgroundCanvas" class="mainCanvases backgroundCanvas" width="2560" height="1440"
|
||||
style="z-index: 0;">
|
||||
<!-- gray grid bg canvas -->
|
||||
|
|
24
js/index.js
24
js/index.js
|
@ -112,6 +112,7 @@ const bgCanvas = document.getElementById("backgroundCanvas"); // gray bg grid
|
|||
const bgCtx = bgCanvas.getContext("2d");
|
||||
|
||||
function startup() {
|
||||
checkIfWebuiIsRunning();
|
||||
loadSettings();
|
||||
drawBackground();
|
||||
changeScaleFactor();
|
||||
|
@ -396,6 +397,7 @@ function mouseMove(evt) {
|
|||
|
||||
function mouseDown(evt) {
|
||||
const rect = ovCanvas.getBoundingClientRect()
|
||||
if (evt.button == 0) { // left click
|
||||
if (placingArbitraryImage) {
|
||||
var nextBox = {};
|
||||
nextBox.x = evt.clientX - ((basePixelCount * scaleFactor) / 2) - rect.left; //origin is middle of the frame
|
||||
|
@ -419,9 +421,19 @@ function mouseDown(evt) {
|
|||
nextBox.h = basePixelCount * scaleFactor;
|
||||
drawTargets.push(nextBox);
|
||||
}
|
||||
} else if (evt.button == 2 && !paintMode) { // right click, also gotta make sure mask blob isn't being used as it's visually inconsistent with behavior of erased region
|
||||
// erase the canvas underneath the cursor,
|
||||
ctx = imgCanvas.getContext('2d');
|
||||
if (snapToGrid) {
|
||||
ctx.clearRect(canvasX + snap(canvasX) - ((basePixelCount * scaleFactor) / 2), canvasY + snap(canvasY) - ((basePixelCount * scaleFactor) / 2), basePixelCount * scaleFactor, basePixelCount * scaleFactor);
|
||||
} else {
|
||||
ctx.clearRect(canvasX - ((basePixelCount * scaleFactor) / 2), canvasY - ((basePixelCount * scaleFactor) / 2), basePixelCount * scaleFactor, basePixelCount * scaleFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mouseUp(evt) {
|
||||
if (evt.button == 0) { // left click
|
||||
if (placingArbitraryImage) {
|
||||
//TODO DO SOMETHING
|
||||
// jeez i REALLY need to refactor tons of this to not be duplicated all over, that's definitely my next chore after figuring out that razza frazza overmask fade
|
||||
|
@ -681,6 +693,7 @@ function mouseUp(evt) {
|
|||
dream(drawIt.x, drawIt.y, stableDiffusionData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeScaleFactor() {
|
||||
|
@ -857,6 +870,17 @@ function cropCanvas(sourceCanvas) {
|
|||
return cutCanvas;
|
||||
}
|
||||
|
||||
function checkIfWebuiIsRunning() {
|
||||
var url = document.getElementById("host").value + "/startup-events"
|
||||
fetch(url).then(response => {
|
||||
if (response.status == 200) {
|
||||
console.log("webui is running");
|
||||
}
|
||||
}).catch(error => {
|
||||
alert("WebUI doesnt seem to be running, please start it and try again\nCheck console for additional info\n" + error);
|
||||
});
|
||||
}
|
||||
|
||||
function loadSettings() {
|
||||
// set default values if not set DEFAULTS
|
||||
var _sampler = localStorage.getItem("sampler") == null ? "DDIM" : localStorage.getItem("sampler");
|
||||
|
|
Loading…
Reference in a new issue