Skip to content

cover

ts
function Rect.cover(target: Rect, source: Rect): Rect

Scales the target rectangle up proportionally so it completely covers the source rectangle while maintaining its aspect ratio, then centers it within the source.

Example

ts
Rect.cover(
    { left: 10, top: 20, width: 100, height: 50 },
    { left: 0, top: 0, width: 150, height: 120 },
);
// { left: -75, top: -30, width: 300, height: 150 }
ts
pipe(
    { left: 10, top: 20, width: 100, height: 50 },
    Rect.cover({ left: 0, top: 0, width: 150, height: 120 }),
);
// { left: -75, top: -30, width: 300, height: 150 }