Skip to content
pixi-silk
GitHub repository
Entry point

pixi-silk/ui/camera

Camera: pan and zoom a world container, ZoomControl.

import { Camera, ZoomControl, zoomLabel } from 'pixi-silk/ui/camera';

Classes#

ClassDescription
CameraPans and zooms a world container over an unbounded canvas. It writes the world’s position and scale, so do not set them yourself while a camera owns the world.
ZoomControlA - 100% + pill for a Camera, 128x32 pixels. The buttons zoom around the view’s centre and the percentage fits the content (or resets). The readout follows the camera’s zoom signal. Place it in screen space, beside the world. Destroying it unsubscribes from the camera.

Interfaces#

InterfaceDescription
CameraInsetsSpace to keep free on each side of the view, in CSS pixels. A side left out is 0.
CameraOptionsOptions of Camera.
CameraStateThe reactive view of a Camera: where it is now, animations included.
WorldRectA rectangle in world units (the local space of CameraOptions.world).
ZoomControlOptionsOptions of ZoomControl.

Functions#

FunctionDescription
zoomLabelFormats a zoom (1 is 100%) as a short percentage. Below 10% it keeps one decimal (2.5%), from 10,000% it switches to k (2.5k%) and from 1,000,000% to M (1.2M%).