mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-25 22:35:43 -03:00
Keep Proportion with shift
This commit is contained in:
23
js/Canvas.js
23
js/Canvas.js
@@ -701,6 +701,29 @@ export class Canvas {
|
|||||||
let newWidth = vecX * cos + vecY * sin;
|
let newWidth = vecX * cos + vecY * sin;
|
||||||
let newHeight = vecY * cos - vecX * sin;
|
let newHeight = vecY * cos - vecX * sin;
|
||||||
|
|
||||||
|
if (isShiftPressed) {
|
||||||
|
const originalAspectRatio = o.width / o.height;
|
||||||
|
if (handle.length === 2) {
|
||||||
|
|
||||||
|
const potentialWidth = Math.abs(newWidth);
|
||||||
|
const potentialHeight = Math.abs(newHeight);
|
||||||
|
|
||||||
|
if (potentialWidth / originalAspectRatio > potentialHeight) {
|
||||||
|
newHeight = newWidth / originalAspectRatio;
|
||||||
|
} else {
|
||||||
|
newWidth = newHeight * originalAspectRatio;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (signX !== 0) {
|
||||||
|
newHeight = newWidth / originalAspectRatio;
|
||||||
|
} else {
|
||||||
|
newWidth = newHeight * originalAspectRatio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let signX = handle.includes('e') ? 1 : (handle.includes('w') ? -1 : 0);
|
let signX = handle.includes('e') ? 1 : (handle.includes('w') ? -1 : 0);
|
||||||
let signY = handle.includes('s') ? 1 : (handle.includes('n') ? -1 : 0);
|
let signY = handle.includes('s') ? 1 : (handle.includes('n') ? -1 : 0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user