@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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    6
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    6
  • 0.1.2
    0
  • 0.1.1
    0

Package Sidebar

Install

npm i @joshfry/aspect-ratio

Weekly Downloads

5

Version

0.2.0

License

ISC

Unpacked Size

4.97 kB

Total Files

7

Last publish

Collaborators

  • joshfry