@myoc/math 0.19.521 → 0.19.522

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 (153) hide show
  1. package/dist/dev/index.js +261 -92
  2. package/dist/dev/index.js.map +4 -4
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/src/colors.d.ts +14 -0
  5. package/dist/types/common/src/constants.d.ts +3 -0
  6. package/dist/types/common/src/keys.d.ts +2 -0
  7. package/dist/types/common/src/points.d.ts +1 -1
  8. package/dist/types/common/src/utils.d.ts +1 -1
  9. package/dist/types/element/src/Scene.d.ts +1 -1
  10. package/dist/types/element/src/align.d.ts +2 -2
  11. package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
  12. package/dist/types/element/src/arrows/focus.d.ts +5 -2
  13. package/dist/types/element/src/binding.d.ts +17 -8
  14. package/dist/types/element/src/bounds.d.ts +5 -9
  15. package/dist/types/element/src/bucketFill.d.ts +110 -0
  16. package/dist/types/element/src/collision.d.ts +1 -1
  17. package/dist/types/element/src/comparisons.d.ts +4 -4
  18. package/dist/types/element/src/convertToShape.d.ts +23 -0
  19. package/dist/types/element/src/distribute.d.ts +2 -2
  20. package/dist/types/element/src/dragElements.d.ts +27 -0
  21. package/dist/types/element/src/duplicate.d.ts +3 -3
  22. package/dist/types/element/src/embeddable.d.ts +2 -2
  23. package/dist/types/element/src/flowchart.d.ts +7 -7
  24. package/dist/types/element/src/fractionalIndex.d.ts +2 -2
  25. package/dist/types/element/src/frame.d.ts +4 -4
  26. package/dist/types/element/src/groups.d.ts +9 -9
  27. package/dist/types/element/src/index.d.ts +4 -1
  28. package/dist/types/element/src/linearElementEditor.d.ts +17 -10
  29. package/dist/types/element/src/newElement.d.ts +13 -0
  30. package/dist/types/element/src/renderElement.d.ts +0 -3
  31. package/dist/types/element/src/resizeElements.d.ts +2 -2
  32. package/dist/types/element/src/selection.d.ts +5 -5
  33. package/dist/types/element/src/shape.d.ts +12 -0
  34. package/dist/types/element/src/sortElements.d.ts +10 -0
  35. package/dist/types/element/src/textElement.d.ts +12 -9
  36. package/dist/types/element/src/transform.d.ts +2 -2
  37. package/dist/types/element/src/typeChecks.d.ts +25 -25
  38. package/dist/types/element/src/types.d.ts +2 -1
  39. package/dist/types/element/src/zindex.d.ts +2 -2
  40. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  41. package/dist/types/excalidraw/actions/actionBoundText.d.ts +24 -8
  42. package/dist/types/excalidraw/actions/actionCanvas.d.ts +128 -961
  43. package/dist/types/excalidraw/actions/actionClipboard.d.ts +24 -8
  44. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +12 -4
  45. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +38 -13
  46. package/dist/types/excalidraw/actions/actionDeselect.d.ts +9 -4
  47. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
  48. package/dist/types/excalidraw/actions/actionElementLink.d.ts +12 -4
  49. package/dist/types/excalidraw/actions/actionElementLock.d.ts +25 -9
  50. package/dist/types/excalidraw/actions/actionExport.d.ts +26 -10
  51. package/dist/types/excalidraw/actions/actionFrame.d.ts +47 -205
  52. package/dist/types/excalidraw/actions/actionGroup.d.ts +39 -23
  53. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -6
  54. package/dist/types/excalidraw/actions/actionLink.d.ts +13 -5
  55. package/dist/types/excalidraw/actions/actionMenu.d.ts +12 -4
  56. package/dist/types/excalidraw/actions/actionProperties.d.ts +43 -24
  57. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +17 -9
  58. package/dist/types/excalidraw/actions/actionStyles.d.ts +12 -4
  59. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +1 -1
  60. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +14 -6
  61. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +16 -9
  62. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +13 -5
  63. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -5
  64. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +16 -9
  65. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -5
  66. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +14 -6
  67. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -5
  68. package/dist/types/excalidraw/actions/index.d.ts +1 -2
  69. package/dist/types/excalidraw/actions/manager.d.ts +1 -0
  70. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  71. package/dist/types/excalidraw/actions/types.d.ts +8 -4
  72. package/dist/types/excalidraw/appState.d.ts +10 -5
  73. package/dist/types/excalidraw/components/Actions.d.ts +17 -12
  74. package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
  75. package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
  76. package/dist/types/excalidraw/components/App.cursor.d.ts +30 -0
  77. package/dist/types/excalidraw/components/App.d.ts +384 -60
  78. package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
  79. package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
  80. package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
  81. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
  82. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
  83. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +3 -1
  84. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
  85. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
  86. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
  87. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
  88. package/dist/types/excalidraw/components/ColorPicker/topPicksDnD.d.ts +31 -0
  89. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
  90. package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
  91. package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
  92. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  93. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
  94. package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
  95. package/dist/types/excalidraw/components/LockButton.d.ts +9 -0
  96. package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
  97. package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
  98. package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
  99. package/dist/types/excalidraw/components/Popover.d.ts +1 -3
  100. package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
  101. package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
  102. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
  103. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
  104. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
  105. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
  106. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
  107. package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
  108. package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
  109. package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
  110. package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
  111. package/dist/types/excalidraw/components/Tools.d.ts +146 -0
  112. package/dist/types/excalidraw/components/UserList.d.ts +3 -2
  113. package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
  114. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -0
  115. package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
  116. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
  117. package/dist/types/excalidraw/components/icons.d.ts +4 -1
  118. package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
  119. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
  120. package/dist/types/excalidraw/context/tunnels.d.ts +0 -1
  121. package/dist/types/excalidraw/data/blob.d.ts +14 -6
  122. package/dist/types/excalidraw/data/index.d.ts +4 -4
  123. package/dist/types/excalidraw/data/json.d.ts +20 -12
  124. package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
  125. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  126. package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
  127. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +10 -3
  128. package/dist/types/excalidraw/scene/Renderer.d.ts +11 -11
  129. package/dist/types/excalidraw/scene/export.d.ts +3 -3
  130. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  131. package/dist/types/excalidraw/scene/types.d.ts +4 -3
  132. package/dist/types/excalidraw/snapping.d.ts +7 -7
  133. package/dist/types/excalidraw/types.d.ts +423 -27
  134. package/dist/types/excalidraw/viewport.d.ts +283 -0
  135. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +2 -3
  136. package/dist/types/laser-pointer/src/state.d.ts +1 -0
  137. package/dist/types/math/src/index.d.ts +1 -0
  138. package/dist/types/math/src/pca.d.ts +79 -0
  139. package/dist/types/math/src/polygon.d.ts +25 -1
  140. package/dist/types/utils/src/export.d.ts +3 -3
  141. package/package.json +2 -2
  142. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -180
  143. package/dist/types/excalidraw/actions/actionSmartZoom.d.ts +0 -16
  144. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +0 -27
  145. package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +0 -7
  146. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
  147. package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
  148. package/dist/types/excalidraw/components/MagicButton.d.ts +0 -10
  149. package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -12
  150. package/dist/types/excalidraw/cursor.d.ts +0 -5
  151. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  152. package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
  153. package/dist/types/excalidraw/scroll.d.ts +0 -46
