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.
Compute the target View that fits
bounds(world space) insideviewportDims(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.yis the world point currently drawn at the canvas top-left, andview.scale.{x,y}is pixels per world unit on each axis (seeview.ts). So: screenX = (worldX - view.x) * view.scale.x screenY = (worldY - view.y) * view.scale.yEmpty / zero-sized bounds or viewports cannot be fit — in that case this returns
currentViewunchanged and logs aconsole.warn. Callers that want to no-op silently can detect zero area themselves before calling.