plotboilerplate 1.30.0 → 1.31.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 (58) hide show
  1. package/README.md +26 -13
  2. package/dist/index.esm.js +120 -45
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +75 -24
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +1 -1
  11. package/src/cjs/Polygon.d.ts +18 -4
  12. package/src/cjs/Polygon.js +56 -18
  13. package/src/cjs/Polygon.js.map +1 -1
  14. package/src/cjs/VertTuple.d.ts +15 -4
  15. package/src/cjs/VertTuple.js +17 -4
  16. package/src/cjs/VertTuple.js.map +1 -1
  17. package/src/cjs/Vertex.d.ts +2 -2
  18. package/src/cjs/Vertex.js +2 -2
  19. package/src/cjs/utils/algorithms/delaunay2voronoi.d.ts +2 -1
  20. package/src/cjs/utils/algorithms/delaunay2voronoi.js +8 -10
  21. package/src/cjs/utils/algorithms/delaunay2voronoi.js.map +1 -1
  22. package/src/cjs/utils/datastructures/PointSet.d.ts +63 -0
  23. package/src/cjs/utils/datastructures/PointSet.js +126 -0
  24. package/src/cjs/utils/datastructures/PointSet.js.map +1 -0
  25. package/src/cjs/utils/datastructures/VoronoiCell.d.ts +19 -2
  26. package/src/cjs/utils/datastructures/VoronoiCell.js +39 -12
  27. package/src/cjs/utils/datastructures/VoronoiCell.js.map +1 -1
  28. package/src/cjs/utils/renderers/VoronoiRenderer.d.ts +99 -0
  29. package/src/cjs/utils/renderers/VoronoiRenderer.js +147 -0
  30. package/src/cjs/utils/renderers/VoronoiRenderer.js.map +1 -0
  31. package/src/esm/Polygon.d.ts +18 -4
  32. package/src/esm/Polygon.js +56 -18
  33. package/src/esm/Polygon.js.map +1 -1
  34. package/src/esm/VertTuple.d.ts +15 -4
  35. package/src/esm/VertTuple.js +17 -4
  36. package/src/esm/VertTuple.js.map +1 -1
  37. package/src/esm/Vertex.d.ts +2 -2
  38. package/src/esm/Vertex.js +2 -2
  39. package/src/esm/utils/algorithms/delaunay2voronoi.d.ts +2 -1
  40. package/src/esm/utils/algorithms/delaunay2voronoi.js +8 -10
  41. package/src/esm/utils/algorithms/delaunay2voronoi.js.map +1 -1
  42. package/src/esm/utils/datastructures/PointSet.d.ts +63 -0
  43. package/src/esm/utils/datastructures/PointSet.js +115 -0
  44. package/src/esm/utils/datastructures/PointSet.js.map +1 -0
  45. package/src/esm/utils/datastructures/VoronoiCell.d.ts +19 -2
  46. package/src/esm/utils/datastructures/VoronoiCell.js +39 -12
  47. package/src/esm/utils/datastructures/VoronoiCell.js.map +1 -1
  48. package/src/esm/utils/renderers/VoronoiRenderer.d.ts +99 -0
  49. package/src/esm/utils/renderers/VoronoiRenderer.js +142 -0
  50. package/src/esm/utils/renderers/VoronoiRenderer.js.map +1 -0
  51. package/src/ts/Polygon.ts +58 -18
  52. package/src/ts/VertTuple.ts +18 -4
  53. package/src/ts/Vertex.ts +2 -2
  54. package/src/ts/utils/_AppContext.ts_ +22 -0
  55. package/src/ts/utils/algorithms/delaunay2voronoi.ts +81 -88
  56. package/src/ts/utils/datastructures/PointSet.ts +135 -0
  57. package/src/ts/utils/datastructures/VoronoiCell.ts +198 -169
  58. package/src/ts/utils/renderers/VoronoiRenderer.ts +200 -0
