1.0.1 • Published 3 years ago
aspratio v1.0.1
aspratio
To get aspect-ratio of 'screen size or image'
Install
npm install aspratioUsage:
get ratio with CJS
const ratio = require("aspratio");
const [Width, Height] = [1920, 1080];
console.log(ratio.toRatio(Width, Height)); // => 16:9
console.log(ratio.toRatio(Width, Height, '/')); // => 16/9const { toRatio } = require("aspratio");
const [Width, Height] = [1920, 1080];
console.log(toRatio(Width, Height)); // => 16:9
console.log(toRatio(Width, Height, '/')); // => 16/9get ratio with ESM
import ratio from "aspratio";
const [Width, Height] = [1920, 1080];
console.log(ratio.toRatio(Width, Height)); // => 16:9
console.log(ratio.toRatio(Width, Height, '/')); // => 16/9import { toRatio } from "aspratio";
const [Width, Height] = [1920, 1080];
console.log(toRatio(Width, Height)); // => 16:9
console.log(toRatio(Width, Height, '/')); // => 16/9To get width
CJS :
const ratio = require("aspratio");
const Height = 1080;
console.log(ratio.toWidth("16:9", Height)); // 1920const { toWidth } = require("aspratio");
const Height = 1080;
console.log(toWidth("16:9", Height)); // 1920ESM :
import ratio from "aspratio";
const Height = 1080;
console.log(ratio.toWidth("16:9", Height)); // 1920import { toWidth } from "aspratio";
const Height = 1080;
console.log(toWidth("16:9", Height)); // 1920To get height
CJS :
const ratio = require("aspratio");
const Width = 1920;
console.log(ratio.toHeight("16:9", Width)); // 1080const { toHeight } = require("aspratio");
const Width = 1920;
console.log(toHeight("16:9", Width)); // 1080ESM :
import ratio from "aspratio";
const Width = 1920;
console.log(ratio.toHeight("16:9", Width)); // 1080import { toHeight } from "aspratio";
const Width = 1920;
console.log(toHeight("16:9", Width)); // 1080