Join us to discuss the challenges, solutions and best practices for in-house JavaScript code sharing. Tuesday, 12/17 at 10am PT/1pm ET.Sign up here »

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

Keywords

Install

npm i @joshfry/aspect-ratio

DownloadsWeekly Downloads

6

Version

0.2.0

License

ISC

Unpacked Size

4.97 kB

Total Files

7

Last publish

Collaborators

  • avatar