package/README.md CHANGED
@@ -14,39 +14,51 @@ often use for the visualization of 2D geometries. Basic features are
14
14
  - adding elements like
15
15
  - vertices
16
16
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/vertex.html "Vertex class"),
17
- [example](https://plotboilerplate.io/repo/demos/basic-Vertex "Vertex example"))
17
+ [example](https://plotboilerplate.io/repo/demos/basic-Vertex "Vertex example"),
18
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0d500-3791-7489-9ac9-90a83ad53415 "Codepen"))
18
19
  - lines
19
20
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/line.html "Line class"),
20
- [example](https://plotboilerplate.io/repo/demos/basic-Line "Line example"))
21
- - vectors [docs](https://plotboilerplate.io/docs_typedoc/classes/vector.html "Vector class"),
22
- [example](https://plotboilerplate.io/repo/demos/basic-Vector "Vector example"))
21
+ [example](https://plotboilerplate.io/repo/demos/basic-Line "Line example"),
22
+ [Codepen](https://codepen.io/ikaroskappler/pen/ZEjamVb "Codepen"))
23
+ - vectors ([docs](https://plotboilerplate.io/docs_typedoc/classes/vector.html "Vector class"),
24
+ [example](https://plotboilerplate.io/repo/demos/basic-Vector "Vector example"),
25
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0d509-e4db-7664-a7a7-8232a26db80f "Codepen"))
23
26
  - triangles
24
27
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/triangle.html "Triangle class"),
25
- [example](https://plotboilerplate.io/repo/demos/basic-Triangle "Triangle example"))
28
+ [example](https://plotboilerplate.io/repo/demos/basic-Triangle "Triangle example"),
29
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0d50e-90ae-7a46-b7c8-a0a50ef7b558 "Codepen"))
26
30
  - curves
27
31
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/cubicbeziercurve.html "CubicBezierCurve class"),
28
- [example](https://plotboilerplate.io/repo/demos/basic-BezierPath "BezierPath example"))
32
+ [example](https://plotboilerplate.io/repo/demos/basic-BezierPath "BezierPath example"),
33
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0e3f0-d703-7ba8-87c4-44eb1d9f0b6c "Codepen"))
29
34
  - circles
30
35
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/circle.html "Circle class"),
31
- [example](https://plotboilerplate.io/repo/demos/basic-Circle "Circle example"))
36
+ [example](https://plotboilerplate.io/repo/demos/basic-Circle "Circle example"),
37
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0e3f9-9df0-7b70-b885-55652dbc6609 "Codepen"))
32
38
  - circle sectors
33
39
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/circlesector.html "CircleSector class"),
34
- [example](https://plotboilerplate.io/repo/demos/basic-CircleSector "CircleSector example"))
40
+ [example](https://plotboilerplate.io/repo/demos/basic-CircleSector "CircleSector example"),
41
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0e41e-655d-73e8-8ea6-b6bca91bc468 "CircleSector"))
35
42
  - polygons
36
43
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/polygon.html "Polygon class"),
37
- [example](https://plotboilerplate.io/repo/demos/basic-Polygon "Polygon example"))
44
+ [example](https://plotboilerplate.io/repo/demos/basic-Polygon "Polygon example"),
45
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0e421-2f06-7594-8b52-de18613870b5 "Codepen"))
38
46
  - ellipses
39
47
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/vellipse.html "VEllipse class"),
40
- [example](https://plotboilerplate.io/repo/demos/basic-VEllipse "VEllipse example"))
48
+ [example](https://plotboilerplate.io/repo/demos/basic-VEllipse "VEllipse example"),
49
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0e423-1b14-75d4-b297-e7d9a47f5abd "Codepen"))
41
50
  - ellipse sectors
