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(
|
function expandRectWithMargins(
|
||||||
rect: NormalizedLocalEditRegion["rect"],
|
rect: NormalizedLocalEditRegion["rect"],
|
||||||
marginX: number,
|
marginX: number,
|
||||||
@ -2489,7 +2508,10 @@ async function buildScaleAdjustVisualLayoutGuideBuffer(params: {
|
|||||||
const shouldUseStructureLock =
|
const shouldUseStructureLock =
|
||||||
structureLockedDraft &&
|
structureLockedDraft &&
|
||||||
sourceRaw &&
|
sourceRaw &&
|
||||||
(targetWidthFactor > 1.08 || targetHeightFactor > 1.08);
|
(targetWidthFactor > 1.08 ||
|
||||||
|
targetHeightFactor > 1.08 ||
|
||||||
|
targetWidthFactor < 0.92 ||
|
||||||
|
targetHeightFactor < 0.92);
|
||||||
const structureLockedComposite = shouldUseStructureLock
|
const structureLockedComposite = shouldUseStructureLock
|
||||||
? await buildScaleAdjustStructureLockedComposite({
|
? await buildScaleAdjustStructureLockedComposite({
|
||||||
includePersonPixels:
|
includePersonPixels:
|
||||||
@ -2603,7 +2625,10 @@ async function createScaleAdjustPatchReference(params: {
|
|||||||
} = params;
|
} = params;
|
||||||
const workspaceRect = getScaleAdjustPatchWorkspaceRect(regions, scalePercent);
|
const workspaceRect = getScaleAdjustPatchWorkspaceRect(regions, scalePercent);
|
||||||
const workspacePixelRect = rectToPixels(workspaceRect, sourceWidth, sourceHeight);
|
const workspacePixelRect = rectToPixels(workspaceRect, sourceWidth, sourceHeight);
|
||||||
const structureLockedDraft = hasScaleAdjustEnlargeTarget(regions, scalePercent);
|
const structureLockedDraft = hasScaleAdjustStructureTarget(
|
||||||
|
regions,
|
||||||
|
scalePercent
|
||||||
|
);
|
||||||
const targetDraftBuffer = await buildScaleAdjustVisualLayoutGuideBuffer({
|
const targetDraftBuffer = await buildScaleAdjustVisualLayoutGuideBuffer({
|
||||||
regions,
|
regions,
|
||||||
scalePercent,
|
scalePercent,
|
||||||
@ -3696,7 +3721,8 @@ export async function POST(request: NextRequest) {
|
|||||||
const useScaleAdjustMarkedPhotoGuide =
|
const useScaleAdjustMarkedPhotoGuide =
|
||||||
useScaleAdjustCoordinatePrompt && !useScaleAdjustVisualLayoutGuide;
|
useScaleAdjustCoordinatePrompt && !useScaleAdjustVisualLayoutGuide;
|
||||||
const useScaleAdjustStructureLockedPatchWorkflow =
|
const useScaleAdjustStructureLockedPatchWorkflow =
|
||||||
isScaleAdjustOperation && hasScaleAdjustEnlargeTarget(regions, scalePercent);
|
isScaleAdjustOperation &&
|
||||||
|
hasScaleAdjustStructureTarget(regions, scalePercent);
|
||||||
const useScaleAdjustEditMask =
|
const useScaleAdjustEditMask =
|
||||||
isScaleAdjustOperation &&
|
isScaleAdjustOperation &&
|
||||||
!useScaleAdjustStructureLockedPatchWorkflow &&
|
!useScaleAdjustStructureLockedPatchWorkflow &&
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user