Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rect-clamp

gre1kISC0.0.0

Constraint a Rectangle into another by preserving the ratio.

rect, rectangle, 2d, bound, clamp, constraints

readme

rect-clamp

Constraint a Rectangle into another by preserving the ratio.

var rect = rectClamp([-100,-100,200,200], [0,0,800,600]);
// rect == [0, 0, 200, 200]
var rect2 = rectClamp([-100,-100,2000,2000], [0,0,800,600]);
// rect2 == [ 0, 0, 600, 600 ]