Fits one rectangle into another
Parameters:
rect
- array [x,y,w,h]
target
- array [x,y,w,h]
mode
- string 'contain' (default) or 'cover'
Returns rectangle [x,y,w,h]
var fitRect = require('fit-rect');
var rect = [0, 0, 16, 9];
var target = [200, 200, 400, 400];
var containedRect = fitRect(rect, target, 'contain'); //[ 200, 287.5, 400, 225 ]
var coveringRect = fitRect(rect, target, 'cover'); //[ 44.4, 200, 711.1, 400 ]
MIT, see LICENSE.md for details.