2.0.1 • Published 3 years ago

@joeflateau/fit-rect v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

fit-rect

npm.io

stable

Fits one rectangle into another

Usage

NPM

fitRect(rect: Size, target: Rect, mode: FitMode): Rect
Parameters:
Returns:
import { fitRect } from "fit-rect";

const rect = [16, 9];
const target = [200, 200, 400, 400];
const containedRect = fitRect(rect, target, "contain"); //[ 200, 287.5, 400, 225 ]
const coveringRect = fitRect(rect, target, "cover"); //[ 44.4, 200, 711.1, 400 ]

License

MIT, see LICENSE.md for details.