Small package for calculating aspect ratio of display resolution.
npm i --save-dev calc-aspect-ratio
import { calcAspectRatio } from 'calc-aspect-ratio';
const aspectRatio = calcAspectRatio(1920, 1080);
console.log(aspectRatio);
/* console output:
{
x: 16,
y: 9,
value: '16:9',
approximately: false,
nonStandard: false
}
*/
// or calc for current screen
console.log(calcAspectRatio(screen.width, screen.height).value);
- Standard aspect ratio:
4:3
- Approximate aspect ratio:
≈16:9
- Nonstandard aspect ratio:
11.99:1