calc-aspect-ratio
v1.3.0
Published
Calc aspect ratio for display resolutions
Downloads
738
Maintainers
Readme
calc-aspect-ratio
Small package for calculating aspect ratio of display resolution.
Demo
Install
npm i --save-dev calc-aspect-ratio
Using
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);
Examples
- Standard aspect ratio:
4:3
- Approximate aspect ratio:
≈16:9
- Nonstandard aspect ratio:
11.99:1