Skip to content

@ue-too/board / index / minZoomLevelBaseOnHeight

函式: minZoomLevelBaseOnHeight()

minZoomLevelBaseOnHeight(boundaries, canvasWidth, canvasHeight, cameraRotation): number | undefined

定義於: packages/board/src/utils/zoomlevel-adjustment.ts:261

Calculates minimum zoom level based only on boundary height.

參數

boundaries

The world-space boundaries

Boundaries | undefined

canvasWidth

number

Canvas width in pixels

canvasHeight

number

Canvas height in pixels

cameraRotation

number

Camera rotation angle in radians

回傳

number | undefined

Minimum zoom level, or undefined if height is not defined

備註

Similar to minZoomLevelBaseOnDimensions but only considers the height constraint. Useful when width is unbounded or not relevant.

Calculates zoom needed to fit the boundary height within the canvas, accounting for rotation:

  • Height projection on canvas X-axis: height * cos(rotation)
  • Height projection on canvas Y-axis: height * sin(rotation)

Takes the maximum of these to ensure the height fits regardless of how rotation distributes it across canvas axes.

範例

typescript
const boundaries = {
  min: { y: 0 },
  max: { y: 500 }
};

const zoom = minZoomLevelBaseOnHeight(boundaries, 800, 600, 0);
// Result: 1.2 (600/500)

參閱

minZoomLevelBaseOnDimensions for full calculation