Skip to content

computeFitTransform

computeFitTransform(bounds, size, padding, limits): ViewportTransform

Defined in: src/components/primitives/viewport/viewportMath.ts:22

Compute a transform that fits bounds (in world coordinates) into the viewport size, with optional uniform inner padding in screen pixels.

The resulting transform preserves aspect ratio (uniform zoom on both axes) and centers the content within the viewport.

Parameters

bounds

WorldRect

size

ViewportSize

padding

number

limits

ZoomLimits

Returns

ViewportTransform