@tsdraw/core 0.4.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.
- package/dist/index.cjs +1709 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +464 -0
- package/dist/index.d.ts +464 -0
- package/dist/index.js +1653 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
type ShapeId = string;
|
|
2
|
+
interface Vec3 {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
z?: number;
|
|
6
|
+
}
|
|
7
|
+
type SegmentType = 'free' | 'straight';
|
|
8
|
+
interface DrawSegment {
|
|
9
|
+
type: SegmentType;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
type SizeStyle = 's' | 'm' | 'l' | 'xl';
|
|
13
|
+
type DashStyle = 'draw' | 'solid' | 'dashed' | 'dotted';
|
|
14
|
+
type ColorStyle = string;
|
|
15
|
+
interface DrawShape {
|
|
16
|
+
id: ShapeId;
|
|
17
|
+
type: 'draw';
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
props: {
|
|
21
|
+
color: ColorStyle;
|
|
22
|
+
dash: DashStyle;
|
|
23
|
+
size: SizeStyle;
|
|
24
|
+
scale: number;
|
|
25
|
+
isPen: boolean;
|
|
26
|
+
isComplete: boolean;
|
|
27
|
+
segments: DrawSegment[];
|
|
28
|
+
isClosed?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
type Shape = DrawShape;
|
|
32
|
+
interface PageState {
|
|
33
|
+
id: string;
|
|
34
|
+
shapes: Record<ShapeId, Shape>;
|
|
35
|
+
erasingShapeIds: ShapeId[];
|
|
36
|
+
}
|
|
37
|
+
declare const STROKE_WIDTHS: Record<SizeStyle, number>;
|
|
38
|
+
declare const DRAG_DISTANCE_SQUARED = 36;
|
|
39
|
+
declare const DEFAULT_COLORS: Record<string, string>;
|
|
40
|
+
declare const MAX_POINTS_PER_SHAPE = 200;
|
|
41
|
+
|
|
42
|
+
declare class DocumentStore {
|
|
43
|
+
private state;
|
|
44
|
+
private order;
|
|
45
|
+
getPage(): PageState;
|
|
46
|
+
getShape(id: ShapeId): Shape | undefined;
|
|
47
|
+
getCurrentPageShapesSorted(): Shape[];
|
|
48
|
+
getCurrentPageRenderingShapesSorted(): Shape[];
|
|
49
|
+
getErasingShapeIds(): ShapeId[];
|
|
50
|
+
setErasingShapes(ids: ShapeId[]): void;
|
|
51
|
+
createShape(shape: Shape): void;
|
|
52
|
+
updateShape(id: ShapeId, partial: Partial<Shape>): void;
|
|
53
|
+
deleteShapes(ids: ShapeId[]): void;
|
|
54
|
+
getCurrentPageShapes(): Shape[];
|
|
55
|
+
getShapeIdsInBounds(box: {
|
|
56
|
+
minX: number;
|
|
57
|
+
minY: number;
|
|
58
|
+
maxX: number;
|
|
59
|
+
maxY: number;
|
|
60
|
+
}): Set<ShapeId>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface PointerInput {
|
|
64
|
+
currentPagePoint: Vec3;
|
|
65
|
+
originPagePoint: Vec3;
|
|
66
|
+
previousPagePoint: Vec3;
|
|
67
|
+
isPen: boolean;
|
|
68
|
+
shiftKey: boolean;
|
|
69
|
+
ctrlKey: boolean;
|
|
70
|
+
isDragging: boolean;
|
|
71
|
+
}
|
|
72
|
+
declare class InputManager {
|
|
73
|
+
private _current;
|
|
74
|
+
private _origin;
|
|
75
|
+
private _previous;
|
|
76
|
+
private _isPen;
|
|
77
|
+
private _shiftKey;
|
|
78
|
+
private _ctrlKey;
|
|
79
|
+
private _metaKey;
|
|
80
|
+
private _isDragging;
|
|
81
|
+
getCurrentPagePoint(): Vec3;
|
|
82
|
+
getOriginPagePoint(): Vec3;
|
|
83
|
+
getPreviousPagePoint(): Vec3;
|
|
84
|
+
getIsPen(): boolean;
|
|
85
|
+
getShiftKey(): boolean;
|
|
86
|
+
getCtrlKey(): boolean;
|
|
87
|
+
getAccelKey(): boolean;
|
|
88
|
+
getIsDragging(): boolean;
|
|
89
|
+
pointerDown(pageX: number, pageY: number, pressure?: number, isPen?: boolean): void;
|
|
90
|
+
pointerMove(pageX: number, pageY: number, pressure?: number, isPen?: boolean): void;
|
|
91
|
+
pointerUp(): void;
|
|
92
|
+
setModifiers(shift: boolean, ctrl: boolean, meta?: boolean): void;
|
|
93
|
+
getInputs(): PointerInput;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface IEditor {
|
|
97
|
+
getZoomLevel(): number;
|
|
98
|
+
options: {
|
|
99
|
+
dragDistanceSquared: number;
|
|
100
|
+
};
|
|
101
|
+
store: DocumentStore;
|
|
102
|
+
input: InputManager;
|
|
103
|
+
getShape(id: ShapeId): Shape | undefined;
|
|
104
|
+
createShape(shape: Shape): void;
|
|
105
|
+
updateShapes(partials: Array<{
|
|
106
|
+
id: ShapeId;
|
|
107
|
+
type: string;
|
|
108
|
+
props?: Partial<DrawShape['props']>;
|
|
109
|
+
}>): void;
|
|
110
|
+
getPointInShapeSpace(shape: DrawShape, pagePoint: Vec3): Vec3;
|
|
111
|
+
createShapeId(): ShapeId;
|
|
112
|
+
getErasingShapeIds(): ShapeId[];
|
|
113
|
+
setErasingShapes(ids: ShapeId[]): void;
|
|
114
|
+
getCurrentPageRenderingShapesSorted(): Shape[];
|
|
115
|
+
getCurrentDrawStyle(): {
|
|
116
|
+
color: ColorStyle;
|
|
117
|
+
dash: DashStyle;
|
|
118
|
+
size: SizeStyle;
|
|
119
|
+
};
|
|
120
|
+
setCurrentDrawStyle(partial: Partial<{
|
|
121
|
+
color: ColorStyle;
|
|
122
|
+
dash: DashStyle;
|
|
123
|
+
size: SizeStyle;
|
|
124
|
+
}>): void;
|
|
125
|
+
panBy(dx: number, dy: number): void;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface ToolPointerDownInfo {
|
|
129
|
+
point: Vec3;
|
|
130
|
+
}
|
|
131
|
+
interface ToolPointerMoveInfo {
|
|
132
|
+
screenDeltaX?: number;
|
|
133
|
+
screenDeltaY?: number;
|
|
134
|
+
}
|
|
135
|
+
interface ToolKeyInfo {
|
|
136
|
+
key: string;
|
|
137
|
+
}
|
|
138
|
+
type ToolStateTransitionInfo = ToolPointerDownInfo | ToolPointerMoveInfo | ToolKeyInfo;
|
|
139
|
+
interface ToolStateContext {
|
|
140
|
+
transition(stateId: string, info?: ToolStateTransitionInfo): void;
|
|
141
|
+
}
|
|
142
|
+
interface StateNodeConstructor {
|
|
143
|
+
id: string;
|
|
144
|
+
new (ctx: ToolStateContext, editor: IEditor): StateNode;
|
|
145
|
+
}
|
|
146
|
+
declare abstract class StateNode {
|
|
147
|
+
protected ctx: ToolStateContext;
|
|
148
|
+
protected editor: IEditor;
|
|
149
|
+
static id: string;
|
|
150
|
+
constructor(ctx: ToolStateContext, editor: IEditor);
|
|
151
|
+
onEnter(_info?: ToolStateTransitionInfo): void;
|
|
152
|
+
onExit(_info?: ToolStateTransitionInfo, _to?: string): void;
|
|
153
|
+
onPointerDown(_info?: ToolPointerDownInfo): void;
|
|
154
|
+
onPointerMove(_info?: ToolPointerMoveInfo): void;
|
|
155
|
+
onPointerUp(): void;
|
|
156
|
+
onKeyDown(_info?: ToolKeyInfo): void;
|
|
157
|
+
onKeyUp(_info?: ToolKeyInfo): void;
|
|
158
|
+
onCancel(): void;
|
|
159
|
+
onInterrupt(): void;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface Viewport {
|
|
163
|
+
x: number;
|
|
164
|
+
y: number;
|
|
165
|
+
zoom: number;
|
|
166
|
+
}
|
|
167
|
+
declare function createViewport(): Viewport;
|
|
168
|
+
declare function screenToPage(viewport: Viewport, screenX: number, screenY: number): {
|
|
169
|
+
x: number;
|
|
170
|
+
y: number;
|
|
171
|
+
};
|
|
172
|
+
declare function pageToScreen(viewport: Viewport, pageX: number, pageY: number): {
|
|
173
|
+
x: number;
|
|
174
|
+
y: number;
|
|
175
|
+
};
|
|
176
|
+
declare function setViewport(viewport: Viewport, updater: {
|
|
177
|
+
x?: number;
|
|
178
|
+
y?: number;
|
|
179
|
+
zoom?: number;
|
|
180
|
+
}): Viewport;
|
|
181
|
+
declare function panViewport(viewport: Viewport, dx: number, dy: number): Viewport;
|
|
182
|
+
declare function zoomViewport(viewport: Viewport, factor: number, centerX?: number, centerY?: number): Viewport;
|
|
183
|
+
|
|
184
|
+
type TsdrawRenderTheme = 'light' | 'dark';
|
|
185
|
+
declare function resolveThemeColor(colorStyle: string, theme: TsdrawRenderTheme): string;
|
|
186
|
+
|
|
187
|
+
interface ICanvasRenderer {
|
|
188
|
+
render(ctx: CanvasRenderingContext2D, viewport: Viewport, shapes: Shape[]): void;
|
|
189
|
+
}
|
|
190
|
+
declare class CanvasRenderer implements ICanvasRenderer {
|
|
191
|
+
private theme;
|
|
192
|
+
setTheme(theme: TsdrawRenderTheme): void;
|
|
193
|
+
render(ctx: CanvasRenderingContext2D, viewport: Viewport, shapes: Shape[]): void;
|
|
194
|
+
private paintStroke;
|
|
195
|
+
private paintDashedStroke;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
type DefaultToolId = 'pen' | 'eraser' | 'select' | 'hand';
|
|
199
|
+
type ToolId = DefaultToolId | (string & {});
|
|
200
|
+
interface ToolDefinition {
|
|
201
|
+
id: ToolId;
|
|
202
|
+
initialStateId: string;
|
|
203
|
+
stateConstructors: StateNodeConstructor[];
|
|
204
|
+
}
|
|
205
|
+
declare class ToolManager {
|
|
206
|
+
private currentToolId;
|
|
207
|
+
private currentState;
|
|
208
|
+
private states;
|
|
209
|
+
private toolInitialStateIds;
|
|
210
|
+
registerState(state: StateNode): void;
|
|
211
|
+
registerTool(id: ToolId, initialStateId: string): void;
|
|
212
|
+
hasTool(id: ToolId): boolean;
|
|
213
|
+
setCurrentTool(id: ToolId): void;
|
|
214
|
+
getCurrentToolId(): ToolId;
|
|
215
|
+
getCurrentState(): StateNode | null;
|
|
216
|
+
transition(stateId: string, info?: ToolStateTransitionInfo): void;
|
|
217
|
+
pointerDown(info: ToolPointerDownInfo): void;
|
|
218
|
+
pointerMove(info: ToolPointerMoveInfo): void;
|
|
219
|
+
pointerUp(): void;
|
|
220
|
+
keyDown(info: ToolKeyInfo): void;
|
|
221
|
+
keyUp(info: ToolKeyInfo): void;
|
|
222
|
+
cancel(): void;
|
|
223
|
+
interrupt(): void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface EditorOptions {
|
|
227
|
+
dragDistanceSquared?: number;
|
|
228
|
+
toolDefinitions?: ToolDefinition[];
|
|
229
|
+
initialToolId?: ToolId;
|
|
230
|
+
}
|
|
231
|
+
declare class Editor {
|
|
232
|
+
readonly store: DocumentStore;
|
|
233
|
+
readonly input: InputManager;
|
|
234
|
+
readonly tools: ToolManager;
|
|
235
|
+
readonly renderer: CanvasRenderer;
|
|
236
|
+
viewport: Viewport;
|
|
237
|
+
readonly options: {
|
|
238
|
+
dragDistanceSquared: number;
|
|
239
|
+
};
|
|
240
|
+
private drawStyle;
|
|
241
|
+
private readonly toolStateContext;
|
|
242
|
+
constructor(opts?: EditorOptions);
|
|
243
|
+
registerToolDefinition(toolDefinition: ToolDefinition): void;
|
|
244
|
+
private getDefaultToolDefinitions;
|
|
245
|
+
createShapeId(): ShapeId;
|
|
246
|
+
getZoomLevel(): number;
|
|
247
|
+
getShape(id: ShapeId): Shape | undefined;
|
|
248
|
+
createShape(shape: Shape): void;
|
|
249
|
+
updateShapes(partials: Array<{
|
|
250
|
+
id: ShapeId;
|
|
251
|
+
type: string;
|
|
252
|
+
props?: Partial<DrawShape['props']>;
|
|
253
|
+
}>): void;
|
|
254
|
+
getPointInShapeSpace(shape: DrawShape, pagePoint: Vec3): Vec3;
|
|
255
|
+
getCurrentPageShapes(): DrawShape[];
|
|
256
|
+
getCurrentPageShapesSorted(): DrawShape[];
|
|
257
|
+
getCurrentPageRenderingShapesSorted(): DrawShape[];
|
|
258
|
+
getErasingShapeIds(): string[];
|
|
259
|
+
setErasingShapes(ids: ShapeId[]): void;
|
|
260
|
+
setCurrentTool(id: ToolId): void;
|
|
261
|
+
getCurrentToolId(): ToolId;
|
|
262
|
+
getCurrentDrawStyle(): {
|
|
263
|
+
color: ColorStyle;
|
|
264
|
+
dash: DashStyle;
|
|
265
|
+
size: SizeStyle;
|
|
266
|
+
};
|
|
267
|
+
setCurrentDrawStyle(partial: Partial<{
|
|
268
|
+
color: ColorStyle;
|
|
269
|
+
dash: DashStyle;
|
|
270
|
+
size: SizeStyle;
|
|
271
|
+
}>): void;
|
|
272
|
+
panBy(dx: number, dy: number): void;
|
|
273
|
+
screenToPage(screenX: number, screenY: number): {
|
|
274
|
+
x: number;
|
|
275
|
+
y: number;
|
|
276
|
+
};
|
|
277
|
+
render(ctx: CanvasRenderingContext2D): void;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
declare class PenIdleState extends StateNode {
|
|
281
|
+
static id: string;
|
|
282
|
+
onPointerDown(info?: ToolPointerDownInfo): void;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
declare class PenDrawingState extends StateNode {
|
|
286
|
+
static id: string;
|
|
287
|
+
private _startInfo;
|
|
288
|
+
private _target;
|
|
289
|
+
private _isPenDevice;
|
|
290
|
+
private _hasPressure;
|
|
291
|
+
private _phase;
|
|
292
|
+
private _extending;
|
|
293
|
+
private _anchor;
|
|
294
|
+
private _pendingAnchor;
|
|
295
|
+
private _lastSample;
|
|
296
|
+
private _shouldMerge;
|
|
297
|
+
private _pathLen;
|
|
298
|
+
private _activePts;
|
|
299
|
+
onEnter(info?: ToolPointerDownInfo): void;
|
|
300
|
+
onPointerMove(): void;
|
|
301
|
+
onKeyDown(info?: ToolKeyInfo): void;
|
|
302
|
+
onKeyUp(info?: ToolKeyInfo): void;
|
|
303
|
+
onPointerUp(): void;
|
|
304
|
+
onCancel(): void;
|
|
305
|
+
onInterrupt(): void;
|
|
306
|
+
private canClosePath;
|
|
307
|
+
private detectClosure;
|
|
308
|
+
private measurePath;
|
|
309
|
+
private beginStroke;
|
|
310
|
+
private spawnShape;
|
|
311
|
+
private advanceStroke;
|
|
312
|
+
private endStroke;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare class EraserIdleState extends StateNode {
|
|
316
|
+
static id: string;
|
|
317
|
+
onPointerDown(info?: ToolPointerDownInfo): void;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
declare class EraserPointingState extends StateNode {
|
|
321
|
+
static id: string;
|
|
322
|
+
onEnter(_info?: ToolStateTransitionInfo): void;
|
|
323
|
+
onPointerMove(info?: ToolPointerMoveInfo): void;
|
|
324
|
+
onPointerUp(): void;
|
|
325
|
+
onExit(_info?: ToolStateTransitionInfo, to?: string): void;
|
|
326
|
+
onCancel(): void;
|
|
327
|
+
private finish;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
declare class EraserErasingState extends StateNode {
|
|
331
|
+
static id: string;
|
|
332
|
+
private _marked;
|
|
333
|
+
onEnter(_info?: ToolStateTransitionInfo): void;
|
|
334
|
+
onPointerMove(): void;
|
|
335
|
+
onPointerUp(): void;
|
|
336
|
+
onExit(): void;
|
|
337
|
+
onCancel(): void;
|
|
338
|
+
private sweep;
|
|
339
|
+
private finish;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
interface Bounds {
|
|
343
|
+
minX: number;
|
|
344
|
+
minY: number;
|
|
345
|
+
maxX: number;
|
|
346
|
+
maxY: number;
|
|
347
|
+
}
|
|
348
|
+
declare function boundsOf(points: {
|
|
349
|
+
x: number;
|
|
350
|
+
y: number;
|
|
351
|
+
}[]): Bounds;
|
|
352
|
+
declare function padBounds(b: Bounds, amount: number): Bounds;
|
|
353
|
+
declare function sqDistance(ax: number, ay: number, bx: number, by: number): number;
|
|
354
|
+
declare function distance(ax: number, ay: number, bx: number, by: number): number;
|
|
355
|
+
declare function closestOnSegment(ax: number, ay: number, bx: number, by: number, px: number, py: number): {
|
|
356
|
+
x: number;
|
|
357
|
+
y: number;
|
|
358
|
+
};
|
|
359
|
+
declare function segmentTouchesPolyline(polyline: {
|
|
360
|
+
x: number;
|
|
361
|
+
y: number;
|
|
362
|
+
}[], ax: number, ay: number, bx: number, by: number, margin: number): boolean;
|
|
363
|
+
declare function minDistanceToPolyline(px: number, py: number, polyline: {
|
|
364
|
+
x: number;
|
|
365
|
+
y: number;
|
|
366
|
+
}[]): number;
|
|
367
|
+
|
|
368
|
+
declare const ERASER_MARGIN = 4;
|
|
369
|
+
declare function shapePagePoints(shape: DrawShape): {
|
|
370
|
+
x: number;
|
|
371
|
+
y: number;
|
|
372
|
+
}[];
|
|
373
|
+
declare function pointHitsShape(shape: DrawShape, pageX: number, pageY: number, margin: number): boolean;
|
|
374
|
+
declare function segmentHitsShape(shape: DrawShape, ax: number, ay: number, bx: number, by: number, margin: number): boolean;
|
|
375
|
+
|
|
376
|
+
declare class SelectIdleState extends StateNode {
|
|
377
|
+
static id: string;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
interface SelectionBounds {
|
|
381
|
+
minX: number;
|
|
382
|
+
minY: number;
|
|
383
|
+
maxX: number;
|
|
384
|
+
maxY: number;
|
|
385
|
+
}
|
|
386
|
+
type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se';
|
|
387
|
+
interface TransformSnapshot {
|
|
388
|
+
x: number;
|
|
389
|
+
y: number;
|
|
390
|
+
segments: Array<{
|
|
391
|
+
type: DrawSegment['type'];
|
|
392
|
+
points: Vec3[];
|
|
393
|
+
}>;
|
|
394
|
+
}
|
|
395
|
+
declare function isSelectTool(tool: string): boolean;
|
|
396
|
+
declare function getShapeBounds(shape: DrawShape): SelectionBounds;
|
|
397
|
+
declare function normalizeSelectionBounds(a: {
|
|
398
|
+
x: number;
|
|
399
|
+
y: number;
|
|
400
|
+
}, b: {
|
|
401
|
+
x: number;
|
|
402
|
+
y: number;
|
|
403
|
+
}): SelectionBounds;
|
|
404
|
+
declare function boundsContainPoint(bounds: SelectionBounds, x: number, y: number): boolean;
|
|
405
|
+
declare function boundsIntersect(a: SelectionBounds, b: SelectionBounds): boolean;
|
|
406
|
+
declare function rotatePoint(point: {
|
|
407
|
+
x: number;
|
|
408
|
+
y: number;
|
|
409
|
+
}, center: {
|
|
410
|
+
x: number;
|
|
411
|
+
y: number;
|
|
412
|
+
}, radians: number): {
|
|
413
|
+
x: number;
|
|
414
|
+
y: number;
|
|
415
|
+
};
|
|
416
|
+
declare function buildTransformSnapshots(editor: Editor, ids: ShapeId[]): Map<ShapeId, TransformSnapshot>;
|
|
417
|
+
declare function buildStartPositions(editor: Editor, ids: ShapeId[]): Map<ShapeId, {
|
|
418
|
+
x: number;
|
|
419
|
+
y: number;
|
|
420
|
+
}>;
|
|
421
|
+
declare function getTopShapeAtPoint(editor: Editor, point: {
|
|
422
|
+
x: number;
|
|
423
|
+
y: number;
|
|
424
|
+
}): DrawShape | null;
|
|
425
|
+
declare function getSelectionBoundsPage(editor: Editor, ids: ShapeId[]): SelectionBounds | null;
|
|
426
|
+
declare function getShapesInBounds(editor: Editor, bounds: SelectionBounds): ShapeId[];
|
|
427
|
+
declare function applyMove(editor: Editor, startPositions: Map<ShapeId, {
|
|
428
|
+
x: number;
|
|
429
|
+
y: number;
|
|
430
|
+
}>, deltaX: number, deltaY: number): void;
|
|
431
|
+
declare function applyRotation(editor: Editor, startShapes: Map<ShapeId, TransformSnapshot>, center: {
|
|
432
|
+
x: number;
|
|
433
|
+
y: number;
|
|
434
|
+
}, delta: number): void;
|
|
435
|
+
declare function applyResize(editor: Editor, handle: ResizeHandle, startBounds: SelectionBounds, startShapes: Map<ShapeId, TransformSnapshot>, pointer: {
|
|
436
|
+
x: number;
|
|
437
|
+
y: number;
|
|
438
|
+
}, lockAspectRatio: boolean): void;
|
|
439
|
+
|
|
440
|
+
declare class HandIdleState extends StateNode {
|
|
441
|
+
static id: string;
|
|
442
|
+
onPointerDown(info?: ToolPointerDownInfo): void;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
declare class HandDraggingState extends StateNode {
|
|
446
|
+
static id: string;
|
|
447
|
+
onPointerMove(info?: ToolPointerMoveInfo): void;
|
|
448
|
+
onPointerUp(): void;
|
|
449
|
+
onCancel(): void;
|
|
450
|
+
onInterrupt(): void;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
declare function encodePoints(points: Vec3[]): string;
|
|
454
|
+
declare function decodePoints(path: string): Vec3[];
|
|
455
|
+
declare function decodeFirstPoint(path: string): Vec3 | null;
|
|
456
|
+
declare function decodeLastPoint(path: string): Vec3 | null;
|
|
457
|
+
declare function decodePathToPoints(segments: {
|
|
458
|
+
path: string;
|
|
459
|
+
}[], ox: number, oy: number): {
|
|
460
|
+
x: number;
|
|
461
|
+
y: number;
|
|
462
|
+
}[];
|
|
463
|
+
|
|
464
|
+
export { type Bounds, CanvasRenderer, type ColorStyle, DEFAULT_COLORS, DRAG_DISTANCE_SQUARED, type DashStyle, type DefaultToolId, DocumentStore, type DrawSegment, type DrawShape, ERASER_MARGIN, Editor, type EditorOptions, EraserErasingState, EraserIdleState, EraserPointingState, HandDraggingState, HandIdleState, type ICanvasRenderer, type IEditor, InputManager, MAX_POINTS_PER_SHAPE, type PageState, PenDrawingState, PenIdleState, type PointerInput, type ResizeHandle, STROKE_WIDTHS, type SegmentType, SelectIdleState, type SelectionBounds, type Shape, type ShapeId, type SizeStyle, StateNode, type StateNodeConstructor, type ToolDefinition, type ToolId, type ToolKeyInfo, ToolManager, type ToolPointerDownInfo, type ToolPointerMoveInfo, type ToolStateContext, type ToolStateTransitionInfo, type TransformSnapshot, type TsdrawRenderTheme, type Vec3, type Viewport, applyMove, applyResize, applyRotation, boundsContainPoint, boundsIntersect, boundsOf, buildStartPositions, buildTransformSnapshots, closestOnSegment, createViewport, decodeFirstPoint, decodeLastPoint, decodePathToPoints, decodePoints, distance, encodePoints, getSelectionBoundsPage, getShapeBounds, getShapesInBounds, getTopShapeAtPoint, isSelectTool, minDistanceToPolyline, normalizeSelectionBounds, padBounds, pageToScreen, panViewport, pointHitsShape, resolveThemeColor, rotatePoint, screenToPage, segmentHitsShape, segmentTouchesPolyline, setViewport, shapePagePoints, sqDistance, zoomViewport };
|