@cornerstonejs/core
Version:
Cornerstone3D Core
13 lines (12 loc) • 447 B
JavaScript
import isEqual from './isEqual.js';
const EPSILON = 1e10;
export const getNormalizedAspectRatio = (aspectRatio) => {
const [width, height] = aspectRatio;
if (isEqual(width, height)) {
return [1, 1];
}
const min = Math.min(width, height);
const normalizedW = Math.round((width / min) * EPSILON) / EPSILON;
const normalizedH = Math.round((height / min) * EPSILON) / EPSILON;
return [normalizedW, normalizedH];
};