42
51
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/vellipsesector.html "VEllipseSector class"),
43
- [example](https://plotboilerplate.io/repo/demos/basic-VEllipseSector "VEllipseSector example"))
52
+ [example](https://plotboilerplate.io/repo/demos/basic-VEllipseSector "VEllipseSector example"),
53
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0e425-813b-7557-8527-1b95bd56212b "Codepen"))
44
54
  - images
45
55
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/pbimage.html "PBImage class"),
46
- [example](https://plotboilerplate.io/repo/demos/basic-PBImage "PBImage example"))
56
+ [example](https://plotboilerplate.io/repo/demos/basic-PBImage "PBImage example"),
57
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0e428-4a64-78b3-8bf8-08a1bf706cfa "Codepen"))
47
58
  - text
48
59
  ([docs](https://plotboilerplate.io/docs_typedoc/classes/pbtext.html "PBText class"),
49
- [example](https://plotboilerplate.io/repo/demos/basic-PBText "PBText example"))
60
+ [example](https://plotboilerplate.io/repo/demos/basic-PBText "PBText example"),
61
+ [Codepen](https://codepen.io/editor/ikaroskappler/pen/01a0e42a-8937-7788-b8ca-c66a8de53cc4 "Codepen"))
50
62
  - configuration of the canvas behavior
51
63
  - fullsize and auto-resizing
52
64
  - enable/disable mouse, touch or keyboard interaction
@@ -587,6 +599,7 @@ new MouseHandler(document.getElementById("mycanvas"))
587
599
  - Mathworld for the [Apollonius math](https://mathworld.wolfram.com/ApolloniusProblem.html)
588
600
  - Mathworld for the [Homothetic center math](https://mathworld.wolfram.com/HomotheticCenter.html)
589
601
  - cut-the-knot.org for the [Radical Axis calculation](https://www.cut-the-knot.org/Curriculum/Geometry/GeoGebra/RadicalAxes.shtml)
602
+ - bitbanging.space with the excellent explanation for [Lloyd's algorithm](https://www.bitbanging.space/posts/lloyds-algorithm)
590
603
 
591
604
  ## Todos
592
605
 
package/dist/index.esm.js CHANGED
@@ -1568,7 +1568,7 @@ const geomutils = {
1568
1568
  * @modified 2025-04-13 Adding the `Vertex.move(amount: XYCoords)` method (does the same as `add`, added by naming convention).
1569
1569
  * @modified 2025-05-07 Class `Vertex` is now implementing interface `IBounded` (to meet convention).
1570
1570
  * @modified 2026-06-10 Adding methods `Vertex.findClosestPoint` and `Vertex.findFarestPoint`.
1571
- * @version 2.12.0
1571
+ * @version 2.12.1
1572
1572
  *
1573
1573
  * @file Vertex
1574
1574
  * @public
@@ -2039,7 +2039,7 @@ class Vertex$1 {
2039
2039
  * around given center.
2040
2040
  *
2041
2041
  * @method rotate
2042
- * @param {number} angle - The angle to 'rotate' this vertex; 0.0 means no change.
2042
+ * @param {number} angle - The angle in radians to 'rotate' this vertex; 0.0 means no change.
2043
2043
  * @param {XYCoords=} center - The center of rotation; default is (0,0).
2044
2044
  * @return {Vertex} this
2045
2045
  * @instance
@@ -2283,8 +2283,9 @@ Vertex$1.utils = {
2283
2283
  * @modified 2025-04-15 Changed param of `VertTuple.moveTo` method from `Vertex` to `XYCoords`.
2284
2284
  * @modified 2025-04-15 Added method `VertTuple.move` method.
2285
2285
  * @modified 2026-06-10 Adding helper function `VertTuple.utils.calcCircumcircle`.
2286
- * @modified 2026-06-17 Adding method `VertTuple.asLine` for converting Vector to Line instances.
2287
- * @version 1.6.0
2286
+ * @modified 2026-06-17 Adding method `VertTuple.asLine` for converting TertTuples to Line instances.
2287
+ * @modified 2026-09-21 Adding method `VertTuple.asVector` for converting TertTuples to Vector instances.
2288
+ * @version 1.7.0
2288
2289
  */
2289
2290
  /**
2290
2291
  * @classdesc An abstract base classes for vertex tuple constructs, like Lines or Vectors.
@@ -2577,16 +2578,27 @@ class VertTuple {
2577
2578
  return this.factory(this.a.clone(), this.b.clone());
2578
2579
  }
2579
2580
  /**
2580
- * Converts this `Vector` to a `Line` (segment).
2581
+ * Converts this `VertTuple` to a `Line` (segment).
2581
2582
  *
2582
2583
  * @method asLine
2583
- * @return {T} A type safe clone if this instance.
2584
+ * @return {Line} This tuple as `Line` instance.
2584
2585
  * @instance
2585
2586
  * @memberof VertTuple
2586
2587
  **/
2587
2588
  asLine() {
2588
2589
  return new Line(this.a, this.b);
2589
2590
  }
2591
+ /**
2592
+ * Converts this `VertTuple` to a `Vector` (arrow).
2593
+ *
2594
+ * @method asVector
2595
+ * @return {Line} This tuple as `Vector` instance.
2596
+ * @instance
2597
+ * @memberof VertTuple
2598
+ **/
2599
+ asVector() {
2600
+ return new Vector(this.a, this.b);
2601
+ }
2590
2602
  /**
2591
2603
  * Create a string representation of this line.
2592
2604
  *
@@ -3108,7 +3120,9 @@ class Line extends VertTuple {
3108
3120
  * @modified 2025-05-16 Class `Polygon` now implements `IBounded`.
3109
3121
  * @modified 2025-05-20 Tweaking `Polygon.getInnerAngleAt` and `Polygo.isAngleAcute` to handle indices out of array bounds as well.
3110
3122
  * @modified 2025-06-07 Adding `Polygon.closestLineIntersectionIndex` to determine line intersections plus detected edge index.
3111
- * @version 1.16.0
3123
+ * @modified 2026-09-16 Adding a `forceClockwise` parameter to the `Polygon.getCentroid()` method.
3124
+ * @modified 2026-09-21 Adding `Polygon.revert` method to change the winding order.
3125
+ * @version 1.17.0
3112
3126
  *
3113
3127
  * @file Polygon
3114
3128
  * @public
@@ -3402,6 +3416,20 @@ class Polygon {
3402
3416
  // return Polygon.utils.signedArea(this.vertices) < 0;
3403
3417
  return Polygon.utils.isClockwise(this.vertices);
3404
3418
  }
3419
+ /**
3420
+ * Revert the order of this polygon's vertices to change the winding order.
3421
+ * This operation is in-place.
3422
+ *
3423
+ * @method revert
3424
+ * @instance
3425
+ * @memberof Polygon
3426
+ * @return {Polygon} This for chaining.
3427
+ */
3428
+ revert() {
3429
+ // this.vertices.slice().reverse(); // Copy?
3430
+ this.vertices.reverse();
3431
+ return this;
3432
+ }
3405
3433
  /**
3406
3434
  * Get the perimeter of this polygon.
3407
3435
  * The perimeter is the absolute length of the outline.
@@ -3483,35 +3511,37 @@ class Polygon {
3483
3511
  }
3484
3512
  /**
3485
3513
  * Get centroid.
3486
- * Centroids define the barycenter of any non self-intersecting convex polygon.
3514
+ * Centroids define the barycenter of any non self-intersecting convex clockwise polygon.
3487
3515
  *
3488
- * If the polygon is self intersecting or non konvex then the barycenter is not well defined.
3516
+ * If the polygon is self intersecting or non convex or not clockwise then the barycenter is not well defined.
3489
3517
  *
3490
3518
  * https://mathworld.wolfram.com/PolygonCentroid.html
3491
3519
  *
3492
3520
  * @method getCentroid
3493
3521
  * @instance
3522
+ * @param {boolean} forceClockwise - [optiona] If set to true then the centroid will be calculated for the clockwise polygon.
3494
3523
  * @memberof Polygon
3495
3524
  * @returns {Vertex|null}
3496
3525
  */
3497
- getCentroid() {
3526
+ getCentroid(forceClockwise) {
3498
3527
  if (this.vertices.length === 0) {
3499
3528
  return null;
3500
3529
  }
3501
- const center = new Vertex$1(0.0, 0.0);
3502
- const n = this.vertices.length;
3503
- for (var i = 0; i < n; i++) {
3504
- // center.add(this.vertices[i]);
3505
- const cur = this.vertices[i];
3506
- const next = this.vertices[(i + 1) % n];
3507
- var factor = cur.x * next.y - next.x * cur.y;
3508
- center.x += (cur.x + next.x) * factor;
3509
- center.y += (cur.y + next.y) * factor;
3510
- }
3511
- const area = this.area();
3512
- center.x *= 1 / (6 * area);
3513
- center.y *= 1 / (6 * area);
3514
- return center;
3530
+ // const centroid: Vertex = new Vertex(0.0, 0.0);
3531
+ // const n = this.vertices.length;
3532
+ // for (var i = 0; i < n; i++) {
3533
+ // // center.add(this.vertices[i]);
3534
+ // const cur: Vertex = this.vertices[i];
3535
+ // const next: Vertex = this.vertices[(i + 1) % n];
3536
+ // var factor: number = cur.x * next.y - next.x * cur.y;
3537
+ // centroid.x += (cur.x + next.x) * factor;
3538
+ // centroid.y += (cur.y + next.y) * factor;
3539
+ // }
3540
+ // const area = this.area();
3541
+ // centroid.x *= 1 / (6 * area);
3542
+ // centroid.y *= 1 / (6 * area);
3543
+ // return centroid;
3544
+ return Polygon.utils.calculateCentroid(this.vertices, forceClockwise);
3515
3545
  }
3516
3546
  //--- BEGIN --- Implement interface `Intersectable`
3517
3547
  /**
@@ -3936,6 +3966,26 @@ Polygon.utils = {
3936
3966
  isClockwise(vertices) {
3937
3967
  return Polygon.utils.signedArea(vertices) < 0;
3938
3968
  },
3969
+ calculateCentroid(vertices, forceClockwise) {
3970
+ const centroid = new Vertex$1(0.0, 0.0);
3971
+ const n = vertices.length;
3972
+ if (forceClockwise && !Polygon.utils.isClockwise(vertices)) {
3973
+ return Polygon.utils.calculateCentroid(vertices.slice().reverse());
3974
+ }
3975
+ for (var i = 0; i < n; i++) {
3976
+ // center.add(this.vertices[i]);
3977
+ const cur = vertices[i];
3978
+ const next = vertices[(i + 1) % n];
3979
+ var factor = cur.x * next.y - next.x * cur.y;
3980
+ centroid.x += (cur.x + next.x) * factor;
3981
+ centroid.y += (cur.y + next.y) * factor;
3982
+ }
3983
+ // const area = this.area();
3984
+ const area = Polygon.utils.area(vertices);
3985
+ centroid.x *= 1 / (6 * area);
3986
+ centroid.y *= 1 / (6 * area);
3987
+ return centroid;
3988
+ },
3939
3989
  /**
3940
3990
  * Calulate the signed polyon area by interpreting the polygon as a matrix
3941
3991
  * and calculating its determinant.
@@ -19362,7 +19412,8 @@ class Delaunay {
19362
19412
  * @modified 2020-08-12 Ported this class from vanilla JS to TypeScript.
19363
19413
  * @modified 2020-08-17 Added some missing type declarations.
19364
19414
  * @modified 2021-01-20 Members `triangles` and `sharedVertex` are now public.
19365
- * @version 1.1.3
19415
+ * @modified 2026-09-15 Added the `VoronoiCell.sharedVertexIndex` attribute.
19416
+ * @version 1.2.0
19366
19417
  *
19367
19418
  * @file VoronoiCell
19368
19419
  * @public
@@ -19378,15 +19429,15 @@ class VoronoiCell {
19378
19429
  * @param {Vertex} sharedVertex This is the 'center' of the voronoi cell; all triangles must share
19379
19430
  * that vertex.
19380
19431
  **/
19381
- constructor(triangles, sharedVertex) {
19382
- if (typeof triangles === 'undefined')
19432
+ constructor(triangles, sharedVertex, sharedVertexIndex) {
19433
+ if (typeof triangles === "undefined")
19383
19434
  triangles = [];
19384
- if (typeof sharedVertex === 'undefined')
19435
+ if (typeof sharedVertex === "undefined")
19385
19436
  sharedVertex = new Vertex$1(0, 0);
19386
19437
  this.triangles = triangles;
19387
19438
  this.sharedVertex = sharedVertex;
19439
+ this.sharedVertexIndex = sharedVertexIndex;
19388
19440
  }
19389
- ;
19390
19441
  /**
19391
19442
  * Check if the first and the last triangle in the path are NOT connected.
19392
19443
  *
@@ -19399,7 +19450,6 @@ class VoronoiCell {
19399
19450
  // There must be at least three triangles
19400
19451
  return this.triangles.length < 3 || !this.triangles[0].isAdjacent(this.triangles[this.triangles.length - 1]);
19401
19452
  }
19402
- ;
19403
19453
  /**
19404
19454
  * Convert this Voronoi cell to a path polygon, consisting of all Voronoi cell corner points.
19405
19455
  *
@@ -19414,7 +19464,32 @@ class VoronoiCell {
19414
19464
  toPolygon() {
19415
19465
  return new Polygon(this.toPathArray(), this.isOpen());
19416
19466
  }
19417
- ;
19467
+ /**
19468
+ * Get all 'umbrella' triangles for this Voronoi cell.
19469
+ *
19470
+ * The 'umbrella' is that sequence of triangles that covers the whole Voronoi cell and
19471
+ * meet in the cell's centroid.
19472
+ *
19473
+ * @method getUmbrellaTriangles
19474
+ * @instance
19475
+ * @memberof VoronoiCell
19476
+ * @return {Array<Triangle>}
19477
+ **/
19478
+ getUmbrellaTriangles() {
19479
+ var tris = [];
19480
+ // for (var i = 0; i < this.triangles.length; i++) {
19481
+ // var delaunayTri = this.triangles[i];
19482
+ // var tri = new Triangle(this.sharedVertex, delaunayTri.b, delaunayTri.c);
19483
+ // tris.push(tri);
19484
+ // }
19485
+ var vertices = this.toPathArray();
19486
+ var n = vertices.length;
19487
+ for (var i = 0; i < n; i++) {
19488
+ var tri = new Triangle(this.sharedVertex, vertices[i], vertices[(i + 1) % n]);
19489
+ tris.push(tri);
19490
+ }
19491
+ return tris;
19492
+ }
19418
19493
  /**
19419
19494
  * Convert the voronoi cell path data to an SVG polygon data string.
19420
19495
  *
@@ -19429,9 +19504,12 @@ class VoronoiCell {
19429
19504
  if (this.triangles.length == 0)
19430
19505
  return "";
19431
19506
  const arr = this.toPathArray();
19432
- return arr.map((vert) => { return '' + vert.x + ',' + vert.y; }).join(' ');
19507
+ return arr
19508
+ .map((vert) => {
19509
+ return "" + vert.x + "," + vert.y;
19510
+ })
19511
+ .join(" ");
19433
19512
  }
19434
- ;
19435
19513
  /**
19436
19514
  * Convert the voronoi cell path data to an array.
19437
19515
  *
@@ -19483,7 +19561,6 @@ class VoronoiCell {
19483
19561
  const openEdgePoint = new Vertex$1(perpendicular.x + (center.x - perpendicular.x) * 1000, perpendicular.y + (center.y - perpendicular.y) * 1000);
19484
19562
  return openEdgePoint;
19485
19563
  }
19486
- ;
19487
19564
  /**
19488
19565
  * A helper function.
19489
19566
  *
@@ -19507,13 +19584,12 @@ class VoronoiCell {
19507
19584
  return tri.a;
19508
19585
  }
19509
19586
  // Here:
19510
- // tri.c.equals(sharedVertex)
19587
+ // tri.c.equals(sharedVertex)
19511
19588
  if (neighbour.a.equals(tri.a) || neighbour.b.equals(tri.a) || neighbour.c.equals(tri.a))
19512
19589
  return tri.b;
19513
19590
  else
19514
19591
  return tri.a;
19515
19592
  }
19516
- ;
19517
19593
  }
19518
19594
 
19519
19595
  /**
@@ -19521,7 +19597,8 @@ class VoronoiCell {
19521
19597
  * @date 2018-04-07
19522
19598
  * @modified 2018-04-11 Using VoronoiCells now (was array before).
19523
19599
  * @modified 2020-08-15 Ported from vanilla JS to TypeScript.
19524
- * @version 1.0.2
19600
+ * @modified 2026-09-15 Added the `sharedVertexIndex` attribute to each Voronoi cell.
19601
+ * @version 1.1.0
19525
19602
  **/
19526
19603
  /**
19527
19604
  * @classdesc Create the voronoi diagram from the given delaunay triangulation (they are dual graphs).
@@ -19536,13 +19613,12 @@ class delaunay2voronoi {
19536
19613
  this.pointList = pointList;
19537
19614
  this.triangles = triangles;
19538
19615
  }
19539
- ;
19540
19616
  // +---------------------------------------------------------------------------------
19541
19617
  // | Convert the triangle set to the Voronoi diagram.
19542
19618
  // +-------------------------------
19543
19619
  build() {
19544
19620
  const voronoiDiagram = [];
19545
- for (var p in this.pointList) {
19621
+ for (var p = 0; p < this.pointList.length; p++) {
19546
19622
  var point = this.pointList[p];
19547
19623
  // Find adjacent triangles for first point
19548
19624
  var adjacentSubset = [];
@@ -19551,12 +19627,12 @@ class delaunay2voronoi {
19551
19627
  adjacentSubset.push(this.triangles[t]);
19552
19628
  }
19553
19629
  var path = this.subsetToPath(adjacentSubset);
19554
- if (path) // There may be errors
19555
- voronoiDiagram.push(new VoronoiCell(path, point));
19630
+ if (path)
19631
+ // There may be errors
19632
+ voronoiDiagram.push(new VoronoiCell(path, point, p));
19556
19633
  }
19557
19634
  return voronoiDiagram;
19558
19635
  }
19559
- ;
19560
19636
  // +---------------------------------------------------------------------------------
19561
19637
  // | Re-order a tiangle subset so the triangle define a single path.
19562
19638
  // |
@@ -19569,7 +19645,7 @@ class delaunay2voronoi {
19569
19645
  subsetToPath(triangleSet, startPosition, tryOnce) {
19570
19646
  if (triangleSet.length == 0)
19571
19647
  return [];
19572
- if (typeof startPosition === 'undefined')
19648
+ if (typeof startPosition === "undefined")
19573
19649
  startPosition = 0;
19574
19650
  let t = startPosition;
19575
19651
  const result = [triangleSet[t]];
@@ -19610,8 +19686,7 @@ class delaunay2voronoi {
19610
19686
  return result;
19611
19687
  }
19612
19688
  }
19613
- ;
19614
- }
19689
+ } // END delaunay2voronoi
19615
19690
 
19616
19691
  /**
19617
19692
  * @requires Line