/** * The geometry of a zoomable, pannable image: pure functions over the image's * own pixel size, the viewport it is shown in, and where it sits there. */ export type ZoomSize = { width: number; height: number; }; export type ZoomPoint = { x: number; y: number; }; /** The image's scale (1 = its own pixels) and its top-left corner in the viewport. */ export type ZoomView = { scale: number; x: number; y: number; fit: boolean; }; /** Fitting enlarges a small image at most this much, so tiny screenshots are readable. */ export declare const MAX_FIT_UPSCALE = 2; export declare const MAX_ZOOM = 8; /** Space kept around a fitted image. */ export declare const FIT_PADDING = 16; export declare function fitScale(image: ZoomSize, viewport: ZoomSize, padding?: number): number; /** Zooming out stops at the fitted size, or at actual size for an enlarged small image. */ export declare function minScale(image: ZoomSize, viewport: ZoomSize): number; export declare function clampView(view: ZoomView, image: ZoomSize, viewport: ZoomSize): ZoomView; export declare function fitView(image: ZoomSize, viewport: ZoomSize): ZoomView; /** Zooms to `scale`, keeping the image point under `point` where it is. */ export declare function zoomTo(view: ZoomView, scale: number, point: ZoomPoint, image: ZoomSize, viewport: ZoomSize): ZoomView; /** The next zoom stop in a direction; the fitted size is always one of them. */ export declare function stepScale(view: ZoomView, direction: 1 | -1, image: ZoomSize, viewport: ZoomSize): number; export declare function panBy(view: ZoomView, dx: number, dy: number, image: ZoomSize, viewport: ZoomSize): ZoomView; /** Two fingers, as their spread and midpoint. */ export type ZoomPinch = { distance: number; middle: ZoomPoint; }; /** * One pinch step: the image point under the fingers' previous midpoint follows * them to the new midpoint, scaled by how far they spread. Panning first and then * zooming around the new midpoint keeps that point exactly under the fingers. */ export declare function pinchTo(view: ZoomView, from: ZoomPinch, to: ZoomPinch, image: ZoomSize, viewport: ZoomSize): ZoomView; /** True when the image is larger than the viewport in some direction, so it can be dragged. */ export declare function canPan(view: ZoomView, image: ZoomSize, viewport: ZoomSize): boolean; /** A click toggles between fitted and actual size (or 200% when those match). */ export declare function toggleAt(view: ZoomView, point: ZoomPoint, image: ZoomSize, viewport: ZoomSize): ZoomView; /** * Whether a click on the image enlarges or shrinks it, taken from what * `toggleAt` actually does, so the cursor always shows the click's real effect. */ export declare function clickZoomDirection(view: ZoomView, image: ZoomSize, viewport: ZoomSize): "in" | "out"; export declare function zoomPercent(view: ZoomView): number;