Skip to main content

Function: viewportFrame()

viewportFrame(viewport, canvasWidth, canvasHeight): object

Defined in: src/ui/elements/PcCanvasMap/index.ts:26

Convert the visible area into percentage offsets and sizes within the map, clamped to the canvas.

Parameters​

viewport​

Rect

canvasWidth​

number

canvasHeight​

number

Returns​

object

height​

height: number

left​

left: number

top​

top: number

width​

width: number

Example​

viewportFrame({ x: 500, y: 0, width: 1000, height: 1000 }, 2000, 2000);
// { left: 25, top: 0, width: 50, height: 50 }