Commit d934e0e8 authored by Laureline Nevin's avatar Laureline Nevin ⌨️
Browse files

Fixed resize keepRatio causing export area to exceed render area

parent d82ef947
Loading
Loading
Loading
Loading
+7 −8
Changes for src/app.ts: 7 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -849,15 +849,14 @@ export class App {
            };
            if (qx === 1 || qy === 1) {
                // Side
                setMinMax(qy === 1 ? 0 : 1);
                const ax = qy === 1 ? 0 : 1;
                setMinMax(ax);
                if (keepRatio) {
                    const newSize = Math.max(
                        1,
                        (wh[1 - (qy === 1 ? 0 : 1)] * (xyMax[qy === 1 ? 0 : 1] - xyMin[qy === 1 ? 0 : 1])) /
                            wh[qy === 1 ? 0 : 1],
                    );
                    xyMin[1 - (qy === 1 ? 0 : 1)] += Math.floor((wh[1 - (qy === 1 ? 0 : 1)] - newSize) / 2);
                    xyMax[1 - (qy === 1 ? 0 : 1)] = xyMin[1 - (qy === 1 ? 0 : 1)] + Math.ceil(newSize);
                    const maxSize = total[1 - ax] - Math.abs(total[1 - ax] / 2 - xyMid[1 - ax]) * 2;
                    let newSize = (wh[1 - ax] * (xyMax[ax] - xyMin[ax])) / wh[ax];
                    newSize = Math.max(1, Math.min(newSize, maxSize));
                    xyMin[1 - ax] += Math.floor((wh[1 - ax] - newSize) / 2);
                    xyMax[1 - ax] = xyMin[1 - ax] + Math.ceil(newSize);
                }
            } else {
                // Corner