Skip to main content

Function: calculatePixelsPerUnit()

calculatePixelsPerUnit(canvasHeight, verticalWorldUnits): number

Defined in: rendering/utilities/calculate-pixels-per-unit.ts:10

Computes pixels-per-unit from a camera's verticalWorldUnits and the current canvas height, so a world unit spans a consistent number of screen pixels regardless of vertical resolution.

Parameters

canvasHeight

number

The render destination's height, in pixels.

verticalWorldUnits

number

The total world-space height the camera should show.

Returns

number

The number of pixels one world unit occupies vertically.

Throws

An error if canvasHeight or verticalWorldUnits is not positive.