calculate-aspect-ratio
Version:
A simple utility function, and command line utility, for calculating an aspect ratio based on width and height.
25 lines (18 loc) • 797 B
JavaScript
/*! calculate-aspect-ratio v0.1.3 | (c) 2018 Ryan Hefner | MIT License | https://github.com/ryanhefner/calculate-aspect-ratio !*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global['calculate-aspect-ratio'] = {})));
}(this, (function (exports) { 'use strict';
var gcd = function gcd(a, b) {
return b ? gcd(b, a % b) : a;
};
var aspectRatio = function aspectRatio(width, height) {
var divisor = gcd(width, height);
return width / divisor + ":" + height / divisor;
};
exports.gcd = gcd;
exports['default'] = aspectRatio;
Object.defineProperty(exports, '__esModule', { value: true });
})));
/* follow me on Twitter! @ryanhefner */