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

Remarks

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