Clamp a View so the visible world rect stays within bounds.
Visible world rect = [view.x, view.x + canvas.width / view.scale.x] ×
[view.y, view.y + canvas.height / view.scale.y].
If the visible rect is larger than bounds along an axis (zoomed out
past the bounds extent), the view is centered on that axis so bounds
sits in the middle of the canvas.
Clamp a
Viewso the visible world rect stays withinbounds.Visible world rect =
[view.x, view.x + canvas.width / view.scale.x]×[view.y, view.y + canvas.height / view.scale.y].If the visible rect is larger than
boundsalong an axis (zoomed out past the bounds extent), the view is centered on that axis so bounds sits in the middle of the canvas.