UNPKG

@niuee/board

Version:

<h1 align="center"> board </h1> <p align="center"> board supercharges your html canvas element giving it the capabilities to pan, zoom, rotate, and much more. </p> <p align="center"> <a href="https://www.npmjs.com/package/@niuee/board">

100 lines (99 loc) 3.51 kB
import { PanHandlerConfig } from "../board-camera/pan/pan-handlers"; import { ZoomHandlerConfig } from "../board-camera/zoom/zoom-handler"; import type { RotationHandlerConfig } from "./rotation"; import { ObservableBoardCamera } from "./interface"; import { PanContext } from "../input-flow-control/pan-control-state-machine"; import { ZoomContext } from "../input-flow-control/zoom-control-state-machine"; import { Point } from "../util/misc"; /** * @description The config for the camera rig. * Camera rig combines pan, zoom and rotation handlers. * * @category Input Flow Control */ export type CameraRigConfig = PanHandlerConfig & ZoomHandlerConfig & RotationHandlerConfig; /** * @description The camera rig. * * This is a consolidated handler function for pan, zoom and rotation. * Essentially, it is a controller that controls the camera, so you don't have to figure out some of the math that is involved in panning, zooming and rotating the camera. * * @category Camera */ export declare class CameraRig implements PanContext, ZoomContext { private _panBy; private _panTo; private _zoomTo; private _zoomBy; private _rotateBy; private _rotateTo; private _config; private _camera; constructor(config: PanHandlerConfig & ZoomHandlerConfig, camera?: ObservableBoardCamera); /** * @description Zoom to a certain zoom level at a certain point. The point is in the viewport coordinate system. */ zoomToAt(targetZoom: number, at: Point): void; /** * @description Zoom by a certain amount at a certain point. The point is in the viewport coordinate system. */ zoomByAt(delta: number, at: Point): void; /** * @description Zoom to a certain zoom level with respect to the center of the viewport. */ zoomTo(targetZoom: number): void; /** * @description Zoom by a certain amount with respect to the center of the viewport. */ zoomBy(delta: number): void; /** * @description Zoom to a certain zoom level with respect to a point in the world coordinate system. */ zoomToAtWorld(targetZoom: number, at: Point): void; /** * @description Zoom by a certain amount with respect to a point in the world coordinate system. */ zoomByAtWorld(delta: number, at: Point): void; /** * @description Pan By a certain amount. (delta is in the viewport coordinate system) */ panBy(delta: Point): void; /** * @description Pan to a certain point. (target is in the world coordinate system) */ panTo(target: Point): void; /** * @description Rotate by a certain amount. */ rotateBy(delta: number): void; /** * @description Rotate to a certain angle. */ rotateTo(target: number): void; set limitEntireViewPort(limit: boolean); /** * @description Whether the entire view port is limited. */ get limitEntireViewPort(): boolean; get camera(): ObservableBoardCamera; get config(): CameraRigConfig; set config(config: CameraRigConfig); /** * @description Configure the camera rig. */ configure(config: Partial<CameraRigConfig>): void; /** * @description Cleanup the camera rig. */ cleanup(): void; /** * @description Setup the camera rig. */ setup(): void; } /** * @description Create a default camera rig. * * @category Camera */ export declare function createDefaultCameraRig(camera: ObservableBoardCamera): CameraRig;