fix: use structure locked drafts for scale shrink
This commit is contained in:
parent
53be242e89
commit
48a0f2ee73
@ -651,6 +651,25 @@ function hasScaleAdjustEnlargeTarget(
|
||||
});
|
||||
}
|
||||
|
||||
function hasScaleAdjustStructureTarget(
|
||||
regions: NormalizedLocalEditRegion[],
|
||||
scalePercent?: ScaleAdjustPercent | null
|
||||
) {
|
||||
return regions.some((region) => {
|
||||
const targetRect = getScaleAdjustTargetRect(region, scalePercent);
|
||||
const widthFactor =
|
||||
region.rect.width > 0 ? targetRect.width / region.rect.width : 1;
|
||||
const heightFactor =
|
||||
region.rect.height > 0 ? targetRect.height / region.rect.height : 1;
|
||||
return (
|
||||
widthFactor > 1.08 ||
|
||||
heightFactor > 1.08 ||
|
||||
widthFactor < 0.92 ||
|
||||
heightFactor < 0.92
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function expandRectWithMargins(
|
||||
rect: NormalizedLocalEditRegion["rect"],
|
||||
marginX: number,
|
||||
@ -2489,7 +2508,10 @@ async function buildScaleAdjustVisualLayoutGuideBuffer(params: {
|
||||
const shouldUseStructureLock =
|
||||
structureLockedDraft &&
|
||||
sourceRaw &&
|
||||
(targetWidthFactor > 1.08 || targetHeightFactor > 1.08);
|
||||
(targetWidthFactor > 1.08 ||
|
||||
targetHeightFactor > 1.08 ||
|
||||
targetWidthFactor < 0.92 ||
|
||||
targetHeightFactor < 0.92);
|
||||
const structureLockedComposite = shouldUseStructureLock
|
||||
? await buildScaleAdjustStructureLockedComposite({
|
||||
includePersonPixels:
|
||||
@ -2603,7 +2625,10 @@ async function createScaleAdjustPatchReference(params: {
|
||||
} = params;
|
||||
const workspaceRect = getScaleAdjustPatchWorkspaceRect(regions, scalePercent);
|
||||
const workspacePixelRect = rectToPixels(workspaceRect, sourceWidth, sourceHeight);
|
||||
const structureLockedDraft = hasScaleAdjustEnlargeTarget(regions, scalePercent);
|
||||
const structureLockedDraft = hasScaleAdjustStructureTarget(
|
||||
regions,
|
||||
scalePercent
|
||||
);
|
||||
const targetDraftBuffer = await buildScaleAdjustVisualLayoutGuideBuffer({
|
||||
regions,
|
||||
scalePercent,
|
||||
@ -3696,7 +3721,8 @@ export async function POST(request: NextRequest) {
|
||||
const useScaleAdjustMarkedPhotoGuide =
|
||||
useScaleAdjustCoordinatePrompt && !useScaleAdjustVisualLayoutGuide;
|
||||
const useScaleAdjustStructureLockedPatchWorkflow =
|
||||
isScaleAdjustOperation && hasScaleAdjustEnlargeTarget(regions, scalePercent);
|
||||
isScaleAdjustOperation &&
|
||||
hasScaleAdjustStructureTarget(regions, scalePercent);
|
||||
const useScaleAdjustEditMask =
|
||||
isScaleAdjustOperation &&
|
||||
!useScaleAdjustStructureLockedPatchWorkflow &&
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user