mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
11 lines
384 B
TypeScript
11 lines
384 B
TypeScript
export function getAspectSafeDimensions(sourceWidth, sourceHeight, reqWidth, reqHeight) {
|
|
let widthCoef = sourceWidth / reqWidth;
|
|
let heightCoef = sourceHeight / reqHeight;
|
|
|
|
let aspectCoef = widthCoef > heightCoef ? widthCoef : heightCoef;
|
|
|
|
return {
|
|
width: Math.floor(sourceWidth / aspectCoef),
|
|
height: Math.floor(sourceHeight / aspectCoef)
|
|
};
|
|
} |