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