@joint/core 4.0.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.
Files changed (139) hide show
  1. package/LICENSE +376 -0
  2. package/README.md +49 -0
  3. package/dist/geometry.js +6486 -0
  4. package/dist/geometry.min.js +8 -0
  5. package/dist/joint.d.ts +5536 -0
  6. package/dist/joint.js +39629 -0
  7. package/dist/joint.min.js +8 -0
  8. package/dist/joint.nowrap.js +39626 -0
  9. package/dist/joint.nowrap.min.js +8 -0
  10. package/dist/vectorizer.js +9135 -0
  11. package/dist/vectorizer.min.js +8 -0
  12. package/dist/version.mjs +3 -0
  13. package/index.js +3 -0
  14. package/joint.mjs +27 -0
  15. package/package.json +192 -0
  16. package/src/V/annotation.mjs +0 -0
  17. package/src/V/index.mjs +2642 -0
  18. package/src/anchors/index.mjs +123 -0
  19. package/src/config/index.mjs +12 -0
  20. package/src/connectionPoints/index.mjs +202 -0
  21. package/src/connectionStrategies/index.mjs +73 -0
  22. package/src/connectors/curve.mjs +553 -0
  23. package/src/connectors/index.mjs +6 -0
  24. package/src/connectors/jumpover.mjs +452 -0
  25. package/src/connectors/normal.mjs +12 -0
  26. package/src/connectors/rounded.mjs +17 -0
  27. package/src/connectors/smooth.mjs +44 -0
  28. package/src/connectors/straight.mjs +110 -0
  29. package/src/dia/Cell.mjs +945 -0
  30. package/src/dia/CellView.mjs +1316 -0
  31. package/src/dia/Element.mjs +519 -0
  32. package/src/dia/ElementView.mjs +859 -0
  33. package/src/dia/Graph.mjs +1112 -0
  34. package/src/dia/HighlighterView.mjs +319 -0
  35. package/src/dia/Link.mjs +565 -0
  36. package/src/dia/LinkView.mjs +2207 -0
  37. package/src/dia/Paper.mjs +3171 -0
  38. package/src/dia/PaperLayer.mjs +75 -0
  39. package/src/dia/ToolView.mjs +69 -0
  40. package/src/dia/ToolsView.mjs +128 -0
  41. package/src/dia/attributes/calc.mjs +128 -0
  42. package/src/dia/attributes/connection.mjs +75 -0
  43. package/src/dia/attributes/defs.mjs +76 -0
  44. package/src/dia/attributes/eval.mjs +64 -0
  45. package/src/dia/attributes/index.mjs +69 -0
  46. package/src/dia/attributes/legacy.mjs +148 -0
  47. package/src/dia/attributes/offset.mjs +53 -0
  48. package/src/dia/attributes/props.mjs +30 -0
  49. package/src/dia/attributes/shape.mjs +92 -0
  50. package/src/dia/attributes/text.mjs +180 -0
  51. package/src/dia/index.mjs +13 -0
  52. package/src/dia/layers/GridLayer.mjs +176 -0
  53. package/src/dia/ports.mjs +874 -0
  54. package/src/elementTools/Control.mjs +153 -0
  55. package/src/elementTools/HoverConnect.mjs +37 -0
  56. package/src/elementTools/index.mjs +5 -0
  57. package/src/env/index.mjs +43 -0
  58. package/src/g/bezier.mjs +175 -0
  59. package/src/g/curve.mjs +956 -0
  60. package/src/g/ellipse.mjs +245 -0
  61. package/src/g/extend.mjs +64 -0
  62. package/src/g/geometry.helpers.mjs +58 -0
  63. package/src/g/index.mjs +17 -0
  64. package/src/g/intersection.mjs +511 -0
  65. package/src/g/line.bearing.mjs +30 -0
  66. package/src/g/line.length.mjs +5 -0
  67. package/src/g/line.mjs +356 -0
  68. package/src/g/line.squaredLength.mjs +10 -0
  69. package/src/g/path.mjs +2260 -0
  70. package/src/g/point.mjs +375 -0
  71. package/src/g/points.mjs +247 -0
  72. package/src/g/polygon.mjs +51 -0
  73. package/src/g/polyline.mjs +523 -0
  74. package/src/g/rect.mjs +556 -0
  75. package/src/g/types.mjs +10 -0
  76. package/src/highlighters/addClass.mjs +27 -0
  77. package/src/highlighters/index.mjs +5 -0
  78. package/src/highlighters/list.mjs +111 -0
  79. package/src/highlighters/mask.mjs +220 -0
  80. package/src/highlighters/opacity.mjs +17 -0
  81. package/src/highlighters/stroke.mjs +100 -0
  82. package/src/layout/index.mjs +4 -0
  83. package/src/layout/ports/port.mjs +188 -0
  84. package/src/layout/ports/portLabel.mjs +224 -0
  85. package/src/linkAnchors/index.mjs +76 -0
  86. package/src/linkTools/Anchor.mjs +235 -0
  87. package/src/linkTools/Arrowhead.mjs +103 -0
  88. package/src/linkTools/Boundary.mjs +48 -0
  89. package/src/linkTools/Button.mjs +121 -0
  90. package/src/linkTools/Connect.mjs +85 -0
  91. package/src/linkTools/HoverConnect.mjs +161 -0
  92. package/src/linkTools/Segments.mjs +393 -0
  93. package/src/linkTools/Vertices.mjs +253 -0
  94. package/src/linkTools/helpers.mjs +33 -0
  95. package/src/linkTools/index.mjs +8 -0
  96. package/src/mvc/Collection.mjs +560 -0
  97. package/src/mvc/Data.mjs +46 -0
  98. package/src/mvc/Dom/Dom.mjs +587 -0
  99. package/src/mvc/Dom/Event.mjs +130 -0
  100. package/src/mvc/Dom/animations.mjs +122 -0
  101. package/src/mvc/Dom/events.mjs +69 -0
  102. package/src/mvc/Dom/index.mjs +13 -0
  103. package/src/mvc/Dom/methods.mjs +392 -0
  104. package/src/mvc/Dom/props.mjs +77 -0
  105. package/src/mvc/Dom/vars.mjs +5 -0
  106. package/src/mvc/Events.mjs +337 -0
  107. package/src/mvc/Listener.mjs +33 -0
  108. package/src/mvc/Model.mjs +239 -0
  109. package/src/mvc/View.mjs +323 -0
  110. package/src/mvc/ViewBase.mjs +182 -0
  111. package/src/mvc/index.mjs +9 -0
  112. package/src/mvc/mvcUtils.mjs +90 -0
  113. package/src/polyfills/array.js +4 -0
  114. package/src/polyfills/base64.js +68 -0
  115. package/src/polyfills/index.mjs +5 -0
  116. package/src/polyfills/number.js +3 -0
  117. package/src/polyfills/string.js +3 -0
  118. package/src/polyfills/typedArray.js +47 -0
  119. package/src/routers/index.mjs +6 -0
  120. package/src/routers/manhattan.mjs +856 -0
  121. package/src/routers/metro.mjs +91 -0
  122. package/src/routers/normal.mjs +6 -0
  123. package/src/routers/oneSide.mjs +60 -0
  124. package/src/routers/orthogonal.mjs +323 -0
  125. package/src/routers/rightAngle.mjs +1056 -0
  126. package/src/shapes/index.mjs +3 -0
  127. package/src/shapes/standard.mjs +755 -0
  128. package/src/util/cloneCells.mjs +67 -0
  129. package/src/util/getRectPoint.mjs +65 -0
  130. package/src/util/index.mjs +5 -0
  131. package/src/util/svgTagTemplate.mjs +110 -0
  132. package/src/util/util.mjs +1754 -0
  133. package/src/util/utilHelpers.mjs +2402 -0
  134. package/src/util/wrappers.mjs +56 -0
  135. package/types/geometry.d.ts +815 -0
  136. package/types/index.d.ts +53 -0
  137. package/types/joint.d.ts +4391 -0
  138. package/types/joint.head.d.ts +12 -0
  139. package/types/vectorizer.d.ts +327 -0