package/dist/dev/index.js CHANGED
@@ -344,7 +344,7 @@ function curveClosestPoint(c, p, tolerance = 1e-3) {
344
344
  t1,
345
345
  (t) => pointDistance(p, bezierEquation(c, t))
346
346
  );
347
- if (!solution) {
347
+ if (solution == null) {
348
348
  return null;
349
349
  }
350
350
  return bezierEquation(c, solution);
@@ -352,7 +352,7 @@ function curveClosestPoint(c, p, tolerance = 1e-3) {
352
352
  function curvePointDistance(c, p) {
353
353
  const closest = curveClosestPoint(c, p);
354
354
  if (!closest) {
355
- return 0;
355
+ return Infinity;
356
356
  }
357
357
  return pointDistance(p, closest);
358
358
  }
@@ -638,6 +638,252 @@ function linesIntersectAt(a, b) {
638
638
  return null;
639
639
  }
640
640
 
641
+ // src/pca.ts
642
+ function centroid(points) {
643
+ let cx = 0;
644
+ let cy = 0;
645
+ for (const [x, y] of points) {
646
+ cx += x;
647
+ cy += y;
648
+ }
649
+ return pointFrom(cx / points.length, cy / points.length);
650
+ }
651
+ function principalAxes(points) {
652
+ if (points.length < 2) {
653
+ console.error("Degenerate point set: at least two points are required");
654
+ }
655
+ const c = centroid(points);
656
+ let m20 = 0;
657
+ let m02 = 0;
658
+ let m11 = 0;
659
+ for (const [x, y] of points) {
660
+ const dx = x - c[0];
661
+ const dy = y - c[1];
662
+ m20 += dx * dx;
663
+ m02 += dy * dy;
664
+ m11 += dx * dy;
665
+ }
666
+ m20 /= points.length;
667
+ m02 /= points.length;
668
+ m11 /= points.length;
669
+ const trace = m20 + m02;
670
+ const diff = Math.hypot(m20 - m02, 2 * m11);
671
+ const majorVariance = (trace + diff) / 2;
672
+ const minorVariance = (trace - diff) / 2;
673
+ let major;
674
+ if (Math.abs(m11) > Number.EPSILON) {
675
+ major = vectorNormalize(vector(majorVariance - m02, m11));
676
+ } else {
677
+ major = m20 >= m02 ? vector(1, 0) : vector(0, 1);
678
+ }
679
+ return {
680
+ centroid: c,
681
+ major,
682
+ minor: vectorNormal(major),
683
+ majorVariance,
684
+ minorVariance
685
+ };
686
+ }
687
+ function principalCoords(points, axes, scale = 1) {
688
+ const { centroid: c, major, minor } = axes;
689
+ return points.map(([x, y]) => {
690
+ const dx = x - c[0];
691
+ const dy = y - c[1];
692
+ return [
693
+ (dx * major[0] + dy * major[1]) * scale,
694
+ (dx * minor[0] + dy * minor[1]) * scale
695
+ ];
696
+ });
697
+ }
698
+ function orientPrincipalAxes(points, axes) {
699
+ const u = principalCoords(points, axes).map(([uu]) => uu);
700
+ if (skewness(u) <= 0) {
701
+ return axes;
702
+ }
703
+ const major = vectorScale(axes.major, -1);
704
+ return { ...axes, major, minor: vectorNormal(major) };
705
+ }
706
+ function elongation(axes) {
707
+ return axes.majorVariance > 0 ? axes.minorVariance / axes.majorVariance : 1;
708
+ }
709
+ function standardizedMoment(values, order) {
710
+ const n = values.length;
711
+ let mean = 0;
712
+ for (const v of values) {
713
+ mean += v;
714
+ }
715
+ mean /= n;
716
+ let variance = 0;
717
+ let moment = 0;
718
+ for (const v of values) {
719
+ const d = v - mean;
720
+ variance += d * d;
721
+ moment += d ** order;
722
+ }
723
+ variance /= n;
724
+ moment /= n;
725
+ const sigma = Math.sqrt(variance);
726
+ return sigma > Number.EPSILON ? moment / sigma ** order : 0;
727
+ }
728
+ function skewness(values) {
729
+ return standardizedMoment(values, 3);
730
+ }
731
+ function kurtosis(values) {
732
+ return standardizedMoment(values, 4);
733
+ }
734
+
735
+ // src/polygon.ts
736
+ function polygon(...points) {
737
+ return polygonClose(points);
738
+ }
739
+ function polygonFromPoints(points) {
740
+ return polygonClose(points);
741
+ }
742
+ var polygonIncludesPoint = (point, polygon2) => {
743
+ const x = point[0];
744
+ const y = point[1];
745
+ let inside = false;
746
+ for (let i = 0, j = polygon2.length - 1; i < polygon2.length; j = i++) {
747
+ const xi = polygon2[i][0];
748
+ const yi = polygon2[i][1];
749
+ const xj = polygon2[j][0];
750
+ const yj = polygon2[j][1];
751
+ if ((yi > y && yj <= y || yi <= y && yj > y) && x < (xj - xi) * (y - yi) / (yj - yi) + xi) {
752
+ inside = !inside;
753
+ }
754
+ }
755
+ return inside;
756
+ };
757
+ var polygonIncludesPointNonZero = (point, polygon2) => {
758
+ const [x, y] = point;
759
+ let windingNumber = 0;
760
+ for (let i = 0; i < polygon2.length; i++) {
761
+ const j = (i + 1) % polygon2.length;
762
+ const [xi, yi] = polygon2[i];
763
+ const [xj, yj] = polygon2[j];
764
+ if (yi <= y) {
765
+ if (yj > y) {
766
+ if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) > 0) {
767
+ windingNumber++;
768
+ }
769
+ }
770
+ } else if (yj <= y) {
771
+ if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) < 0) {
772
+ windingNumber--;
773
+ }
774
+ }
775
+ }
776
+ return windingNumber !== 0;
777
+ };
778
+ function polygonClose(polygon2) {
779
+ return polygonIsClosed(polygon2) ? polygon2 : [...polygon2, polygon2[0]];
780
+ }
781
+ function polygonIsClosed(polygon2, tolerance = PRECISION) {
782
+ return pointsEqual(polygon2[0], polygon2[polygon2.length - 1], tolerance);
783
+ }
784
+ function polygonSignedArea(polygon2, tolerance = PRECISION) {
785
+ const pts = polygonIsClosed(polygon2, tolerance) ? polygon2.slice(0, -1) : polygon2;
786
+ let sum = 0;
787
+ for (let i = 0, j = pts.length - 1; i < pts.length; j = i++) {
788
+ sum += pts[j][0] * pts[i][1] - pts[i][0] * pts[j][1];
789
+ }
790
+ return sum / 2;
791
+ }
792
+ function polygonArea(polygon2, tolerance = PRECISION) {
793
+ return Math.abs(polygonSignedArea(polygon2, tolerance));
794
+ }
795
+ function convexHull(points) {
796
+ if (points.length < 3) {
797
+ return [...points];
798
+ }
799
+ const sorted = [...points].sort(
800
+ (a, b) => a[0] === b[0] ? a[1] - b[1] : a[0] - b[0]
801
+ );
802
+ const cross = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
803
+ const half = (pts) => {
804
+ const chain = [];
805
+ for (const p of pts) {
806
+ while (chain.length >= 2 && cross(chain[chain.length - 2], chain[chain.length - 1], p) <= 0) {
807
+ chain.pop();
808
+ }
809
+ chain.push(p);
810
+ }
811
+ chain.pop();
812
+ return chain;
813
+ };
814
+ const hull = [...half(sorted), ...half([...sorted].reverse())];
815
+ return hull.length >= 3 ? hull : [...points];
816
+ }
817
+ function simplifyConvexPolygon(polygon2, angleThreshold) {
818
+ if (polygon2.length < 3) {
819
+ return [...polygon2];
820
+ }
821
+ const turnAt = (i) => {
822
+ const prev = polygon2[(i - 1 + polygon2.length) % polygon2.length];
823
+ const curr = polygon2[i];
824
+ const next = polygon2[(i + 1) % polygon2.length];
825
+ const inAngle = Math.atan2(curr[1] - prev[1], curr[0] - prev[0]);
826
+ const outAngle = Math.atan2(next[1] - curr[1], next[0] - curr[0]);
827
+ return Math.abs(normalizeTurn(outAngle - inAngle));
828
+ };
829
+ let start = 0;
830
+ for (let i = 1; i < polygon2.length; i++) {
831
+ if (turnAt(i) > turnAt(start)) {
832
+ start = i;
833
+ }
834
+ }
835
+ const simplified = [];
836
+ let accumulated = 0;
837
+ for (let k = 0; k < polygon2.length; k++) {
838
+ const i = (start + k) % polygon2.length;
839
+ accumulated += turnAt(i);
840
+ if (accumulated >= angleThreshold) {
841
+ simplified.push(polygon2[i]);
842
+ accumulated = 0;
843
+ }
844
+ }
845
+ return simplified.length >= 3 ? simplified : [...polygon2];
846
+ }
847
+ function normalizeTurn(angle) {
848
+ let a = angle;
849
+ while (a > Math.PI) {
850
+ a -= 2 * Math.PI;
851
+ }
852
+ while (a < -Math.PI) {
853
+ a += 2 * Math.PI;
854
+ }
855
+ return a;
856
+ }
857
+
858
+ // src/range.ts
859
+ import { toBrandedType } from "@excalidraw/common";
860
+ function rangeInclusive(start, end) {
861
+ return toBrandedType([start, end]);
862
+ }
863
+ function rangeInclusiveFromPair(pair) {
864
+ return toBrandedType(pair);
865
+ }
866
+ var rangesOverlap = ([a0, a1], [b0, b1]) => {
867
+ if (a0 <= b0) {
868
+ return a1 >= b0;
869
+ }
870
+ if (a0 >= b0) {
871
+ return b1 >= a0;
872
+ }
873
+ return false;
874
+ };
875
+ var rangeIntersection = ([a0, a1], [b0, b1]) => {
876
+ const rangeStart = Math.max(a0, b0);
877
+ const rangeEnd = Math.min(a1, b1);
878
+ if (rangeStart <= rangeEnd) {
879
+ return toBrandedType([rangeStart, rangeEnd]);
880
+ }
881
+ return null;
882
+ };
883
+ var rangeIncludesValue = (value, [min, max]) => {
884
+ return value >= min && value <= max;
885
+ };
886
+
641
887
  // src/segment.ts
