Unused variable cleanup and new overmask px default

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
Victor Seiji Hariki 2022-12-26 22:24:26 -03:00
parent 8fbc42744e
commit 12e371a481
4 changed files with 17 additions and 40 deletions

View file

@ -7,6 +7,9 @@ const config = makeReadOnly(
{
// Scroll Tick Limit (How much must scroll to reach next tick)
wheelTickSize: 50,
// Endpoint
api: makeReadOnly({path: "/sdapi/v1/"}),
},
"config"
);

View file

@ -132,35 +132,9 @@ var stableDiffusionData = {
};
// stuff things use
let debug = false;
var returnedImages;
var imageIndex = 0;
var tmpImgXYWH = {};
var host = "";
var url = "/sdapi/v1/";
var endpoint = "txt2img";
var frameX = 512;
var frameY = 512;
var drawThis = {};
const basePixelCount = 64; //64 px - ALWAYS 64 PX
var snapToGrid = true;
var backupMaskPaintCanvas; //???
var backupMaskPaintCtx; //...? look i am bad at this
var backupMaskChunk = null;
var backupMaskX = null;
var backupMaskY = null;
var totalImagesReturned;
var overMaskPx = 0;
var drawTargets = []; // is this needed? i only draw the last one anyway...
var dropTargets = []; // uhhh yeah similar to the above but for arbitrary dropped images
var arbitraryImage;
var arbitraryImageData;
var arbitraryImageBitmap;
var arbitraryImageBase64; // seriously js cmon work with me here
var placingArbitraryImage = false; // for when the user has loaded an existing image from their computer
var marchOffset = 0;
var inProgress = false;
var marchCoords = {};
//
function startup() {

View file

@ -13,7 +13,7 @@ let generating = false;
const _monitorProgress = (bb, oncheck = null) => {
const minDelay = 1000;
const apiURL = `${host}${url}progress?skip_current_image=true`;
const apiURL = `${host}${config.api.path}progress?skip_current_image=true`;
const expanded = {...bb};
expanded.x--;
@ -84,7 +84,7 @@ const _monitorProgress = (bb, oncheck = null) => {
* @returns {Promise<string[]>}
*/
const _dream = async (endpoint, request) => {
const apiURL = `${host}${url}${endpoint}`;
const apiURL = `${host}${config.api.path}${endpoint}`;
// Debugging is enabled
if (global.debug) {
@ -380,7 +380,7 @@ const _generate = async (endpoint, request, bb, options = {}) => {
interruptButton.classList.add("dream-stop-btn");
interruptButton.textContent = "Interrupt";
interruptButton.addEventListener("click", () => {
fetch(`${host}${url}interrupt`, {method: "POST"});
fetch(`${host}${config.api.path}interrupt`, {method: "POST"});
interruptButton.disabled = true;
});
const marchingOptions = {};
@ -400,13 +400,13 @@ const _generate = async (endpoint, request, bb, options = {}) => {
if (lastProgress < nextCP && data.progress >= nextCP) {
nextCP += options.drawEvery;
fetch(`${host}${url}progress?skip_current_image=false`).then(
async (response) => {
fetch(
`${host}${config.api.path}progress?skip_current_image=false`
).then(async (response) => {
if (stopDrawingStatus) return;
const imagedata = await response.json();
redraw(imagedata.current_image);
}
);
});
}
lastProgress = data.progress;
});
@ -1191,7 +1191,7 @@ const dreamTool = () =>
state.invertMask = false;
state.keepUnmasked = true;
state.keepUnmaskedBlur = 8;
state.overMaskPx = 0;
state.overMaskPx = 20;
state.preserveMasks = false;
state.erasePrevCursor = () =>
@ -2022,7 +2022,8 @@ const img2imgTool = () =>
window.onbeforeunload = async () => {
// Stop current generation on page close
if (generating) await fetch(`${host}${url}interrupt`, {method: "POST"});
if (generating)
await fetch(`${host}${config.api.path}interrupt`, {method: "POST"});
};
const sendSeed = (seed) => {

View file

@ -33,7 +33,6 @@ const interrogateTool = () =>
state.snapToGrid = true;
state.invertMask = false;
state.overMaskPx = 0;
state.block_res_change = true;
state.erasePrevReticle = () => ovLayer.clear();
@ -163,7 +162,7 @@ const interrogate_callback = async (evn, state) => {
* @returns {Promise<string>}
*/
const _interrogate = async (request) => {
const apiURL = `${host}${url}` + "interrogate";
const apiURL = `${host}${config.api.path}interrogate`;
/** @type {StableDiffusionResponse} */
let data = null;