@joint/core 4.2.0-alpha.0 → 4.2.0-alpha.1

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.
@@ -12,12 +12,16 @@ export namespace g {
12
12
  }
13
13
 
14
14
  export type Shape = Path | Point | Line | Polyline | Polygon | Rect | Ellipse;
15
+
15
16
  export interface PlainPoint {
16
17
 
17
18
  x: number;
18
19
  y: number;
19
20
  }
20
21
 
22
+ /** Can be understood by `g.Point` constructor */
23
+ export type PointInit = Partial<PlainPoint> | string;
24
+
21
25
  export interface PlainRect {
22
26
 
23
27
  x: number;
@@ -77,15 +81,15 @@ export namespace g {
77
81
 
78
82
  clone(): Segment;
79
83
 
80
- closestPoint(p: Point, opt?: SubdivisionsOpt): Point;
84
+ closestPoint(p: PlainPoint, opt?: SubdivisionsOpt): Point;
81
85
 
82
- closestPointLength(p: Point, opt?: SubdivisionsOpt): number;
86
+ closestPointLength(p: PlainPoint, opt?: SubdivisionsOpt): number;
83
87
 
84
- closestPointNormalizedLength(p: Point, opt?: SubdivisionsOpt): number;
88
+ closestPointNormalizedLength(p: PlainPoint, opt?: SubdivisionsOpt): number;
85
89
 
86
- closestPointT(p: Point): number;
90
+ closestPointT(p: PlainPoint): number;
87
91
 
88
- closestPointTangent(p: Point): Line | null;
92
+ closestPointTangent(p: PlainPoint): Line | null;
89
93
 
90
94
  divideAt(ratio: number, opt?: SubdivisionsOpt): [Segment, Segment];
91
95
 
@@ -111,7 +115,7 @@ export namespace g {
111
115
 
112
116
  round(precision?: number): this;
113
117
 
114
- scale(sx: number, sy: number, origin?: PlainPoint): this;
118
+ scale(sx: number, sy: number, origin?: PointInit): this;
115
119
 
116
120
  tangentAt(ratio: number): Line | null;
117
121
 
@@ -168,7 +172,7 @@ export namespace g {
168
172
  end: Point;
169
173
  type: types.Curve;
170
174
 
171
- constructor(p1: PlainPoint | string, p2: PlainPoint | string, p3: PlainPoint | string, p4: PlainPoint | string);
175
+ constructor(p1: PointInit, p2: PointInit, p3: PointInit, p4: PointInit);
172
176
  constructor(curve: Curve);
173
177
 
174
178
  bbox(): Rect;
@@ -216,7 +220,7 @@ export namespace g {
216
220
 
217
221
  round(precision?: number): this;
218
222
 
219
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
223
+ scale(sx: number, sy: number, origin?: PointInit): this;
220
224
 
221
225
  tangentAt(ratio: number, opt?: SubdivisionsOpt): Line | null;
222
226
 
@@ -248,7 +252,7 @@ export namespace g {
248
252
  b: number;
249
253
  type: types.Ellipse;
250
254
 
251
- constructor(center: PlainPoint | string, a: number, b: number);
255
+ constructor(center: PointInit, a: number, b: number);
252
256
  constructor(ellipse: Ellipse);
253
257
 
254
258
  bbox(): Rect;
@@ -265,7 +269,7 @@ export namespace g {
265
269
 
266
270
  intersectionWithLine(l: Line): Point[] | null;
267
271
 
268
- intersectionWithLineFromCenterToPoint(p: PlainPoint, angle?: number): Point;
272
+ intersectionWithLineFromCenterToPoint(p: PointInit, angle?: number): Point;
269
273
 
270
274
  normalizedDistance(point: PlainPoint): number;
271
275
 
@@ -284,7 +288,7 @@ export namespace g {
284
288
  end: Point;
285
289
  type: types.Line;
286
290
 
287
- constructor(p1: PlainPoint | string, p2: PlainPoint | string);
291
+ constructor(p1: PointInit, p2: PointInit);
288
292
  constructor(line: Line);
289
293
  constructor();
290
294
 
@@ -298,13 +302,13 @@ export namespace g {
298
302
 
299
303
  parallel(distance: number): Line;
300
304
 
301
- closestPoint(p: PlainPoint | string): Point;
305
+ closestPoint(p: PointInit): Point;
302
306
 
303
- closestPointLength(p: PlainPoint | string): number;
307
+ closestPointLength(p: PointInit): number;
304
308
 
305
- closestPointNormalizedLength(p: PlainPoint | string): number;
309
+ closestPointNormalizedLength(p: PointInit): number;
306
310
 
307
- closestPointTangent(p: PlainPoint | string): Line | null;
311
+ closestPointTangent(p: PointInit): Line | null;
308
312
 
309
313
  containsPoint(p: PlainPoint): boolean;
310
314
 
@@ -332,13 +336,13 @@ export namespace g {
332
336
 
333
337
  pointAtLength(length: number): Point;
334
338
 
335
- pointOffset(p: PlainPoint | string): number;
339
+ pointOffset(p: PointInit): number;
336
340
 
337
341
  rotate(origin: PlainPoint, angle: number): this;
338
342
 
339
343
  round(precision?: number): this;
340
344
 
341
- scale(sx: number, sy: number, origin?: PlainPoint): this;
345
+ scale(sx: number, sy: number, origin?: PointInit): this;
342
346
 
343
347
  setLength(length: number): this;
344
348
 
@@ -377,13 +381,13 @@ export namespace g {
377
381
 
378
382
  clone(): Path;
379
383
 
380
- closestPoint(p: Point, opt?: SegmentSubdivisionsOpt): Point | null;
384
+ closestPoint(p: PlainPoint, opt?: SegmentSubdivisionsOpt): Point | null;
381
385
 
382
- closestPointLength(p: Point, opt?: SegmentSubdivisionsOpt): number;
386
+ closestPointLength(p: PlainPoint, opt?: SegmentSubdivisionsOpt): number;
383
387
 
384
- closestPointNormalizedLength(p: Point, opt?: SegmentSubdivisionsOpt): number;
388
+ closestPointNormalizedLength(p: PlainPoint, opt?: SegmentSubdivisionsOpt): number;
385
389
 
386
- closestPointTangent(p: Point, opt?: SegmentSubdivisionsOpt): Line | null;
390
+ closestPointTangent(p: PlainPoint, opt?: SegmentSubdivisionsOpt): Line | null;
387
391
 
388
392
  containsPoint(p: PlainPoint, opt?: SegmentSubdivisionsOpt): boolean;
389
393
 
@@ -419,7 +423,7 @@ export namespace g {
419
423
 
420
424
  round(precision?: number): this;
421
425
 
422
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
426
+ scale(sx: number, sy: number, origin?: PointInit): this;
423
427
 
424
428
  segmentAt(ratio: number, opt?: SegmentSubdivisionsOpt): Segment | null;
425
429
 
@@ -446,7 +450,7 @@ export namespace g {
446
450
 
447
451
  validate(): this;
448
452
 
449
- private closestPointT(p: Point, opt?: SegmentSubdivisionsOpt): PathT | null;
453
+ private closestPointT(p: PlainPoint, opt?: SegmentSubdivisionsOpt): PathT | null;
450
454
 
451
455
  private lengthAtT(t: PathT, opt?: SegmentSubdivisionsOpt): number;
452
456
 
@@ -474,17 +478,17 @@ export namespace g {
474
478
  type: types.Point;
475
479
 
476
480
  constructor(x?: number, y?: number);
477
- constructor(p: PlainPoint | string);
481
+ constructor(p: PointInit);
478
482
 
479
- chooseClosest(points: PlainPoint[]): Point | null;
483
+ chooseClosest(points: PointInit[]): Point | null;
480
484
 
481
485
  adhereToRect(r: Rect): this;
482
486
 
483
487
  angleBetween(p1: PlainPoint, p2: PlainPoint): number;
484
488
 
485
- bearing(p: Point): CardinalDirection;
489
+ bearing(p: PlainPoint): CardinalDirection;
486
490
 
487
- changeInAngle(dx: number, dy: number, ref: PlainPoint | string): number;
491
+ changeInAngle(dx: number, dy: number, ref: PointInit): number;
488
492
 
489
493
  clone(): Point;
490
494
 
@@ -493,42 +497,42 @@ export namespace g {
493
497
  difference(dx?: number, dy?: number): Point;
494
498
  difference(p: PlainPoint): Point;
495
499
 
496
- distance(p: PlainPoint | string): number;
500
+ distance(p: PlainPoint): number;
497
501
 
498
502
  dot(p: PlainPoint): number;
499
503
 
500
- equals(p: Point): boolean;
504
+ equals(p: PlainPoint): boolean;
501
505
 
502
- lerp(p: Point, t: number): Point;
506
+ lerp(p: PlainPoint, t: number): Point;
503
507
 
504
508
  magnitude(): number;
505
509
 
506
510
  manhattanDistance(p: PlainPoint): number;
507
511
 
508
- move(ref: PlainPoint | string, distance: number): this;
512
+ move(ref: PointInit, distance: number): this;
509
513
 
510
514
  normalize(length: number): this;
511
515
 
512
516
  offset(dx?: number, dy?: number): this;
513
517
  offset(p: PlainPoint): this;
514
518
 
515
- reflection(ref: PlainPoint | string): Point;
519
+ reflection(ref: PointInit): Point;
516
520
 
517
- rotate(origin: PlainPoint | string, angle: number): this;
521
+ rotate(origin: PlainPoint, angle: number): this;
518
522
 
519
523
  round(precision?: number): this;
520
524
 
521
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
525
+ scale(sx: number, sy: number, origin?: PointInit): this;
522
526
 
523
527
  snapToGrid(gx: number, gy?: number): this;
524
528
 
525
- squaredDistance(p: PlainPoint | string): number;
529
+ squaredDistance(p: PlainPoint): number;
526
530
 
527
- theta(p: PlainPoint | string): number;
531
+ theta(p: PointInit): number;
528
532
 
529
533
  toJSON(): PlainPoint;
530
534
 
531
- toPolar(origin?: PlainPoint | string): this;
535
+ toPolar(origin?: PointInit): this;
532
536
 
533
537
  toString(): string;
534
538
 
@@ -542,7 +546,7 @@ export namespace g {
542
546
 
543
547
  vectorAngle(p: PlainPoint): number;
544
548
 
545
- static fromPolar(distance: number, angle: number, origin?: PlainPoint | string): Point;
549
+ static fromPolar(distance: number, angle: number, origin?: PointInit): Point;
546
550
 
547
551
  static random(x1: number, x2: number, y1: number, y2: number): Point;
548
552
  }
@@ -554,17 +558,17 @@ export namespace g {
554
558
 
555
559
  constructor();
556
560
  constructor(svgString: string);
557
- constructor(points: PlainPoint[]);
561
+ constructor(points: PointInit[]);
558
562
 
559
563
  bbox(): Rect | null;
560
564
 
561
- closestPoint(p: PlainPoint | string): Point | null;
565
+ closestPoint(p: PlainPoint): Point | null;
562
566
 
563
- closestPointLength(p: PlainPoint | string): number;
567
+ closestPointLength(p: PlainPoint): number;
564
568
 
565
- closestPointNormalizedLength(p: PlainPoint | string): number;
569
+ closestPointNormalizedLength(p: PlainPoint): number;
566
570
 
567
- closestPointTangent(p: PlainPoint | string): Line | null;
571
+ closestPointTangent(p: PlainPoint): Line | null;
568
572
 
569
573
  containsPoint(p: PlainPoint): boolean;
570
574
 
@@ -584,7 +588,7 @@ export namespace g {
584
588
 
585
589
  round(precision?: number): this;
586
590
 
587
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
591
+ scale(sx: number, sy: number, origin?: PointInit): this;
588
592
 
589
593
  simplify(opt?: { threshold?: number }): this;
590
594
 
@@ -649,7 +653,7 @@ export namespace g {
649
653
 
650
654
  clone(): Rect;
651
655
 
652
- containsPoint(p: PlainPoint | string, opt?: StrictOpt): boolean;
656
+ containsPoint(p: PointInit, opt?: StrictOpt): boolean;
653
657
 
654
658
  containsRect(r: PlainRect): boolean;
655
659
 
@@ -663,7 +667,7 @@ export namespace g {
663
667
 
664
668
  intersectionWithLine(l: Line): Point[] | null;
665
669
 
666
- intersectionWithLineFromCenterToPoint(p: PlainPoint | string, angle?: number): Point;
670
+ intersectionWithLineFromCenterToPoint(p: PointInit, angle?: number): Point;
667
671
 
668
672
  leftLine(): Line;
669
673
 
@@ -675,7 +679,7 @@ export namespace g {
675
679
 
676
680
  moveAndExpand(r: PlainRect): this;
677
681
 
678
- moveAroundPoint(origin: PlainPoint | string, angle: number): this;
682
+ moveAroundPoint(origin: PlainPoint, angle: number): this;
679
683
 
680
684
  normalize(): this;
681
685
 
@@ -684,7 +688,7 @@ export namespace g {
684
688
 
685
689
  origin(): Point;
686
690
 
687
- pointNearestToPoint(point: PlainPoint | string): Point;
691
+ pointNearestToPoint(point: PointInit): Point;
688
692
 
689
693
  rightLine(): Line;
690
694
 
@@ -692,9 +696,9 @@ export namespace g {
692
696
 
693
697
  round(precision?: number): this;
694
698
 
695
- scale(sx: number, sy: number, origin?: PlainPoint | string): this;
699
+ scale(sx: number, sy: number, origin?: PointInit): this;
696
700
 
697
- sideNearestToPoint(point: PlainPoint | string): RectangleSide;
701
+ sideNearestToPoint(point: PointInit): RectangleSide;
698
702
 
699
703
  snapToGrid(gx: number, gy?: number): this;
700
704
 
@@ -734,24 +738,24 @@ export namespace g {
734
738
  p3: Point;
735
739
  }
736
740
 
737
- export function curveThroughPoints(points: PlainPoint[] | Point[]): string[];
741
+ export function curveThroughPoints(points: PlainPoint[]): string[];
738
742
 
739
- export function getCurveControlPoints(points: PlainPoint[] | Point[]): [Point[], Point[]];
743
+ export function getCurveControlPoints(points: PlainPoint[]): [Point[], Point[]];
740
744
 
741
745
  export function getCurveDivider(
742
- p0: string | PlainPoint,
743
- p1: string | PlainPoint,
744
- p2: string | PlainPoint,
745
- p3: string | PlainPoint
746
+ p0: PointInit,
747
+ p1: PointInit,
748
+ p2: PointInit,
749
+ p3: PointInit
746
750
  ): (t: number) => [IBezierCurve, IBezierCurve];
747
751
 
748
752
  export function getFirstControlPoints(rhs: number[]): number[];
749
753
 
750
754
  export function getInversionSolver(
751
- p0: PlainPoint,
752
- p1: PlainPoint,
753
- p2: PlainPoint,
754
- p3: PlainPoint
755
+ p0: PointInit,
756
+ p1: PointInit,
757
+ p2: PointInit,
758
+ p3: PointInit
755
759
  ): (p: PlainPoint) => number;
756
760
  }
757
761