bbox-aspect-ratio
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

Bounding Box Aspect Ratio

Calculate aspect ration from bounding box

🔧 Installation

npm i bbox-aspect-ratio

📦 Usage

import { bBoxAspectRatio, calculateSize, SizeType } from "bbox-aspect-ratio";
 
// Get aspect ratio
const topRight = [76.20742, 11.59426];
const bottomLeft = [76.86794, 11.95073];
const aspectRatio = bBoxAspectRatio([...topRight, ...bottomLeft]);
console.log(aspectRatio); // [1321, 713]
 
// Calculate size by width
const sizeByWidth = calculateSize(aspectRatio, 50, SizeType.Width);
console.log(sizeByWidth); // 27 → w: 50, h: 27
 
// Calculate size by height
const sizeByHeight = calculateSize(aspectRatio, 50, SizeType.Height);
console.log(sizeByWidth); // 93 → w: 93, h: 50

/bbox-aspect-ratio/

    Package Sidebar

    Install

    npm i bbox-aspect-ratio

    Weekly Downloads

    20

    Version

    1.4.1

    License

    MIT

    Unpacked Size

    13.2 kB

    Total Files

    18

    Last publish

    Collaborators

    • harshzalavadiya