642
888
  function lineSegment(a, b) {
643
889
  return [a, b];
@@ -727,95 +973,6 @@ function lineSegmentsDistance(s1, s2) {
727
973
  );
728
974
  }
729
975
 
730
- // src/polygon.ts
731
- function polygon(...points) {
732
- return polygonClose(points);
733
- }
734
- function polygonFromPoints(points) {
735
- return polygonClose(points);
736
- }
737
- var polygonIncludesPoint = (point, polygon2) => {
738
- const x = point[0];
739
- const y = point[1];
740
- let inside = false;
741
- for (let i = 0, j = polygon2.length - 1; i < polygon2.length; j = i++) {
742
- const xi = polygon2[i][0];
743
- const yi = polygon2[i][1];
744
- const xj = polygon2[j][0];
745
- const yj = polygon2[j][1];
746
- if ((yi > y && yj <= y || yi <= y && yj > y) && x < (xj - xi) * (y - yi) / (yj - yi) + xi) {
747
- inside = !inside;
748
- }
749
- }
750
- return inside;
751
- };
752
- var polygonIncludesPointNonZero = (point, polygon2) => {
753
- const [x, y] = point;
754
- let windingNumber = 0;
755
- for (let i = 0; i < polygon2.length; i++) {
756
- const j = (i + 1) % polygon2.length;
757
- const [xi, yi] = polygon2[i];
758
- const [xj, yj] = polygon2[j];
759
- if (yi <= y) {
760
- if (yj > y) {
761
- if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) > 0) {
762
- windingNumber++;
763
- }
764
- }
765
- } else if (yj <= y) {
766
- if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) < 0) {
767
- windingNumber--;
768
- }
769
- }
770
- }
771
- return windingNumber !== 0;
772
- };
773
- var pointOnPolygon = (p, poly, threshold = PRECISION) => {
774
- let on = false;
775
- for (let i = 0, l = poly.length - 1; i < l; i++) {
776
- if (pointOnLineSegment(p, lineSegment(poly[i], poly[i + 1]), threshold)) {
777
- on = true;
778
- break;
779
- }
780
- }
781
- return on;
782
- };
783
- function polygonClose(polygon2) {
784
- return polygonIsClosed(polygon2) ? polygon2 : [...polygon2, polygon2[0]];
785
- }
786
- function polygonIsClosed(polygon2) {
787
- return pointsEqual(polygon2[0], polygon2[polygon2.length - 1]);
788
- }
789
-
790
- // src/range.ts
791
- import { toBrandedType } from "@excalidraw/common";
792
- function rangeInclusive(start, end) {
793
- return toBrandedType([start, end]);
794
- }
795
- function rangeInclusiveFromPair(pair) {
796
- return toBrandedType(pair);
797
- }
798
- var rangesOverlap = ([a0, a1], [b0, b1]) => {
799
- if (a0 <= b0) {
800
- return a1 >= b0;
801
- }
802
- if (a0 >= b0) {
803
- return b1 >= a0;
804
- }
805
- return false;
806
- };
807
- var rangeIntersection = ([a0, a1], [b0, b1]) => {
808
- const rangeStart = Math.max(a0, b0);
809
- const rangeEnd = Math.min(a1, b1);
810
- if (rangeStart <= rangeEnd) {
811
- return toBrandedType([rangeStart, rangeEnd]);
812
- }
813
- return null;
814
- };
815
- var rangeIncludesValue = (value, [min, max]) => {
816
- return value >= min && value <= max;
817
- };
818
-
819
976
  // src/rectangle.ts
