feat: center content in canvas expanded to aspect ratio

This commit is contained in:
Arnošt Pleskot
2023-08-22 21:33:04 +02:00
parent c49bf04801
commit e00764a937
2 changed files with 19 additions and 5 deletions
+3 -3
View File
@@ -1038,11 +1038,11 @@ export const expandToAspectRatio = (
let newWidth = Math.round(originalWidth);
let newHeight = Math.round(originalHeight);
// Expand by width
if (originalAspectRatio > targetAspectRatio) {
// Original is landscape, expand width
if (originalAspectRatio < targetAspectRatio) {
newWidth = Math.round(originalHeight * targetAspectRatio);
}
// Expand by height
// Original is portrait or square, expand height
else {
newHeight = Math.round(originalWidth / targetAspectRatio);
}