1.3.0 • Published 3 months ago

calc-aspect-ratio v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

calc-aspect-ratio

NPM version NPM downloads install size

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

Links

1.3.0

3 months ago

1.2.0

3 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago