weasel API - v0.8.0
    Preparing search index...

    Function fitViewToBounds

    • Compute the target View that fits bounds (world space) inside viewportDims (CSS px). The bounds are centered in the viewport with uniform padding on all sides; the resulting scale is clamped to the configured min/max.

      View semantics: view.x / view.y is the world point currently drawn at the canvas top-left, and view.scale.{x,y} is pixels per world unit on each axis (see view.ts). So: screenX = (worldX - view.x) * view.scale.x screenY = (worldY - view.y) * view.scale.y

      Empty / zero-sized bounds or viewports cannot be fit — in that case this returns currentView unchanged and logs a console.warn. Callers that want to no-op silently can detect zero area themselves before calling.

      Parameters

      Returns View