fix resolution not bound to cursor size anymore (again)

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
Victor Seiji Hariki 2022-12-13 20:22:16 -03:00
parent e2afb48703
commit 2e151d2bbc

View file

@ -481,13 +481,13 @@ const _generate = async (
* @param {*} evn * @param {*} evn
* @param {*} state * @param {*} state
*/ */
const dream_generate_callback = async (bb, state) => { const dream_generate_callback = async (bb, resolution, state) => {
// Build request to the API // Build request to the API
const request = {}; const request = {};
Object.assign(request, stableDiffusionData); Object.assign(request, stableDiffusionData);
request.width = bb.w; request.width = resolution.w;
request.height = bb.h; request.height = resolution.h;
// Load prompt (maybe we should add some events so we don't have to do this) // Load prompt (maybe we should add some events so we don't have to do this)
request.prompt = document.getElementById("prompt").value; request.prompt = document.getElementById("prompt").value;
@ -647,7 +647,7 @@ function applyOvermask(canvas, ctx, px) {
/** /**
* Image to Image * Image to Image
*/ */
const dream_img2img_callback = (bb, state) => { const dream_img2img_callback = (bb, resolution, state) => {
// Get visible pixels // Get visible pixels
const visibleCanvas = uil.getVisible(bb); const visibleCanvas = uil.getVisible(bb);
@ -658,8 +658,8 @@ const dream_img2img_callback = (bb, state) => {
const request = {}; const request = {};
Object.assign(request, stableDiffusionData); Object.assign(request, stableDiffusionData);
request.width = bb.w; request.width = resolution.w;
request.height = bb.h; request.height = resolution.h;
request.denoising_strength = state.denoisingStrength; request.denoising_strength = state.denoisingStrength;
request.inpainting_fill = 1; // For img2img use original request.inpainting_fill = 1; // For img2img use original
@ -1093,7 +1093,11 @@ const dreamTool = () =>
state.cursorSize, state.cursorSize,
state.snapToGrid && basePixelCount state.snapToGrid && basePixelCount
); );
dream_generate_callback(bb, state); const resolution = (state.selected && state.selected.bb) || {
w: stableDiffusionData.width,
h: stableDiffusionData.height,
};
dream_generate_callback(bb, resolution, state);
state.selected = null; state.selected = null;
}; };
state.erasecb = (evn) => { state.erasecb = (evn) => {
@ -1492,7 +1496,11 @@ const img2imgTool = () =>
state.cursorSize, state.cursorSize,
state.snapToGrid && basePixelCount state.snapToGrid && basePixelCount
); );
dream_img2img_callback(bb, state); const resolution = (state.selected && state.selected.bb) || {
w: stableDiffusionData.width,
h: stableDiffusionData.height,
};
dream_img2img_callback(bb, resolution, state);
state.selected = null; state.selected = null;
state.redraw(); state.redraw();
}; };