mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add optimal size handling
This commit is contained in:
committed by
Kent Keirsey
parent
1a4be78013
commit
4fdc4c15f9
@ -2,19 +2,22 @@ import { roundToMultiple } from 'common/util/roundDownToMultiple';
|
||||
import type { Dimensions } from 'features/canvas/store/canvasTypes';
|
||||
import { CANVAS_GRID_SIZE_FINE } from 'features/canvas/store/constants';
|
||||
|
||||
const getScaledBoundingBoxDimensions = (dimensions: Dimensions) => {
|
||||
const getScaledBoundingBoxDimensions = (
|
||||
dimensions: Dimensions,
|
||||
optimalDimension: number
|
||||
) => {
|
||||
const { width, height } = dimensions;
|
||||
|
||||
const scaledDimensions = { width, height };
|
||||
const targetArea = 512 * 512;
|
||||
const targetArea = optimalDimension * optimalDimension;
|
||||
const aspectRatio = width / height;
|
||||
let currentArea = width * height;
|
||||
let maxDimension = 448;
|
||||
let maxDimension = optimalDimension - CANVAS_GRID_SIZE_FINE;
|
||||
while (currentArea < targetArea) {
|
||||
maxDimension += CANVAS_GRID_SIZE_FINE;
|
||||
if (width === height) {
|
||||
scaledDimensions.width = 512;
|
||||
scaledDimensions.height = 512;
|
||||
scaledDimensions.width = optimalDimension;
|
||||
scaledDimensions.height = optimalDimension;
|
||||
break;
|
||||
} else {
|
||||
if (aspectRatio > 1) {
|
||||
|
Reference in New Issue
Block a user