820
977
  function rectangle(topLeft, bottomRight) {
821
978
  return [topLeft, bottomRight];
@@ -852,7 +1009,9 @@ export {
852
1009
  average,
853
1010
  bezierEquation,
854
1011
  cartesian2Polar,
1012
+ centroid,
855
1013
  clamp,
1014
+ convexHull,
856
1015
  curve,
857
1016
  curveCatmullRomCubicApproxPoints,
858
1017
  curveCatmullRomQuadraticApproxPoints,
@@ -872,6 +1031,7 @@ export {
872
1031
  ellipseLineIntersectionPoints,
873
1032
  ellipseSegmentInterceptPoints,
874
1033
  ellipseTouchesPoint,
1034
+ elongation,
875
1035
  isCloseTo,
876
1036
  isCurve,
877
1037
  isFiniteNumber,
@@ -881,6 +1041,7 @@ export {
881
1041
  isRightAngleRads,
882
1042
  isValidPoint,
883
1043
  isVector,
1044
+ kurtosis,
884
1045
  line,
885
1046
  lineSegment,
886
1047
  lineSegmentIntersectionPoints,
@@ -889,6 +1050,7 @@ export {
889
1050
  linesIntersectAt,
890
1051
  normalizeRadians,
891
1052
  offsetPointsForQuadraticBezier,
1053
+ orientPrincipalAxes,
892
1054
  pointCenter,
893
1055
  pointDistance,
894
1056
  pointDistanceSq,
@@ -897,16 +1059,20 @@ export {
897
1059
  pointFromPair,
898
1060
  pointFromVector,
899
1061
  pointOnLineSegment,
900
- pointOnPolygon,
901
1062
  pointRotateDegs,
902
1063
  pointRotateRads,
903
1064
  pointScaleFromOrigin,
904
1065
  pointTranslate,
905
1066
  pointsEqual,
906
1067
  polygon,
1068
+ polygonArea,
907
1069
  polygonFromPoints,
908
1070
  polygonIncludesPoint,
909
1071
  polygonIncludesPointNonZero,
1072
+ polygonIsClosed,
1073
+ polygonSignedArea,
1074
+ principalAxes,
1075
+ principalCoords,
910
1076
  radiansBetweenAngles,
911
1077
  radiansDifference,
912
1078
  radiansToDegrees,
@@ -922,6 +1088,9 @@ export {
922
1088
  round,
923
1089
  roundToStep,
924
1090
  segmentsIntersectAt,
1091
+ simplifyConvexPolygon,
1092
+ skewness,
1093
+ standardizedMoment,
925
1094
  triangleIncludesPoint,
926
1095
  vector,
927
1096
  vectorAdd,