@joshfry/aspect-ratio

0.2.0 • Public • Published

Aspect Ratio helper functions

Method Description
getGcd(w, h) Returns greatest common denominator as a number.
getFraction(w, h); Returns an object: { nominator, denominator }.
getAspectRatioString(w, h); Returns a string, like: "4:3"
getAspectRatioPercentage(w, h); Returns aspect ratio percentage as a number >= 1.

Install

  • npm $ npm i @joshfry/aspect-ratio
  • yarn $ yarn add @joshfry/aspect-ratio

Usage

import { getAspectRatioPercentage } from '@joshfry/aspect-ratio';
const aspectRatioPercentage = getAspectRatioPercentage(w, h);

Test

Install Jest globally with npm i jest-cli -g and run jest.

Readme

Keywords

Package Sidebar

Install

npm i @joshfry/aspect-ratio

Weekly Downloads

6

Version

0.2.0

License

ISC

Unpacked Size

4.97 kB

Total Files

7

Last publish

Collaborators

  • joshfry