@lancercomet/zoom-pan 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,831 @@
1
+ export declare type AnchorType = 'topLeft' | 'center';
2
+
3
+ /**
4
+ * Image is used to load and display an image in world space.
5
+ */
6
+ export declare class BitmapLayer extends CanvasLayer {
7
+ #private;
8
+ /** 从图片源创建位图层(会把像素绘入离屏) */
9
+ static fromImage(options: ICreateBitmapLayerOptions): Promise<BitmapLayer>;
10
+ /** 替换图源(尺寸会重配) */
11
+ setSource(src: string | File | Blob, crossOrigin?: '' | 'anonymous' | 'use-credentials'): Promise<void>;
12
+ /** 在位图上作画(提供 ctx) */
13
+ paint(fn: (ctx: CanvasRenderingContext2D, canvas: HTMLCanvasElement) => void): void;
14
+ /** 读取/写回像素 */
15
+ getImageData(sx?: number, sy?: number, sw?: number, sh?: number): ImageData;
16
+ putImageData(img: ImageData, dx?: number, dy?: number): void;
17
+ /** 导出(PNG dataURL 或 ImageBitmap) */
18
+ toDataURL(type?: string, quality?: number): string;
19
+ toImageBitmap(opts?: ImageBitmapOptions): Promise<ImageBitmap>;
20
+ destroy(): void;
21
+ private constructor();
22
+ }
23
+
24
+ export declare type BlendMode = GlobalCompositeOperation;
25
+
26
+ /**
27
+ * CanvasLayer is used to create a layer with an offscreen canvas in either world or screen space.
28
+ * You can draw anything you want on the offscreen canvas, and it will be rendered as a layer.
29
+ */
30
+ export declare class CanvasLayer extends LayerBase {
31
+ private readonly _redraw?;
32
+ readonly canvas: HTMLCanvasElement;
33
+ readonly context: CanvasRenderingContext2D;
34
+ x: number;
35
+ y: number;
36
+ scale: number;
37
+ rotation: number;
38
+ anchor: AnchorType;
39
+ private _drawing;
40
+ private _lastX;
41
+ private _lastY;
42
+ /**
43
+ * Begin a stroke at the given world coordinates.
44
+ */
45
+ beginStroke(wx: number, wy: number): void;
46
+ /**
47
+ * Continue a stroke to the given world coordinates.
48
+ */
49
+ stroke(wx: number, wy: number, color: string, size: number, pressure?: number, mode?: 'brush' | 'eraser'): void;
50
+ /**
51
+ * End the current stroke.
52
+ */
53
+ endStroke(): void;
54
+ /**
55
+ * Check if currently drawing.
56
+ */
57
+ isDrawing(): boolean;
58
+ /**
59
+ * Capture a snapshot of the canvas content.
60
+ * If region is provided, only that region is captured (more memory efficient).
61
+ * Returns null if capture fails.
62
+ */
63
+ captureSnapshot(region?: IRect): ImageData | null;
64
+ /**
65
+ * Restore a snapshot to the canvas.
66
+ * If position is provided, the snapshot is placed at that position.
67
+ * Otherwise, it's placed at (0, 0).
68
+ */
69
+ restoreSnapshot(data: ImageData, position?: {
70
+ x: number;
71
+ y: number;
72
+ }): void;
73
+ /**
74
+ * Clear a region of the canvas.
75
+ * If no region is provided, clears the entire canvas.
76
+ */
77
+ clearRegion(region?: IRect): void;
78
+ /**
79
+ * Request a redraw of the offscreen canvas.
80
+ * This will call the redraw function you provided in the constructor.
81
+ */
82
+ requestRedraw(): void;
83
+ /**
84
+ * Draw an image onto the offscreen canvas.
85
+ */
86
+ drawImage(image: HTMLImageElement | HTMLCanvasElement | ImageBitmap, dx: number, dy: number, dw?: number, dh?: number): void;
87
+ /**
88
+ * Hit test the layer.
89
+ * Returns true if the point (wx, wy) in world space is within the layer bounds.
90
+ */
91
+ hitTest(wx: number, wy: number): boolean;
92
+ /**
93
+ * Convert a point from world space to local layer space.
94
+ */
95
+ toLocalPoint(wx: number, wy: number): {
96
+ lx: number;
97
+ ly: number;
98
+ };
99
+ /**
100
+ * Render the layer onto the given context.
101
+ */
102
+ render(ctx: CanvasRenderingContext2D, view?: ViewManager): void;
103
+ cropTo(config: ILayerResizeConfig): void;
104
+ resizeTo(config: ILayerResizeConfig): void;
105
+ private _cloneCanvas;
106
+ private _setCanvasSize;
107
+ destroy(): void;
108
+ constructor(options: ICreateCanvasLayerOption);
109
+ }
110
+
111
+ export declare type CommandType = 'snapshot' | string;
112
+
113
+ /**
114
+ * Content Layer Manager is used to store content bitmaps.
115
+ * Uses a composite cache to avoid re-rendering all layers every frame.
116
+ */
117
+ export declare class ContentLayerManager extends LayerManagerBase {
118
+ private _compositeCache;
119
+ private _compositeCacheCtx;
120
+ private _compositeDirty;
121
+ private _lastCacheWidth;
122
+ private _lastCacheHeight;
123
+ private _cachedBoundsMinX;
124
+ private _cachedBoundsMinY;
125
+ /**
126
+ * Mark the composite cache as dirty.
127
+ * Call this when any layer content changes.
128
+ */
129
+ markDirty(): void;
130
+ /**
131
+ * Override addLayer to mark cache dirty.
132
+ */
133
+ addLayer(layer: LayerBase, insertAt?: number): string;
134
+ /**
135
+ * Override removeLayer to mark cache dirty.
136
+ */
137
+ removeLayer(id: string): void;
138
+ /**
139
+ * Override moveLayer to mark cache dirty.
140
+ */
141
+ moveLayer(id: string, toIndex: number): void;
142
+ /**
143
+ * Render all layers in target view.
144
+ * Uses composite cache for better performance with many layers.
145
+ */
146
+ renderAllLayersIn(view: ViewManager): void;
147
+ /**
148
+ * Rebuild the composite cache from all world layers.
149
+ */
150
+ private _rebuildCompositeCache;
151
+ /**
152
+ * Override destroy to clean up cache.
153
+ */
154
+ destroy(): void;
155
+ }
156
+
157
+ /**
158
+ * Create a document plugin instance.
159
+ */
160
+ export declare function createDocumentPlugin(options?: DocumentPluginOptions): DocumentPlugin;
161
+
162
+ /**
163
+ * Create an interaction plugin instance.
164
+ */
165
+ export declare function createInteractionPlugin(options?: InteractionPluginOptions): InteractionPlugin;
166
+
167
+ /**
168
+ * Helper function to create a snapshot command.
169
+ *
170
+ * Usage:
171
+ * ```typescript
172
+ * // Before starting the action
173
+ * const before = layer.captureSnapshot()
174
+ *
175
+ * // ... perform some drawing ...
176
+ *
177
+ * // After the action is complete
178
+ * const after = layer.captureSnapshot()
179
+ * const command = createSnapshotCommand(layer, before, after)
180
+ * historyManager.addCommand(command)
181
+ * ```
182
+ */
183
+ export declare function createSnapshotCommand(target: ISnapshotable, beforeData: ImageData | null, afterData: ImageData | null, options?: SnapshotCommandOptions): SnapshotCommand | null;
184
+
185
+ /**
186
+ * Document Plugin
187
+ *
188
+ * Manages document bounds, margins, clipping, and pan clamping.
189
+ */
190
+ export declare class DocumentPlugin implements Plugin_2 {
191
+ readonly name = "document";
192
+ private _view;
193
+ private _options;
194
+ private _enabled;
195
+ private _x;
196
+ private _y;
197
+ private _width;
198
+ private _height;
199
+ private _marginL;
200
+ private _marginR;
201
+ private _marginT;
202
+ private _marginB;
203
+ private _panClampMode;
204
+ constructor(options?: DocumentPluginOptions);
205
+ install(view: ViewManager): void;
206
+ destroy(): void;
207
+ isEnabled(): boolean;
208
+ getRect(): {
209
+ x: number;
210
+ y: number;
211
+ width: number;
212
+ height: number;
213
+ };
214
+ setRect(x: number, y: number, width: number, height: number): void;
215
+ clearRect(): void;
216
+ setMargins(margins: {
217
+ left?: number;
218
+ right?: number;
219
+ top?: number;
220
+ bottom?: number;
221
+ }): void;
222
+ getMargins(): {
223
+ left: number;
224
+ right: number;
225
+ top: number;
226
+ bottom: number;
227
+ };
228
+ setPanClampMode(mode: PanClampMode): void;
229
+ getPanClampMode(): PanClampMode;
230
+ /**
231
+ * Crop document and all world layers to the specified size.
232
+ */
233
+ cropTo(config: ILayerResizeConfig): void;
234
+ /**
235
+ * Resize document and all world layers to the specified size.
236
+ */
237
+ resizeTo(config: ILayerResizeConfig): void;
238
+ /**
239
+ * Zoom to fit the document in the viewport.
240
+ */
241
+ zoomToFit(mode?: 'contain' | 'cover' | 'fitWidth' | 'fitHeight'): void;
242
+ /**
243
+ * Check if a world point is inside the document.
244
+ */
245
+ isPointInDocument(wx: number, wy: number): boolean;
246
+ private _onUpdate;
247
+ private _onBeforeRender;
248
+ private _onAfterRender;
249
+ private _clampPan;
250
+ private _doResize;
251
+ }
252
+
253
+ export declare interface DocumentPluginOptions {
254
+ /**
255
+ * Initial document rectangle (world coordinates).
256
+ */
257
+ rect?: {
258
+ x: number;
259
+ y: number;
260
+ width: number;
261
+ height: number;
262
+ };
263
+ /**
264
+ * Initial margins (CSS pixels).
265
+ */
266
+ margins?: {
267
+ left?: number;
268
+ right?: number;
269
+ top?: number;
270
+ bottom?: number;
271
+ };
272
+ /**
273
+ * Draw 1px border around document. Default false.
274
+ */
275
+ drawBorder?: boolean;
276
+ /**
277
+ * The min visible edge of the document in px when clamping pan. Default 30.
278
+ */
279
+ minVisiblePx?: number;
280
+ /**
281
+ * Pan clamp mode. Default 'minVisible'.
282
+ */
283
+ panClampMode?: PanClampMode;
284
+ }
285
+
286
+ /**
287
+ * 历史管理器:管理撤销/重做操作的命令栈
288
+ */
289
+ export declare class HistoryManager {
290
+ private _maxHistorySize;
291
+ private _undoStack;
292
+ private _redoStack;
293
+ /**
294
+ * 执行命令并记录到历史
295
+ * 用于需要执行+记录的场景(如从外部触发的命令)
296
+ */
297
+ executeCommand(command: ICommand): void;
298
+ /**
299
+ * 将已执行的命令添加到历史记录
300
+ * 用于实时绘制场景(命令已经通过其他方式执行完成)
301
+ */
302
+ addCommand(command: ICommand): void;
303
+ /**
304
+ * 撤销操作
305
+ */
306
+ undo(): ICommand | null;
307
+ /**
308
+ * 重做操作
309
+ */
310
+ redo(): ICommand | null;
311
+ /**
312
+ * 检查是否可以撤销
313
+ */
314
+ canUndo(): boolean;
315
+ /**
316
+ * 检查是否可以重做
317
+ */
318
+ canRedo(): boolean;
319
+ /**
320
+ * 清空所有历史
321
+ */
322
+ clear(): void;
323
+ /**
324
+ * 设置最大历史大小
325
+ */
326
+ setMaxHistorySize(size: number): void;
327
+ constructor(options?: {
328
+ /**
329
+ * Maximum number of commands to keep in history.
330
+ *
331
+ * @default 50
332
+ */
333
+ maxHistorySize?: number;
334
+ /**
335
+ * You can optionally provide initial undo and redo stacks.
336
+ * This is useful in some situations like loading from a saved state,
337
+ * or already having a Vue reactive array to use.
338
+ *
339
+ * @default []
340
+ */
341
+ undoStack?: ICommand[];
342
+ /**
343
+ * You can optionally provide initial undo and redo stacks.
344
+ * This is useful in some situations like loading from a saved state,
345
+ * or already having a Vue reactive array to use.
346
+ *
347
+ * @default []
348
+ */
349
+ redoStack?: ICommand[];
350
+ });
351
+ }
352
+
353
+ export declare interface ICommand {
354
+ readonly type: CommandType;
355
+ execute(): void;
356
+ undo(): void;
357
+ canMerge?(other: ICommand): boolean;
358
+ merge?(other: ICommand): ICommand;
359
+ }
360
+
361
+ export declare interface ICreateBitmapLayerOptions {
362
+ src: string | File | Blob;
363
+ width?: number;
364
+ height?: number;
365
+ name?: string;
366
+ x?: number;
367
+ y?: number;
368
+ scale?: number;
369
+ rotation?: number;
370
+ anchor?: AnchorType;
371
+ space?: SpaceType;
372
+ crossOrigin?: '' | 'anonymous' | 'use-credentials';
373
+ }
374
+
375
+ export declare interface ICreateCanvasLayerOption {
376
+ name?: string;
377
+ width: number;
378
+ height: number;
379
+ /**
380
+ * The space of the layer, either 'world' or 'screen'.
381
+ *
382
+ * @default 'world'
383
+ */
384
+ space?: SpaceType;
385
+ x?: number;
386
+ y?: number;
387
+ scale?: number;
388
+ rotation?: number;
389
+ anchor?: AnchorType;
390
+ redraw?: (context: CanvasRenderingContext2D, canvas: HTMLCanvasElement) => void;
391
+ }
392
+
393
+ export declare interface ILayerResizeConfig {
394
+ width: number;
395
+ height: number;
396
+ }
397
+
398
+ /**
399
+ * Interaction Plugin
400
+ *
401
+ * Handles pan (drag), zoom (wheel), and inertia.
402
+ * Can be enabled/disabled at runtime.
403
+ */
404
+ export declare class InteractionPlugin implements Plugin_2 {
405
+ readonly name = "interaction";
406
+ private _view;
407
+ private _options;
408
+ private _panEnabled;
409
+ private _zoomEnabled;
410
+ private _dragging;
411
+ private _vx;
412
+ private _vy;
413
+ private _lastMoveTs;
414
+ private _activePointerId;
415
+ private _onDownBound;
416
+ private _onMoveBound;
417
+ private _onUpBound;
418
+ private _onWheelBound;
419
+ constructor(options?: InteractionPluginOptions);
420
+ install(view: ViewManager): void;
421
+ destroy(): void;
422
+ isPanEnabled(): boolean;
423
+ isZoomEnabled(): boolean;
424
+ setPanEnabled(enabled: boolean): void;
425
+ setZoomEnabled(enabled: boolean): void;
426
+ setWheelSensitivity(s: number): void;
427
+ isDragging(): boolean;
428
+ private _onUpdate;
429
+ private _onPointerDown;
430
+ private _onPointerMove;
431
+ private _onPointerUp;
432
+ private _getLineHeightPx;
433
+ private _normalizeWheelDelta;
434
+ private _onWheel;
435
+ }
436
+
437
+ export declare interface InteractionPluginOptions {
438
+ /**
439
+ * Enable pan (drag to move). Default true.
440
+ */
441
+ panEnabled?: boolean;
442
+ /**
443
+ * Enable zoom (wheel to scale). Default true.
444
+ */
445
+ zoomEnabled?: boolean;
446
+ /**
447
+ * Friction for inertia (per frame). Default 0.92.
448
+ */
449
+ friction?: number;
450
+ /**
451
+ * Stop speed threshold (px/ms). Default 20/1000.
452
+ */
453
+ stopSpeed?: number;
454
+ /**
455
+ * EMA alpha for velocity smoothing. Default 0.25.
456
+ */
457
+ emaAlpha?: number;
458
+ /**
459
+ * Idle time (ms) before clearing inertia on pointer up. Default 120.
460
+ */
461
+ idleNoInertiaMs?: number;
462
+ /**
463
+ * Wheel sensitivity (pixel -> log step multiplier). Default 0.0015.
464
+ */
465
+ wheelSensitivity?: number;
466
+ }
467
+
468
+ export declare interface IRect {
469
+ x: number;
470
+ y: number;
471
+ width: number;
472
+ height: number;
473
+ }
474
+
475
+ /**
476
+ * Interface for objects that can capture and restore snapshots.
477
+ * CanvasLayer implements this interface.
478
+ */
479
+ export declare interface ISnapshotable {
480
+ captureSnapshot(region?: ISnapshotRegion): ImageData | null;
481
+ restoreSnapshot(data: ImageData, position?: {
482
+ x: number;
483
+ y: number;
484
+ }): void;
485
+ }
486
+
487
+ export declare interface ISnapshotRegion {
488
+ x: number;
489
+ y: number;
490
+ width: number;
491
+ height: number;
492
+ }
493
+
494
+ export declare abstract class LayerBase {
495
+ readonly id: string;
496
+ type: string;
497
+ name: string;
498
+ space: SpaceType;
499
+ visible: boolean;
500
+ opacity: number;
501
+ blend: BlendMode;
502
+ abstract render(context: CanvasRenderingContext2D, view?: ViewManager): void;
503
+ abstract destroy(): void;
504
+ abstract hitTest(x: number, y: number, view?: ViewManager): boolean;
505
+ protected constructor(name: string, type: string, space?: SpaceType);
506
+ }
507
+
508
+ export declare class LayerManagerBase {
509
+ protected _worldLayers: LayerBase[];
510
+ protected _screenLayers: LayerBase[];
511
+ /**
512
+ * Render all layers in target view.
513
+ */
514
+ protected _renderAllLayersIn(view: ViewManager, context: CanvasRenderingContext2D): void;
515
+ addLayer(layer: LayerBase, insertAt?: number): string;
516
+ createImageLayer(option: ICreateBitmapLayerOptions): Promise<BitmapLayer>;
517
+ createCanvasLayer(option: ICreateCanvasLayerOption): CanvasLayer;
518
+ removeLayer(id: string): void;
519
+ /**
520
+ * Move a layer from one index to another.
521
+ * Both indices are relative to the layer's space (world or screen).
522
+ */
523
+ moveLayer(id: string, toIndex: number): void;
524
+ getLayer(id: string): LayerBase | undefined;
525
+ getAllLayers(space?: SpaceType): LayerBase[];
526
+ /**
527
+ * Hit test all layers (top-first).
528
+ *
529
+ * @param x
530
+ * @param y
531
+ * @param space
532
+ */
533
+ hitTest(x: number, y: number, space?: 'world' | 'screen'): LayerBase | undefined;
534
+ destroy(): void;
535
+ }
536
+
537
+ export declare type PanClampMode = 'margin' | 'minVisible';
538
+
539
+ /**
540
+ * Plugin interface for ViewManager.
541
+ * Plugins can extend the core functionality with additional features.
542
+ */
543
+ declare interface Plugin_2 {
544
+ /**
545
+ * Unique name of the plugin.
546
+ */
547
+ readonly name: string;
548
+ /**
549
+ * Called when the plugin is installed on a ViewManager instance.
550
+ * @param view The ViewManager instance
551
+ */
552
+ install(view: ViewManager): void;
553
+ /**
554
+ * Called when the plugin is uninstalled or the ViewManager is destroyed.
555
+ */
556
+ destroy(): void;
557
+ }
558
+ export { Plugin_2 as Plugin }
559
+
560
+ /**
561
+ * Plugin constructor type for creating plugin instances.
562
+ */
563
+ export declare type PluginConstructor<T extends Plugin_2 = Plugin_2, O = unknown> = new (options?: O) => T;
564
+
565
+ /**
566
+ * Plugin factory function type.
567
+ */
568
+ export declare type PluginFactory<T extends Plugin_2 = Plugin_2, O = unknown> = (options?: O) => T;
569
+
570
+ export declare type RenderCallback = (ctx: CanvasRenderingContext2D) => void;
571
+
572
+ export declare type RenderFn = (view: ViewManager) => void;
573
+
574
+ /**
575
+ * A generic command that stores before/after snapshots for undo/redo.
576
+ * This command is decoupled from any specific layer implementation.
577
+ */
578
+ export declare class SnapshotCommand implements ICommand {
579
+ readonly type = "snapshot";
580
+ private readonly _target;
581
+ private readonly _beforeData;
582
+ private readonly _afterData;
583
+ private readonly _region?;
584
+ private _isExecuted;
585
+ /**
586
+ * Create a snapshot command.
587
+ *
588
+ * @param target - The object to restore snapshots to (must implement ISnapshotable)
589
+ * @param beforeData - The snapshot before the change
590
+ * @param afterData - The snapshot after the change
591
+ * @param options - Optional configuration
592
+ */
593
+ constructor(target: ISnapshotable, beforeData: ImageData, afterData: ImageData, options?: SnapshotCommandOptions);
594
+ execute(): void;
595
+ undo(): void;
596
+ canMerge(): boolean;
597
+ merge(): ICommand;
598
+ }
599
+
600
+ export declare interface SnapshotCommandOptions {
601
+ /**
602
+ * The region of the snapshot. If not provided, uses full canvas.
603
+ */
604
+ region?: ISnapshotRegion;
605
+ }
606
+
607
+ export declare type SpaceType = 'world' | 'screen';
608
+
609
+ /**
610
+ * Top Screen Layer Manager is used to store top screen overlays.
611
+ * If you have something like UI elements, just put it here.
612
+ */
613
+ export declare class TopScreenLayerManager extends LayerManagerBase {
614
+ /**
615
+ * Render all layers in target view.
616
+ */
617
+ renderAllLayersIn(view: ViewManager): void;
618
+ }
619
+
620
+ export declare type UpdateCallback = (dt: number) => void;
621
+
622
+ export declare class ViewManager {
623
+ readonly canvas: HTMLCanvasElement;
624
+ readonly context: CanvasRenderingContext2D;
625
+ readonly contentCanvas: HTMLCanvasElement;
626
+ readonly contentContext: CanvasRenderingContext2D;
627
+ readonly topScreenCanvas: HTMLCanvasElement;
628
+ readonly topScreenContext: CanvasRenderingContext2D;
629
+ private readonly _render;
630
+ private readonly _options;
631
+ private readonly _resizeObserver?;
632
+ private _layerManagers;
633
+ private _plugins;
634
+ private _isResetting;
635
+ private _isResizing;
636
+ private _resizeReleaseTimer;
637
+ private _needsRender;
638
+ private _raf;
639
+ private _lastFrameTs;
640
+ private _tx;
641
+ private _ty;
642
+ private _anchorX;
643
+ private _anchorY;
644
+ private _currentLogZ;
645
+ private _targetLogZ;
646
+ private LOG_MIN;
647
+ private LOG_MAX;
648
+ private _updateCallbacks;
649
+ private _beforeRenderCallbacks;
650
+ private _afterRenderCallbacks;
651
+ get zoom(): number;
652
+ get minZoom(): number;
653
+ get maxZoom(): number;
654
+ private _dpr;
655
+ get dpr(): number;
656
+ /**
657
+ * Install a plugin.
658
+ */
659
+ use<T extends Plugin_2>(plugin: T): T;
660
+ /**
661
+ * Uninstall a plugin by name.
662
+ */
663
+ unuse(name: string): void;
664
+ /**
665
+ * Get an installed plugin by name.
666
+ */
667
+ getPlugin<T extends Plugin_2>(name: string): T | undefined;
668
+ /**
669
+ * Register a callback to be called every frame with delta time.
670
+ */
671
+ onUpdate(callback: UpdateCallback): void;
672
+ /**
673
+ * Unregister an update callback.
674
+ */
675
+ offUpdate(callback: UpdateCallback): void;
676
+ /**
677
+ * Register a callback to be called before rendering (with world transform applied).
678
+ */
679
+ onBeforeRender(callback: RenderCallback): void;
680
+ /**
681
+ * Unregister a before-render callback.
682
+ */
683
+ offBeforeRender(callback: RenderCallback): void;
684
+ /**
685
+ * Register a callback to be called after rendering.
686
+ */
687
+ onAfterRender(callback: RenderCallback): void;
688
+ /**
689
+ * Unregister an after-render callback.
690
+ */
691
+ offAfterRender(callback: RenderCallback): void;
692
+ /**
693
+ * Request a render on the next frame.
694
+ * Call this when content changes and needs to be redrawn.
695
+ */
696
+ requestRender(): void;
697
+ /**
698
+ * Clamp target zoom (log space) to range.
699
+ */
700
+ private _clampLog;
701
+ /**
702
+ * Set target zoom at screen anchor point, with smooth transition.
703
+ */
704
+ private _setTargetLogZoomAtScreen;
705
+ /**
706
+ * Zoom to absolute zoom level at screen point, with smooth transition.
707
+ */
708
+ zoomToAtScreen(anchorX: number, anchorY: number, zoom: number): void;
709
+ /**
710
+ * Zoom to absolute zoom level at screen point, instantly (no animation).
711
+ */
712
+ zoomToAtScreenRaw(anchorX: number, anchorY: number, zoom: number): void;
713
+ /**
714
+ * Zoom to absolute zoom level at world point, with smooth transition.
715
+ */
716
+ zoomToAtWorld(wx: number, wy: number, zoom: number): void;
717
+ /**
718
+ * Zoom by multiplicative factor at screen point, with smooth transition.
719
+ */
720
+ zoomByFactorAtScreen(anchorX: number, anchorY: number, factor: number): void;
721
+ /**
722
+ * Zoom by log step at screen point. Used by interaction plugin.
723
+ */
724
+ zoomByLogAtScreen(anchorX: number, anchorY: number, stepLog: number): void;
725
+ /**
726
+ * Zoom by multiplicative factor at world point, with smooth transition.
727
+ */
728
+ zoomByFactorAtWorld(wx: number, wy: number, factor: number): void;
729
+ zoomInAtCenter(): void;
730
+ zoomOutAtCenter(): void;
731
+ /**
732
+ * Pan by delta (CSS px).
733
+ */
734
+ panBy(dx: number, dy: number): void;
735
+ /**
736
+ * Set pan position (CSS px).
737
+ */
738
+ setPan(tx: number, ty: number): void;
739
+ /**
740
+ * Set full transform: zoom and pan.
741
+ */
742
+ setTransform(zoom: number, tx: number, ty: number): void;
743
+ private _ensureOffscreenSizeLike;
744
+ private _loop;
745
+ applyWorldTransform(ctx: CanvasRenderingContext2D): void;
746
+ applyScreenTransform(ctx: CanvasRenderingContext2D): void;
747
+ getPixelColorAtScreen(sx: number, sy: number): {
748
+ r: number;
749
+ g: number;
750
+ b: number;
751
+ a: number;
752
+ rgba: string;
753
+ hex: string;
754
+ };
755
+ getPixelColorAtWorld(wx: number, wy: number): {
756
+ r: number;
757
+ g: number;
758
+ b: number;
759
+ a: number;
760
+ rgba: string;
761
+ hex: string;
762
+ };
763
+ registerLayerManager(manager: LayerManagerBase): void;
764
+ unregisterLayerManager(manager: LayerManagerBase): void;
765
+ getLayerManagers(): LayerManagerBase[];
766
+ /**
767
+ * Smoothly reset to zoom=1, pan=(0,0).
768
+ */
769
+ resetSmooth(): void;
770
+ /**
771
+ * Instantly reset (no animation).
772
+ */
773
+ resetInstant(): void;
774
+ /**
775
+ * Convert screen (canvas client) -> world.
776
+ */
777
+ toWorld(x: number, y: number): {
778
+ wx: number;
779
+ wy: number;
780
+ };
781
+ /**
782
+ * Convert world -> screen (canvas client).
783
+ */
784
+ toScreen(wx: number, wy: number): {
785
+ x: number;
786
+ y: number;
787
+ };
788
+ /**
789
+ * Get current transform.
790
+ */
791
+ getTransform(): {
792
+ zoom: number;
793
+ tx: number;
794
+ ty: number;
795
+ };
796
+ /**
797
+ * Get viewport bounds in world coordinates.
798
+ */
799
+ getViewportBounds(): {
800
+ left: number;
801
+ top: number;
802
+ right: number;
803
+ bottom: number;
804
+ width: number;
805
+ height: number;
806
+ };
807
+ /**
808
+ * Set zoom range.
809
+ */
810
+ setZoomRange(minZoom: number, maxZoom: number): void;
811
+ /**
812
+ * Resize canvas to match parent size and DPR.
813
+ */
814
+ resizeToParent(): void;
815
+ /**
816
+ * Destroy and cleanup.
817
+ */
818
+ destroy(): void;
819
+ constructor(canvas: HTMLCanvasElement, render: RenderFn, options?: ViewManagerOption);
820
+ }
821
+
822
+ export declare interface ViewManagerOption {
823
+ minZoom?: number;
824
+ maxZoom?: number;
825
+ approachKZoom?: number;
826
+ approachKPan?: number;
827
+ autoResize?: boolean;
828
+ background?: string | null;
829
+ }
830
+
831
+ export { }