@@ -0,0 +1,815 @@
1
+ export namespace g {
2
+
3
+ export enum types {
4
+ Point = 1,
5
+ Line = 2,
6
+ Ellipse = 3,
7
+ Rect = 4,
8
+ Polyline = 5,
9
+ Polygon = 6,
10
+ Curve = 7,
11
+ Path = 8,
12
+ }
13
+
14
+ export type Shape = Path | Point | Line | Polyline | Polygon | Rect | Ellipse;
15
+ export interface PlainPoint {
16
+
17
+ x: number;
18
+ y: number;
19
+ }
20
+
21
+ export interface PlainRect {
22
+
23
+ x: number;
24
+ y: number;
25
+ width: number;
26
+ height: number;
27
+ }
28
+
29
+ export interface Scale {
30
+
31
+ sx: number;
32
+ sy: number;
33
+ }
34
+
35
+ export interface PrecisionOpt {
36
+
37
+ precision?: number;
38
+ }
39
+
40
+ export interface SubdivisionsOpt extends PrecisionOpt {
41
+
42
+ subdivisions?: Curve[];
43
+ }
44
+
45
+ export interface SegmentSubdivisionsOpt extends PrecisionOpt {
46
+
47
+ segmentSubdivisions?: Curve[][];
48
+ }
49
+
50
+ export interface PathT {
51
+
52
+ segmentIndex: number;
53
+ value: number;
54
+ }
55
+
56
+ export interface Segment {
57
+
58
+ type: SegmentType;
59
+
60
+ isSegment: boolean;
61
+ isSubpathStart: boolean;
62
+ isVisible: boolean;
63
+
64
+ nextSegment: Segment | null;
65
+ previousSegment: Segment | null;
66
+ subpathStartSegment: Segment | null;
67
+
68
+ start: Point | null | never; // getter, `never` for Moveto
69
+ end: Point | null; // getter or directly assigned
70
+
71
+ bbox(): Rect | null;
72
+
73
+ clone(): Segment;
74
+
75
+ closestPoint(p: Point, opt?: SubdivisionsOpt): Point;
76
+
77
+ closestPointLength(p: Point, opt?: SubdivisionsOpt): number;
78
+
79
+ closestPointNormalizedLength(p: Point, opt?: SubdivisionsOpt): number;
80
+
81
+ closestPointT(p: Point): number;
82
+
83
+ closestPointTangent(p: Point): Line | null;
84
+
85
+ divideAt(ratio: number, opt?: SubdivisionsOpt): [Segment, Segment];
86
+
87
+ divideAtLength(length: number, opt?: SubdivisionsOpt): [Segment, Segment];
88
+
89
+ divideAtT(t: number): [Segment, Segment];
90
+
91
+ equals(segment: Segment): boolean;
92
+
93
+ getSubdivisions(): Curve[];
94
+
95
+ isDifferentiable(): boolean;
96
+
97
+ length(): number;
98
+
99
+ lengthAtT(t: number, opt?: PrecisionOpt): number;
100
+
101
+ pointAt(ratio: number): Point;
102
+
103
+ pointAtLength(length: number): Point;
104
+
105
+ pointAtT(t: number): Point;
106
+
107
+ round(precision?: number): this;
108
+
109
+ scale(sx: number, sy: number, origin?: PlainPoint): this;
110
+
111
+ tangentAt(ratio: number): Line | null;
112
+
113
+ tangentAtLength(length: number): Line | null;
114
+
115
+ tangentAtT(t: number): Line | null;
116
+
117
+ translate(tx?: number, ty?: number): this;
118
+ translate(tx: PlainPoint): this;
119
+
120
+ serialize(): string;
121
+
122
+ toString(): string;
123
+ }
124
+
125
+ export interface SegmentTypes {
126
+
127
+ [key: string]: Segment;
128
+ }
129
+
130
+ type CardinalDirection = 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW' | 'N';
131
+
132
+ type RectangleSide = 'left' | 'right' | 'top' | 'bottom';
133
+
134
+ type PathSegmentUnit = Segment | Segment[];
135
+
136
+ type PathObjectUnit = Line | Line[] | Curve | Curve[];
137
+
138
+ type SegmentType = 'L' | 'C' | 'M' | 'Z' | 'z';
139
+
140
+ export function normalizeAngle(angle: number): number;
141
+
142
+ export function snapToGrid(val: number, gridSize: number): number;
143
+
144
+ export function toDeg(rad: number): number;
145
+
146
+ export function toRad(deg: number, over360?: boolean): number;
147
+
148
+ export function random(min?: number, max?: number): number;
149
+
150
+ export interface SkeletonPoints {
151
+ startControlPoint1: Point;
152
+ startControlPoint2: Point;
153
+ divider: Point;
154
+ dividerControlPoint1: Point;
155
+ dividerControlPoint2: Point;
156
+ }
157
+
158
+ class Curve {
159
+
160
+ start: Point;
161
+ controlPoint1: Point;
162
+ controlPoint2: Point;
163
+ end: Point;
164
+ type: types.Curve;
165
+
166
+ constructor(p1: PlainPoint | string, p2: PlainPoint | string, p3: PlainPoint | string, p4: PlainPoint | string);
167
+ constructor(curve: Curve);
168
+
169
+ bbox(): Rect;
170
+
171
+ clone(): Curve;
172
+
173
+ closestPoint(p: PlainPoint, opt?: SubdivisionsOpt): Point;
174
+
175
+ closestPointLength(p: PlainPoint, opt?: SubdivisionsOpt): number;
176
+
177
+ closestPointNormalizedLength(p: PlainPoint, opt?: SubdivisionsOpt): number;
178
+
179
+ closestPointT(p: PlainPoint, opt?: SubdivisionsOpt): number;
180
+
181
+ closestPointTangent(p: PlainPoint, opt?: SubdivisionsOpt): Line | null;
182
+
183
+ containsPoint(p: PlainPoint, opt?: SubdivisionsOpt): boolean;
184
+
185
+ divideAt(ratio: number, opt?: SubdivisionsOpt): [Curve, Curve];
186
+
187
+ divideAtLength(length: number, opt?: SubdivisionsOpt): [Curve, Curve];
188
+
189
+ divideAtT(t: number): [Curve, Curve];
190
+ divide(t: number): [Curve, Curve]; // alias to `divideAtT`
191
+
192
+ endpointDistance(): number;
193
+
194
+ equals(c: Curve): boolean;
195
+
196
+ getSkeletonPoints(t: number): SkeletonPoints;
197
+
198
+ getSubdivisions(opt?: PrecisionOpt): Curve[];
199
+
200
+ isDifferentiable(): boolean;
201
+
202
+ length(opt?: SubdivisionsOpt): number;
203
+
204
+ lengthAtT(t: number, opt?: PrecisionOpt): number;
205
+
206
+ pointAt(ratio: number, opt?: SubdivisionsOpt): Point;
207
+
208
+ pointAtLength(length: number, opt?: SubdivisionsOpt): Point;
209
+
210
+ pointAtT(t: number): Point;
211
+
212
+ round(precision?: number): this;
213
+
214
+ scale(sx: number, sy: number, origin?: PlainPoint | string): this;
215
+
216
+ tangentAt(ratio: number, opt?: SubdivisionsOpt): Line | null;
217
+
218
+ tangentAtLength(length: number, opt?: SubdivisionsOpt): Line | null;
219
+
220
+ tangentAtT(t: number): Line | null;
221
+
222
+ tAt(ratio: number, opt?: SubdivisionsOpt): number;
223
+
224
+ tAtLength(length: number, opt?: SubdivisionsOpt): number;
225
+
226
+ translate(tx?: number, ty?: number): this;
227
+ translate(tx: PlainPoint): this;
228
+
229
+ toPoints(opt?: SubdivisionsOpt): Point[];
230
+
231
+ toPolyline(opt?: SubdivisionsOpt): Polyline;
232
+
233
+ toString(): string;
234
+
235
+ static throughPoints(points: PlainPoint[]): Curve[];
236
+ }
237
+
238
+ class Ellipse {
239
+
240
+ x: number;
241
+ y: number;
242
+ a: number;
243
+ b: number;
244
+ type: types.Ellipse;
245
+
246
+ constructor(center: PlainPoint | string, a: number, b: number);
247
+ constructor(ellipse: Ellipse);
248
+
249
+ bbox(): Rect;
250
+
251
+ center(): Point;
252
+
253
+ clone(): Ellipse;
254
+
255
+ containsPoint(p: PlainPoint): boolean;
256
+
257
+ equals(ellipse: Ellipse): boolean;
258
+
259
+ inflate(dx?: number, dy?: number): this;
260
+
261
+ intersectionWithLine(l: Line): Point[] | null;
262
+
263
+ intersectionWithLineFromCenterToPoint(p: PlainPoint, angle?: number): Point;
264
+
265
+ normalizedDistance(point: PlainPoint): number;
266
+
267
+ round(precision?: number): this;
268
+
269
+ tangentTheta(p: PlainPoint): number;
270
+
271
+ toString(): string;
272
+
273
+ static fromRect(rect: PlainRect): Ellipse;
274
+ }
275
+
276
+ class Line {
277
+
278
+ start: Point;
279
+ end: Point;
280
+ type: types.Line;
281
+
282
+ constructor(p1: PlainPoint | string, p2: PlainPoint | string);
283
+ constructor(line: Line);
284
+ constructor();
285
+
286
+ angle(): number;
287
+
288
+ bbox(): Rect;
289
+
290
+ bearing(): CardinalDirection;
291
+
292
+ clone(): Line;
293
+
294
+ parallel(distance: number): Line;
295
+
296
+ closestPoint(p: PlainPoint | string): Point;
297
+
298
+ closestPointLength(p: PlainPoint | string): number;
299
+
300
+ closestPointNormalizedLength(p: PlainPoint | string): number;
301
+
302
+ closestPointTangent(p: PlainPoint | string): Line | null;
303
+
304
+ containsPoint(p: PlainPoint): boolean;
305
+
306
+ divideAt(t: number): [Line, Line];
307
+
308
+ divideAtLength(length: number): [Line, Line];
309
+
310
+ equals(line: Line): boolean;
311
+
312
+ intersect(line: Line): Point | null; // Backwards compatibility, should return an array
313
+ intersect(rect: Rect): Point[] | null;
314
+ intersect(ellipse: Ellipse): Point[] | null;
315
+ intersect(polyline: Polyline): Point[] | null;
316
+ intersect(path: Path, opt?: SegmentSubdivisionsOpt): Point[] | null;
317
+
318
+ intersectionWithLine(l: Line): Point[] | null;
319
+
320
+ isDifferentiable(): boolean;
321
+
322
+ length(): number;
323
+
324
+ midpoint(): Point;
325
+
326
+ pointAt(t: number): Point;
327
+
328
+ pointAtLength(length: number): Point;
329
+
330
+ pointOffset(p: PlainPoint | string): number;
331
+
332
+ rotate(origin: PlainPoint, angle: number): this;
333
+
334
+ round(precision?: number): this;
335
+
336
+ scale(sx: number, sy: number, origin?: PlainPoint): this;
337
+
338
+ setLength(length: number): this;
339
+
340
+ squaredLength(): number;
341
+
342
+ tangentAt(t: number): Line | null;
343
+
344
+ tangentAtLength(length: number): Line | null;
345
+
346
+ translate(tx?: number, ty?: number): this;
347
+ translate(tx: PlainPoint): this;
348
+
349
+ vector(): Point;
350
+
351
+ toString(): string;
352
+
353
+ serialize(): string;
354
+ }
355
+
356
+ class Path {
357
+
358
+ segments: Segment[];
359
+ start: Point | null; // getter
360
+ end: Point | null; // getter
361
+ type: types.Path;
362
+
363
+ constructor();
364
+ constructor(pathData: string);
365
+ constructor(segments: PathSegmentUnit | PathSegmentUnit[]);
366
+ constructor(objects: PathObjectUnit | PathObjectUnit[]);
367
+ constructor(polyline: Polyline);
368
+
369
+ appendSegment(segments: PathSegmentUnit | PathSegmentUnit[]): void;
370
+
371
+ bbox(): Rect | null;
372
+
373
+ clone(): Path;
374
+
375
+ closestPoint(p: Point, opt?: SegmentSubdivisionsOpt): Point | null;
376
+
377
+ closestPointLength(p: Point, opt?: SegmentSubdivisionsOpt): number;
378
+
379
+ closestPointNormalizedLength(p: Point, opt?: SegmentSubdivisionsOpt): number;
380
+
381
+ closestPointTangent(p: Point, opt?: SegmentSubdivisionsOpt): Line | null;
382
+
383
+ containsPoint(p: PlainPoint, opt?: SegmentSubdivisionsOpt): boolean;
384
+
385
+ divideAt(ratio: number, opt?: SegmentSubdivisionsOpt): [Path, Path] | null;
386
+
387
+ divideAtLength(length: number, opt?: SegmentSubdivisionsOpt): [Path, Path] | null;
388
+
389
+ equals(p: Path): boolean;
390
+
391
+ getSegment(index: number): Segment | null;
392
+
393
+ getSegmentSubdivisions(opt?: PrecisionOpt): Curve[][];
394
+
395
+ getSubpaths(): Path[];
396
+
397
+ insertSegment(index: number, segments: PathSegmentUnit | PathSegmentUnit[]): void;
398
+
399
+ intersectionWithLine(l: Line, opt?: SegmentSubdivisionsOpt): Point[] | null;
400
+
401
+ isDifferentiable(): boolean;
402
+
403
+ isValid(): boolean;
404
+
405
+ length(opt?: SegmentSubdivisionsOpt): number;
406
+
407
+ pointAt(ratio: number, opt?: SegmentSubdivisionsOpt): Point | null;
408
+
409
+ pointAtLength(length: number, opt?: SegmentSubdivisionsOpt): Point | null;
410
+
411
+ removeSegment(index: number): void;
412
+
413
+ replaceSegment(index: number, segments: PathSegmentUnit | PathSegmentUnit[]): void;
414
+
415
+ round(precision?: number): this;
416
+
417
+ scale(sx: number, sy: number, origin?: PlainPoint | string): this;
418
+
419
+ segmentAt(ratio: number, opt?: SegmentSubdivisionsOpt): Segment | null;
420
+
421
+ segmentAtLength(length: number, opt?: SegmentSubdivisionsOpt): Segment | null;
422
+
423
+ segmentIndexAt(ratio: number, opt?: SegmentSubdivisionsOpt): number | null;
424
+
425
+ segmentIndexAtLength(length: number, opt?: SegmentSubdivisionsOpt): number | null;
426
+
427
+ tangentAt(ratio: number, opt?: SegmentSubdivisionsOpt): Line | null;
428
+
429
+ tangentAtLength(length: number, opt?: SegmentSubdivisionsOpt): Line | null;
430
+
431
+ toPoints(opt?: SegmentSubdivisionsOpt): Point[][] | null;
432
+
433
+ toPolylines(opt?: SegmentSubdivisionsOpt): Polyline[] | null;
434
+
435
+ translate(tx?: number, ty?: number): this;
436
+ translate(tx: PlainPoint): this;
437
+
438
+ serialize(): string;
439
+
440
+ toString(): string;
441
+
442
+ validate(): this;
443
+
444
+ private closestPointT(p: Point, opt?: SegmentSubdivisionsOpt): PathT | null;
445
+
446
+ private lengthAtT(t: PathT, opt?: SegmentSubdivisionsOpt): number;
447
+
448
+ private pointAtT(t: PathT): Point | null;
449
+
450
+ private tangentAtT(t: PathT): Line | null;
451
+
452
+ private prepareSegment(segment: Segment, previousSegment?: Segment | null, nextSegment?: Segment | null): Segment;
453
+
454
+ private updateSubpathStartSegment(segment: Segment): void;
455
+
456
+ static createSegment(type: SegmentType, ...args: any[]): PathSegmentUnit;
457
+
458
+ static parse(pathData: string): Path;
459
+
460
+ static segmentTypes: SegmentTypes;
461
+
462
+ static isDataSupported(pathData: string): boolean;
463
+ }
464
+
465
+ class Point implements PlainPoint {
466
+
467
+ x: number;
468
+ y: number;
469
+ type: types.Point;
470
+
471
+ constructor(x?: number, y?: number);
472
+ constructor(p: PlainPoint | string);
473
+
474
+ chooseClosest(points: PlainPoint[]): Point | null;
475
+
476
+ adhereToRect(r: Rect): this;
477
+
478
+ angleBetween(p1: PlainPoint, p2: PlainPoint): number;
479
+
480
+ bearing(p: Point): CardinalDirection;
481
+
482
+ changeInAngle(dx: number, dy: number, ref: PlainPoint | string): number;
483
+
484
+ clone(): Point;
485
+
486
+ cross(p1: PlainPoint, p2: PlainPoint): number;
487
+
488
+ difference(dx?: number, dy?: number): Point;
489
+ difference(p: PlainPoint): Point;
490
+
491
+ distance(p: PlainPoint | string): number;
492
+
493
+ dot(p: PlainPoint): number;
494
+
495
+ equals(p: Point): boolean;
496
+
497
+ lerp(p: Point, t: number): Point;
498
+
499
+ magnitude(): number;
500
+
501
+ manhattanDistance(p: PlainPoint): number;
502
+
503
+ move(ref: PlainPoint | string, distance: number): this;
504
+
505
+ normalize(length: number): this;
506
+
507
+ offset(dx?: number, dy?: number): this;
508
+ offset(p: PlainPoint): this;
509
+
510
+ reflection(ref: PlainPoint | string): Point;
511
+
512
+ rotate(origin: PlainPoint | string, angle: number): this;
513
+
514
+ round(precision?: number): this;
515
+
516
+ scale(sx: number, sy: number, origin?: PlainPoint | string): this;
517
+
518
+ snapToGrid(gx: number, gy?: number): this;
519
+
520
+ squaredDistance(p: PlainPoint | string): number;
521
+
522
+ theta(p: PlainPoint | string): number;
523
+
524
+ toJSON(): PlainPoint;
525
+
526
+ toPolar(origin?: PlainPoint | string): this;
527
+
528
+ toString(): string;
529
+
530
+ serialize(): string;
531
+
532
+ translate(tx?: number, ty?: number): this;
533
+ translate(tx: PlainPoint): this;
534
+
535
+ update(x?: number, y?: number): this;
536
+ update(p: PlainPoint): this;
537
+
538
+ vectorAngle(p: PlainPoint): number;
539
+
540
+ static fromPolar(distance: number, angle: number, origin?: PlainPoint | string): Point;
541
+
542
+ static random(x1: number, x2: number, y1: number, y2: number): Point;
543
+ }
544
+ abstract class PolygonalChain {
545
+
546
+ points: Point[];
547
+ start: Point | null; // getter
548
+ end: Point | null; // getter
549
+
550
+ constructor();
551
+ constructor(svgString: string);
552
+ constructor(points: PlainPoint[]);
553
+
554
+ bbox(): Rect | null;
555
+
556
+ closestPoint(p: PlainPoint | string): Point | null;
557
+
558
+ closestPointLength(p: PlainPoint | string): number;
559
+
560
+ closestPointNormalizedLength(p: PlainPoint | string): number;
561
+
562
+ closestPointTangent(p: PlainPoint | string): Line | null;
563
+
564
+ containsPoint(p: PlainPoint): boolean;
565
+
566
+ equals(p: Polyline): boolean;
567
+
568
+ isDifferentiable(): boolean;
569
+
570
+ intersectionWithLine(l: Line): Point[] | null;
571
+
572
+ close(): this;
573
+
574
+ length(): number;
575
+
576
+ pointAt(ratio: number): Point | null;
577
+
578
+ pointAtLength(length: number): Point | null;
579
+
580
+ round(precision?: number): this;
581
+
582
+ scale(sx: number, sy: number, origin?: PlainPoint | string): this;
583
+
584
+ simplify(opt?: { threshold?: number }): this;
585
+
586
+ tangentAt(ratio: number): Line | null;
587
+
588
+ tangentAtLength(length: number): Line | null;
589
+
590
+ translate(tx?: number, ty?: number): this;
591
+ translate(tx: PlainPoint): this;
592
+
593
+ serialize(): string;
594
+
595
+ toString(): string;
596
+
597
+ clone(): this;
598
+
599
+ convexHull(): this;
600
+ }
601
+
602
+ class Polyline extends PolygonalChain {
603
+
604
+ type: types.Polyline;
605
+
606
+ static parse(svgString: string): Polyline;
607
+
608
+ static fromRect(rect: Rect): Polyline;
609
+ }
610
+
611
+ class Polygon extends PolygonalChain {
612
+
613
+ type: types.Polygon;
614
+
615
+ static parse(svgString: string): Polygon;
616
+
617
+ static fromRect(rect: Rect): Polygon;
618
+ }
619
+
620
+ class Rect implements PlainRect {
621
+
622
+ x: number;
623
+ y: number;
624
+ width: number;
625
+ height: number;
626
+ type: types.Rect;
627
+
628
+ constructor(x?: number, y?: number, width?: number, height?: number);
629
+ constructor(r: PlainRect);
630
+
631
+ bbox(angle?: number): Rect;
632
+
633
+ rotateAroundCenter(angle: number): this;
634
+
635
+ bottomLeft(): Point;
636
+
637
+ bottomLine(): Line;
638
+
639
+ bottomMiddle(): Point;
640
+
641
+ bottomRight(): Point;
642
+
643
+ center(): Point;
644
+
645
+ clone(): Rect;
646
+
647
+ containsPoint(p: PlainPoint | string): boolean;
648
+
649
+ containsRect(r: PlainRect): boolean;
650
+
651
+ corner(): Point;
652
+
653
+ equals(r: PlainRect): boolean;
654
+
655
+ inflate(dx?: number, dy?: number): this;
656
+
657
+ intersect(r: Rect): Rect | null;
658
+
659
+ intersectionWithLine(l: Line): Point[] | null;
660
+
661
+ intersectionWithLineFromCenterToPoint(p: PlainPoint | string, angle?: number): Point;
662
+
663
+ leftLine(): Line;
664
+
665
+ leftMiddle(): Point;
666
+
667
+ maxRectScaleToFit(rect: PlainRect, origin?: PlainPoint): Scale;
668
+
669
+ maxRectUniformScaleToFit(rect: PlainRect, origin?: PlainPoint): number;
670
+
671
+ moveAndExpand(r: PlainRect): this;
672
+
673
+ normalize(): this;
674
+
675
+ offset(dx?: number, dy?: number): this;
676
+ offset(p: PlainPoint): this;
677
+
678
+ origin(): Point;
679
+
680
+ pointNearestToPoint(point: PlainPoint | string): Point;
681
+
682
+ rightLine(): Line;
683
+
684
+ rightMiddle(): Point;
685
+
686
+ round(precision?: number): this;
687
+
688
+ scale(sx: number, sy: number, origin?: PlainPoint | string): this;
689
+
690
+ sideNearestToPoint(point: PlainPoint | string): RectangleSide;
691
+
692
+ snapToGrid(gx: number, gy?: number): this;
693
+
694
+ topLeft(): Point;
695
+
696
+ topLine(): Line;
697
+
698
+ topMiddle(): Point;
699
+
700
+ topRight(): Point;
701
+
702
+ translate(tx?: number, ty?: number): this;
703
+ translate(tx: PlainPoint): this;
704
+
705
+ toJSON(): PlainRect;
706
+
707
+ toString(): string;
708
+
709
+ union(rect: PlainRect): Rect;
710
+
711
+ update(x?: number, y?: number, width?: number, height?: number): this;
712
+ update(rect: PlainRect): this;
713
+
714
+ static fromEllipse(e: Ellipse): Rect;
715
+
716
+ static fromPointUnion(...points: PlainPoint[]): Rect | null;
717
+
718
+ static fromRectUnion(...rects: PlainRect[]): Rect | null;
719
+ }
720
+
721
+ namespace bezier {
722
+
723
+ interface IBezierCurve {
724
+ p0: Point;
725
+ p1: Point;
726
+ p2: Point;
727
+ p3: Point;
728
+ }
729
+
730
+ export function curveThroughPoints(points: PlainPoint[] | Point[]): string[];
731
+
732
+ export function getCurveControlPoints(points: PlainPoint[] | Point[]): [Point[], Point[]];
733
+
734
+ export function getCurveDivider(
735
+ p0: string | PlainPoint,
736
+ p1: string | PlainPoint,
737
+ p2: string | PlainPoint,
738
+ p3: string | PlainPoint
739
+ ): (t: number) => [IBezierCurve, IBezierCurve];
740
+
741
+ export function getFirstControlPoints(rhs: number[]): number[];
742
+
743
+ export function getInversionSolver(
744
+ p0: PlainPoint,
745
+ p1: PlainPoint,
746
+ p2: PlainPoint,
747
+ p3: PlainPoint
748
+ ): (p: PlainPoint) => number;
749
+ }
750
+
751
+ namespace scale {
752
+
753
+ export function linear(domain: [number, number], range: [number, number], value: number): number;
754
+ }
755
+
756
+ namespace intersection {
757
+
758
+ function exists(shape1: Shape, shape2: Shape, shape1opt?: SegmentSubdivisionsOpt | null, shape2opt?: SegmentSubdivisionsOpt | null): boolean;
759
+
760
+ /* Line */
761
+
762
+ export function lineWithLine(line1: Line, line2: Line): boolean;
763
+
764
+ /* Ellipse */
765
+
766
+ export function ellipseWithLine(ellipse: Ellipse, line: Line): boolean;
767
+
768
+ export function ellipseWithEllipse(ellipse1: Ellipse, ellipse2: Ellipse): boolean;
769
+
770
+ /* Rect */
771
+
772
+ export function rectWithLine(rect: Rect, line: Line): boolean;
773
+
774
+ export function rectWithEllipse(rect: Rect, ellipse: Ellipse): boolean;
775
+
776
+ export function rectWithRect(rect1: Rect, rect2: Rect): boolean;
777
+
778
+
779
+ /* Polyline */
780
+
781
+ export function polylineWithLine(polyline: Polyline, line: Line): boolean;
782
+
783
+ export function polylineWithEllipse(polyline: Polyline, ellipse: Ellipse): boolean;
784
+
785
+ export function polylineWithRect(polyline: Polyline, rect: Rect): boolean;
786
+
787
+ export function polylineWithPolyline(polyline1: Polyline, polyline2: Polyline): boolean;
788
+
789
+ /* Polygon */
790
+
791
+ export function polygonWithLine(polygon: Polygon, line: Line): boolean;
792
+
793
+ export function polygonWithEllipse(polygon: Polygon, ellipse: Ellipse): boolean;
794
+
795
+ export function polygonWithRect(polygon: Polygon, rect: Rect): boolean;
796
+
797
+ export function polygonWithPolyline(polygon: Polygon, polyline: Polyline): boolean;
798
+
799
+ export function polygonWithPolygon(polygon1: Polygon, polygon2: Polygon): boolean;
800
+
801
+ /* Path */
802
+
803
+ export function pathWithLine(path: Path, line: Line, pathOpt?: SegmentSubdivisionsOpt): boolean;
804
+
805
+ export function pathWithEllipse(path: Path, ellipse: Ellipse, pathOpt?: SegmentSubdivisionsOpt): boolean;
806
+
807
+ export function pathWithRect(path: Path, rect: Rect, pathOpt?: SegmentSubdivisionsOpt): boolean;
808
+
809
+ export function pathWithPolyline(path: Path, polyline: Polyline, pathOpt?: SegmentSubdivisionsOpt): boolean;
810
+
811
+ export function pathWithPolygon(path: Path, polygon: Polygon, pathOpt?: SegmentSubdivisionsOpt): boolean;
812
+
813
+ export function pathWithPath(path1: Path, path2: Path, pathOpt1?: SegmentSubdivisionsOpt | null, pathOpt2?: SegmentSubdivisionsOpt | null): boolean;
814
+ }
815
+ }