0.2.0 • Published 6 years ago
@joshfry/aspect-ratio v0.2.0
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
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
.