-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathsvg.draw.js.d.mts
64 lines (55 loc) · 1.56 KB
/
svg.draw.js.d.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Type definitions for @svgdotjs version 3.x
// Project: @svgdotjs/svg.draw.js
declare module '@svgdotjs/svg.js' {
interface DrawOptions {
snapToGrid?: number
drawCircles?: boolean
}
type DrawMethod = 'done' | 'cancel' | 'undo' | 'stop' | 'point' | 'update'
interface DrawEvent {
detail: {
event: Event
p: SVGPoint
m: DOMMatrix
}
}
interface SVGDotJsEventMap {
drawstart: DrawEvent
drawstop: Event
drawupdate: DrawEvent
drawpoint: DrawEvent
drawdone: Event
drawcancel: Event
}
export interface Element {
draw(event?: Event, options?: DrawOptions): Element
/** Begin drawing with the provided `DrawOptions` */
draw(options?: DrawOptions): Element
/**
* Call a built-in method
*
* @example
* // Finishes the poly-shape
* polygon.draw('done');
*
* // Cancels drawing of a shape, removes it
* polygon.draw('cancel');
*
* // The following are only useful in edge-cases
*
* // Draws a new point with the help of a (mouse) event
* polygon.draw('point', event)
*
* // Draws the point while moving the mouse (basically the animation)
* polygon.draw('update', evnt)
*
* // Stop drawing, cleans up
* polygon.draw('stop', event)
*/
draw(method: DrawMethod, event?: Event): Element
/** Update options for a drawing in progress */
draw(method: 'param', key: any, value: any): Element
/** Call a method by name. May be used when drawing custom shapes. */
draw(method: string): Element
}
}