@dwelle/excalidraw 0.6.0-rc.1 → 0.6.0-rc.2

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 (227) hide show
  1. package/README.md +3 -2
  2. package/dist/dev/{chunk-EFVS2MI5.js → chunk-LCPOPWNR.js} +2 -2
  3. package/dist/dev/{chunk-EFVS2MI5.js.map → chunk-LCPOPWNR.js.map} +1 -1
  4. package/dist/dev/chunk-NGUTX5QY.js +25914 -0
  5. package/dist/dev/chunk-NGUTX5QY.js.map +7 -0
  6. package/dist/dev/data/image-2IPPJHZ4.js +13 -0
  7. package/dist/dev/index.css.map +1 -1
  8. package/dist/dev/index.js +33216 -35
  9. package/dist/dev/index.js.map +4 -4
  10. package/dist/dev/subset-shared.chunk.js +1 -1
  11. package/dist/dev/subset-worker.chunk.js +1 -1
  12. package/dist/prod/{chunk-P7457GAF.js → chunk-BE2LY6VO.js} +1 -1
  13. package/dist/prod/chunk-R7OERAXD.js +46 -0
  14. package/dist/prod/data/image-DXJVNPGL.js +1 -0
  15. package/dist/prod/index.js +108 -1
  16. package/dist/prod/subset-shared.chunk.js +1 -1
  17. package/dist/prod/subset-worker.chunk.js +1 -1
  18. package/dist/types/excalidraw/actions/actionAlign.d.ts +12 -12
  19. package/dist/types/excalidraw/actions/actionCanvas.d.ts +18 -18
  20. package/dist/types/excalidraw/actions/actionClipboard.d.ts +4 -4
  21. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +2 -2
  22. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +2 -2
  23. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  24. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  25. package/dist/types/excalidraw/actions/actionElementLink.d.ts +2 -2
  26. package/dist/types/excalidraw/actions/actionElementLock.d.ts +2 -2
  27. package/dist/types/excalidraw/actions/actionExport.d.ts +19 -19
  28. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -1
  29. package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -2
  30. package/dist/types/excalidraw/actions/actionFrame.d.ts +2 -2
  31. package/dist/types/excalidraw/actions/actionGroup.d.ts +4 -4
  32. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +1 -1
  33. package/dist/types/excalidraw/actions/actionLink.d.ts +2 -2
  34. package/dist/types/excalidraw/actions/actionMenu.d.ts +3 -3
  35. package/dist/types/excalidraw/actions/actionNavigate.d.ts +1 -1
  36. package/dist/types/excalidraw/actions/actionProperties.d.ts +16 -16
  37. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +1 -1
  38. package/dist/types/excalidraw/actions/actionStyles.d.ts +2 -2
  39. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +1 -1
  40. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +1 -1
  41. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +1 -1
  42. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +1 -1
  43. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +1 -1
  44. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +1 -1
  45. package/dist/types/excalidraw/actions/actionZindex.d.ts +10 -10
  46. package/dist/types/excalidraw/actions/manager.d.ts +1 -1
  47. package/dist/types/excalidraw/appState.d.ts +9 -9
  48. package/dist/types/excalidraw/clipboard.d.ts +4 -4
  49. package/dist/types/excalidraw/components/Actions.d.ts +6 -7
  50. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -2
  51. package/dist/types/excalidraw/components/App.d.ts +1 -1
  52. package/dist/types/excalidraw/components/Avatar.d.ts +1 -1
  53. package/dist/types/excalidraw/components/BraveMeasureTextError.d.ts +1 -2
  54. package/dist/types/excalidraw/components/Button.d.ts +1 -1
  55. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -1
  56. package/dist/types/excalidraw/components/ButtonIconCycle.d.ts +2 -2
  57. package/dist/types/excalidraw/components/ButtonIconSelect.d.ts +2 -2
  58. package/dist/types/excalidraw/components/ButtonSelect.d.ts +1 -2
  59. package/dist/types/excalidraw/components/ButtonSeparator.d.ts +1 -2
  60. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +1 -2
  61. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +1 -2
  62. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -2
  63. package/dist/types/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +1 -2
  64. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +1 -1
  65. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +1 -2
  66. package/dist/types/excalidraw/components/ColorPicker/PickerHeading.d.ts +1 -1
  67. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +1 -2
  68. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -2
  69. package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -2
  70. package/dist/types/excalidraw/components/ConfirmDialog.d.ts +1 -2
  71. package/dist/types/excalidraw/components/ContextMenu.d.ts +1 -1
  72. package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -2
  73. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +1 -1
  74. package/dist/types/excalidraw/components/Dialog.d.ts +1 -1
  75. package/dist/types/excalidraw/components/DialogActionButton.d.ts +1 -1
  76. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -2
  77. package/dist/types/excalidraw/components/ErrorDialog.d.ts +1 -1
  78. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
  79. package/dist/types/excalidraw/components/FixedSideContainer.d.ts +1 -1
  80. package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +1 -2
  81. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -2
  82. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +2 -1
  83. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +1 -2
  84. package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +1 -1
  85. package/dist/types/excalidraw/components/HandButton.d.ts +1 -2
  86. package/dist/types/excalidraw/components/HelpButton.d.ts +1 -2
  87. package/dist/types/excalidraw/components/HelpDialog.d.ts +1 -2
  88. package/dist/types/excalidraw/components/HintViewer.d.ts +1 -2
  89. package/dist/types/excalidraw/components/IconPicker.d.ts +2 -2
  90. package/dist/types/excalidraw/components/ImageExportDialog.d.ts +2 -3
  91. package/dist/types/excalidraw/components/InitializeApp.d.ts +1 -1
  92. package/dist/types/excalidraw/components/InlineIcon.d.ts +1 -2
  93. package/dist/types/excalidraw/components/JSONExportDialog.d.ts +1 -1
  94. package/dist/types/excalidraw/components/LaserPointerButton.d.ts +1 -2
  95. package/dist/types/excalidraw/components/LayerUI.d.ts +1 -1
  96. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  97. package/dist/types/excalidraw/components/LibraryMenuBrowseButton.d.ts +1 -2
  98. package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -2
  99. package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -1
  100. package/dist/types/excalidraw/components/LibraryMenuItems.d.ts +1 -2
  101. package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +2 -2
  102. package/dist/types/excalidraw/components/LibraryUnit.d.ts +2 -2
  103. package/dist/types/excalidraw/components/LockButton.d.ts +1 -2
  104. package/dist/types/excalidraw/components/MagicButton.d.ts +2 -2
  105. package/dist/types/excalidraw/components/MobileMenu.d.ts +2 -1
  106. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +4 -4
  107. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +6 -6
  108. package/dist/types/excalidraw/components/Paragraph.d.ts +1 -2
  109. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +1 -1
  110. package/dist/types/excalidraw/components/PenModeButton.d.ts +1 -2
  111. package/dist/types/excalidraw/components/Popover.d.ts +1 -1
  112. package/dist/types/excalidraw/components/ProjectName.d.ts +1 -2
  113. package/dist/types/excalidraw/components/PublishLibrary.d.ts +1 -2
  114. package/dist/types/excalidraw/components/RadioGroup.d.ts +1 -1
  115. package/dist/types/excalidraw/components/Range.d.ts +1 -2
  116. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -2
  117. package/dist/types/excalidraw/components/ScrollableList.d.ts +1 -1
  118. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -2
  119. package/dist/types/excalidraw/components/ShareableLinkDialog.d.ts +1 -2
  120. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +6 -6
  121. package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +1 -2
  122. package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -1
  123. package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -1
  124. package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +1 -1
  125. package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +1 -1
  126. package/dist/types/excalidraw/components/Sidebar/SidebarTrigger.d.ts +1 -2
  127. package/dist/types/excalidraw/components/Sidebar/common.d.ts +1 -0
  128. package/dist/types/excalidraw/components/Spinner.d.ts +1 -2
  129. package/dist/types/excalidraw/components/Stack.d.ts +2 -3
  130. package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -2
  131. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  132. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +1 -1
  133. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -2
  134. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +1 -1
  135. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -2
  136. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -2
  137. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -2
  138. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -2
  139. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -2
  140. package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -2
  141. package/dist/types/excalidraw/components/Stats/index.d.ts +4 -4
  142. package/dist/types/excalidraw/components/Switch.d.ts +1 -2
  143. package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +1 -2
  144. package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +1 -1
  145. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +1 -1
  146. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +2 -2
  147. package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +1 -1
  148. package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +1 -1
  149. package/dist/types/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.d.ts +1 -2
  150. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -1
  151. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -1
  152. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -1
  153. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +1 -1
  154. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +2 -1
  155. package/dist/types/excalidraw/components/TTDDialog/common.d.ts +1 -1
  156. package/dist/types/excalidraw/components/Toast.d.ts +1 -1
  157. package/dist/types/excalidraw/components/Tooltip.d.ts +1 -1
  158. package/dist/types/excalidraw/components/UserList.d.ts +1 -1
  159. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -2
  160. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -2
  161. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  162. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +11 -11
  163. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +1 -1
  164. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +1 -1
  165. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +4 -3
  166. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -2
  167. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +1 -1
  168. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +1 -1
  169. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +2 -1
  170. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSeparator.d.ts +1 -2
  171. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +1 -1
  172. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -2
  173. package/dist/types/excalidraw/components/footer/Footer.d.ts +1 -2
  174. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +1 -2
  175. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -2
  176. package/dist/types/excalidraw/components/icons.d.ts +178 -178
  177. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +1 -1
  178. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +12 -13
  179. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +9 -9
  180. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +10 -10
  181. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +3 -4
  182. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +15 -15
  183. package/dist/types/excalidraw/constants.d.ts +1 -0
  184. package/dist/types/excalidraw/data/blob.d.ts +1 -1
  185. package/dist/types/excalidraw/element/ElementCanvasButtons.d.ts +1 -2
  186. package/dist/types/excalidraw/element/binding.d.ts +1 -2
  187. package/dist/types/excalidraw/element/collision.d.ts +10 -1
  188. package/dist/types/excalidraw/element/distance.d.ts +3 -0
  189. package/dist/types/excalidraw/element/newElement.d.ts +1 -1
  190. package/dist/types/excalidraw/element/transformHandles.d.ts +2 -2
  191. package/dist/types/excalidraw/element/types.d.ts +1 -1
  192. package/dist/types/excalidraw/element/utils.d.ts +21 -0
  193. package/dist/types/excalidraw/fonts/FontMetadata.d.ts +1 -1
  194. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +1 -1
  195. package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -1
  196. package/dist/types/excalidraw/index.d.ts +1 -3
  197. package/dist/types/excalidraw/shapes.d.ts +11 -12
  198. package/dist/types/excalidraw/types.d.ts +1 -0
  199. package/dist/types/excalidraw/utils.d.ts +3 -3
  200. package/dist/types/excalidraw/visualdebug.d.ts +7 -8
  201. package/dist/types/excalidraw/zindex.d.ts +2 -2
  202. package/dist/types/math/curve.d.ts +22 -14
  203. package/dist/types/math/ellipse.d.ts +44 -0
  204. package/dist/types/math/index.d.ts +1 -1
  205. package/dist/types/math/line.d.ts +2 -30
  206. package/dist/types/math/point.d.ts +1 -29
  207. package/dist/types/math/rectangle.d.ts +3 -0
  208. package/dist/types/math/segment.d.ts +8 -1
  209. package/dist/types/math/types.d.ts +15 -6
  210. package/dist/types/math/vector.d.ts +0 -4
  211. package/dist/types/utils/export.d.ts +1 -1
  212. package/package.json +5 -5
  213. package/dist/dev/chunk-637CAVTS.js +0 -57639
  214. package/dist/dev/chunk-637CAVTS.js.map +0 -7
  215. package/dist/dev/data/image-N6Y7BWW6.css +0 -6753
  216. package/dist/dev/data/image-N6Y7BWW6.css.map +0 -7
  217. package/dist/dev/data/image-QMQX6YR5.js +0 -15
  218. package/dist/prod/chunk-PEDHHNBJ.js +0 -153
  219. package/dist/prod/data/image-IP6M4LZC.js +0 -1
  220. package/dist/prod/data/image-KGQIL6Y4.css +0 -1
  221. package/dist/types/math/arc.d.ts +0 -6
  222. package/dist/types/math/ga/ga.d.ts +0 -63
  223. package/dist/types/math/ga/gadirections.d.ts +0 -8
  224. package/dist/types/math/ga/galines.d.ts +0 -22
  225. package/dist/types/math/ga/gapoints.d.ts +0 -7
  226. package/dist/types/math/ga/gatransforms.d.ts +0 -10
  227. /package/dist/dev/data/{image-QMQX6YR5.js.map → image-2IPPJHZ4.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import type { Curve, GlobalPoint, LocalPoint, Radians } from "./types";
1
+ import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
2
2
  /**
3
3
  *
4
4
  * @param a
@@ -8,25 +8,33 @@ import type { Curve, GlobalPoint, LocalPoint, Radians } from "./types";
8
8
  * @returns
9
9
  */
10
10
  export declare function curve<Point extends GlobalPoint | LocalPoint>(a: Point, b: Point, c: Point, d: Point): Curve<Point>;
11
- export declare const curveRotate: <Point extends GlobalPoint | LocalPoint>(curve: Curve<Point>, angle: Radians, origin: Point) => Point[];
12
11
  /**
13
- *
14
- * @param pointsIn
15
- * @param curveTightness
16
- * @returns
12
+ * Computes the intersection between a cubic spline and a line segment.
17
13
  */
18
- export declare function curveToBezier<Point extends LocalPoint | GlobalPoint>(pointsIn: readonly Point[], curveTightness?: number): Point[];
14
+ export declare function curveIntersectLineSegment<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, l: LineSegment<Point>): Point[];
19
15
  /**
16
+ * Finds the closest point on the Bezier curve from another point
20
17
  *
21
- * @param t
22
- * @param controlPoints
18
+ * @param x
19
+ * @param y
20
+ * @param P0
21
+ * @param P1
22
+ * @param P2
23
+ * @param P3
24
+ * @param tolerance
25
+ * @param maxLevel
23
26
  * @returns
24
27
  */
25
- export declare const cubicBezierPoint: <Point extends GlobalPoint | LocalPoint>(t: number, controlPoints: Curve<Point>) => Point;
28
+ export declare function curveClosestPoint<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point, tolerance?: number): Point | null;
26
29
  /**
30
+ * Determines the distance between a point and the closest point on the
31
+ * Bezier curve.
27
32
  *
28
- * @param point
29
- * @param controlPoints
30
- * @returns
33
+ * @param c The curve to test
34
+ * @param p The point to measure from
35
+ */
36
+ export declare function curvePointDistance<Point extends GlobalPoint | LocalPoint>(c: Curve<Point>, p: Point): number;
37
+ /**
38
+ * Determines if the parameter is a Curve
31
39
  */
32
- export declare const cubicBezierDistance: <Point extends GlobalPoint | LocalPoint>(point: Point, controlPoints: Curve<Point>) => number;
40
+ export declare function isCurve<P extends GlobalPoint | LocalPoint>(v: unknown): v is Curve<P>;
@@ -0,0 +1,44 @@
1
+ import type { Ellipse, GlobalPoint, Line, LineSegment, LocalPoint } from "./types";
2
+ /**
3
+ * Construct an Ellipse object from the parameters
4
+ *
5
+ * @param center The center of the ellipse
6
+ * @param angle The slanting of the ellipse in radians
7
+ * @param halfWidth Half of the width of a non-slanted version of the ellipse
8
+ * @param halfHeight Half of the height of a non-slanted version of the ellipse
9
+ * @returns The constructed Ellipse object
10
+ */
11
+ export declare function ellipse<Point extends GlobalPoint | LocalPoint>(center: Point, halfWidth: number, halfHeight: number): Ellipse<Point>;
12
+ /**
13
+ * Determines if a point is inside or on the ellipse outline
14
+ *
15
+ * @param p The point to test
16
+ * @param ellipse The ellipse to compare against
17
+ * @returns TRUE if the point is inside or on the outline of the ellipse
18
+ */
19
+ export declare const ellipseIncludesPoint: <Point extends GlobalPoint | LocalPoint>(p: Point, ellipse: Ellipse<Point>) => boolean;
20
+ /**
21
+ * Tests whether a point lies on the outline of the ellipse within a given
22
+ * tolerance
23
+ *
24
+ * @param point The point to test
25
+ * @param ellipse The ellipse to compare against
26
+ * @param threshold The distance to consider a point close enough to be "on" the outline
27
+ * @returns TRUE if the point is on the ellise outline
28
+ */
29
+ export declare const ellipseTouchesPoint: <Point extends GlobalPoint | LocalPoint>(point: Point, ellipse: Ellipse<Point>, threshold?: number) => boolean;
30
+ /**
31
+ * Determine the shortest euclidean distance from a point to the
32
+ * outline of the ellipse
33
+ *
34
+ * @param p The point to consider
35
+ * @param ellipse The ellipse to calculate the distance to
36
+ * @returns The eucledian distance
37
+ */
38
+ export declare const ellipseDistanceFromPoint: <Point extends GlobalPoint | LocalPoint>(p: Point, ellipse: Ellipse<Point>) => number;
39
+ /**
40
+ * Calculate a maximum of two intercept points for a line going throug an
41
+ * ellipse.
42
+ */
43
+ export declare function ellipseSegmentInterceptPoints<Point extends GlobalPoint | LocalPoint>(e: Readonly<Ellipse<Point>>, s: Readonly<LineSegment<Point>>): Point[];
44
+ export declare function ellipseLineIntersectionPoints<Point extends GlobalPoint | LocalPoint>({ center, halfWidth, halfHeight }: Ellipse<Point>, [g, h]: Line<Point>): Point[];
@@ -1,10 +1,10 @@
1
- export * from "./arc";
2
1
  export * from "./angle";
3
2
  export * from "./curve";
4
3
  export * from "./line";
5
4
  export * from "./point";
6
5
  export * from "./polygon";
7
6
  export * from "./range";
7
+ export * from "./rectangle";
8
8
  export * from "./segment";
9
9
  export * from "./triangle";
10
10
  export * from "./types";
@@ -1,4 +1,4 @@
1
- import type { GlobalPoint, Line, LocalPoint, Radians } from "./types";
1
+ import type { GlobalPoint, Line, LocalPoint } from "./types";
2
2
  /**
3
3
  * Create a line from two points.
4
4
  *
@@ -6,34 +6,6 @@ import type { GlobalPoint, Line, LocalPoint, Radians } from "./types";
6
6
  * @returns The line on which the points lie
7
7
  */
8
8
  export declare function line<P extends GlobalPoint | LocalPoint>(a: P, b: P): Line<P>;
9
- /**
10
- * Convenient point creation from an array of two points.
11
- *
12
- * @param param0 The array with the two points to convert to a line
13
- * @returns The created line
14
- */
15
- export declare function lineFromPointPair<P extends GlobalPoint | LocalPoint>([a, b]: [
16
- P,
17
- P
18
- ]): Line<P>;
19
- /**
20
- * TODO
21
- *
22
- * @param pointArray
23
- * @returns
24
- */
25
- export declare function lineFromPointArray<P extends GlobalPoint | LocalPoint>(pointArray: P[]): Line<P> | undefined;
26
- /**
27
- * Return the coordinates resulting from rotating the given line about an
28
- * origin by an angle in degrees note that when the origin is not given,
29
- * the midpoint of the given line is used as the origin
30
- *
31
- * @param l
32
- * @param angle
33
- * @param origin
34
- * @returns
35
- */
36
- export declare const lineRotate: <Point extends GlobalPoint | LocalPoint>(l: Line<Point>, angle: Radians, origin?: Point | undefined) => Line<Point>;
37
9
  /**
38
10
  * Determines the intersection point (unless the lines are parallel) of two
39
11
  * lines
@@ -42,4 +14,4 @@ export declare const lineRotate: <Point extends GlobalPoint | LocalPoint>(l: Lin
42
14
  * @param b
43
15
  * @returns
44
16
  */
45
- export declare const linesIntersectAt: <Point extends GlobalPoint | LocalPoint>(a: Line<Point>, b: Line<Point>) => Point | null;
17
+ export declare function linesIntersectAt<Point extends GlobalPoint | LocalPoint>(a: Line<Point>, b: Line<Point>): Point | null;
@@ -27,17 +27,7 @@ export declare function pointFromPair<Point extends GlobalPoint | LocalPoint>(pa
27
27
  * @param v The vector to convert
28
28
  * @returns The point the vector points at with origin 0,0
29
29
  */
30
- export declare function pointFromVector<P extends GlobalPoint | LocalPoint>(v: Vector): P;
31
- /**
32
- * Convert the coordiante object to a point.
33
- *
34
- * @param coords The coordinate object with x and y properties
35
- * @returns
36
- */
37
- export declare function pointFromCoords<Point extends GlobalPoint | LocalPoint>({ x, y, }: {
38
- x: number;
39
- y: number;
40
- }): Point;
30
+ export declare function pointFromVector<P extends GlobalPoint | LocalPoint>(v: Vector, offset?: P): P;
41
31
  /**
42
32
  * Checks if the provided value has the shape of a Point.
43
33
  *
@@ -93,24 +83,6 @@ export declare function pointTranslate<From extends GlobalPoint | LocalPoint, To
93
83
  * @returns The middle point
94
84
  */
95
85
  export declare function pointCenter<P extends LocalPoint | GlobalPoint>(a: P, b: P): P;
96
- /**
97
- * Add together two points by their coordinates like you'd apply a translation
98
- * to a point by a vector.
99
- *
100
- * @param a One point to act as a basis
101
- * @param b The other point to act like the vector to translate by
102
- * @returns
103
- */
104
- export declare function pointAdd<Point extends LocalPoint | GlobalPoint>(a: Point, b: Point): Point;
105
- /**
106
- * Subtract a point from another point like you'd translate a point by an
107
- * invese vector.
108
- *
109
- * @param a The point to translate
110
- * @param b The point which will act like a vector
111
- * @returns The resulting point
112
- */
113
- export declare function pointSubtract<Point extends LocalPoint | GlobalPoint>(a: Point, b: Point): Point;
114
86
  /**
115
87
  * Calculate the distance between two points.
116
88
  *
@@ -0,0 +1,3 @@
1
+ import type { GlobalPoint, LineSegment, LocalPoint, Rectangle } from "./types";
2
+ export declare function rectangle<P extends GlobalPoint | LocalPoint>(topLeft: P, bottomRight: P): Rectangle<P>;
3
+ export declare function rectangleIntersectLineSegment<Point extends LocalPoint | GlobalPoint>(r: Rectangle<Point>, l: LineSegment<Point>): Point[];
@@ -6,7 +6,6 @@ import type { GlobalPoint, LineSegment, LocalPoint, Radians } from "./types";
6
6
  * @returns The line segment delineated by the points
7
7
  */
8
8
  export declare function lineSegment<P extends GlobalPoint | LocalPoint>(a: P, b: P): LineSegment<P>;
9
- export declare function lineSegmentFromPointArray<P extends GlobalPoint | LocalPoint>(pointArray: P[]): LineSegment<P> | undefined;
10
9
  /**
11
10
  *
12
11
  * @param segment
@@ -30,3 +29,11 @@ export declare const lineSegmentRotate: <Point extends GlobalPoint | LocalPoint>
30
29
  export declare const segmentsIntersectAt: <Point extends GlobalPoint | LocalPoint>(a: Readonly<LineSegment<Point>>, b: Readonly<LineSegment<Point>>) => Point | null;
31
30
  export declare const pointOnLineSegment: <Point extends GlobalPoint | LocalPoint>(point: Point, line: LineSegment<Point>, threshold?: number) => boolean;
32
31
  export declare const distanceToLineSegment: <Point extends GlobalPoint | LocalPoint>(point: Point, line: LineSegment<Point>) => number;
32
+ /**
33
+ * Returns the intersection point of a segment and a line
34
+ *
35
+ * @param l
36
+ * @param s
37
+ * @returns
38
+ */
39
+ export declare function lineSegmentIntersectionPoints<Point extends GlobalPoint | LocalPoint>(l: LineSegment<Point>, s: LineSegment<Point>): Point | null;
@@ -62,6 +62,12 @@ export type Triangle<P extends GlobalPoint | LocalPoint> = [
62
62
  ] & {
63
63
  _brand: "excalimath__triangle";
64
64
  };
65
+ /**
66
+ * A rectangular shape represented by 4 points at its corners
67
+ */
68
+ export type Rectangle<P extends GlobalPoint | LocalPoint> = [a: P, b: P] & {
69
+ _brand: "excalimath__rectangle";
70
+ };
65
71
  /**
66
72
  * A polygon is a closed shape by connecting the given points
67
73
  * rectangles and diamonds are modelled by polygons
@@ -86,11 +92,14 @@ export type PolarCoords = [
86
92
  angle: number
87
93
  ];
88
94
  /**
89
- * Angles are in radians and centered on 0, 0. Zero radians on a 1 radius circle
90
- * corresponds to (1, 0) cartesian coordinates (point), i.e. to the "right".
95
+ An ellipse is specified by its center, angle, and its major and minor axes
96
+ but for the sake of simplicity, we've used halfWidth and halfHeight instead
97
+ in replace of semi major and semi minor axes
91
98
  */
92
- export type SymmetricArc = {
93
- radius: number;
94
- startAngle: number;
95
- endAngle: number;
99
+ export type Ellipse<Point extends GlobalPoint | LocalPoint> = {
100
+ center: Point;
101
+ halfWidth: number;
102
+ halfHeight: number;
103
+ } & {
104
+ _brand: "excalimath_ellipse";
96
105
  };
@@ -86,7 +86,3 @@ export declare function vectorMagnitude(v: Vector): number;
86
86
  * @returns The new normalized vector
87
87
  */
88
88
  export declare const vectorNormalize: (v: Vector) => Vector;
89
- /**
90
- * Project the first vector onto the second vector
91
- */
92
- export declare const vectorProjection: (a: Vector, b: Vector) => Vector;
@@ -1,5 +1,5 @@
1
+ import type { ExportToCanvasConfig, ExportToCanvasData } from "@excalidraw/excalidraw/scene/export";
1
2
  import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
2
- import type { ExportToCanvasConfig, ExportToCanvasData } from "../excalidraw/scene/export";
3
3
  export { MIME_TYPES };
4
4
  type ExportToBlobConfig = ExportToCanvasConfig & {
5
5
  mimeType?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dwelle/excalidraw",
3
- "version": "0.6.0-rc.1",
3
+ "version": "0.6.0-rc.2",
4
4
  "type": "module",
5
5
  "types": "./dist/types/excalidraw/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -48,8 +48,8 @@
48
48
  ]
49
49
  },
50
50
  "peerDependencies": {
51
- "react": "^17.0.2 || ^18.2.0",
52
- "react-dom": "^17.0.2 || ^18.2.0"
51
+ "react": "^17.0.2 || ^18.2.0 || ^19.0.0",
52
+ "react-dom": "^17.0.2 || ^18.2.0 || ^19.0.0"
53
53
  },
54
54
  "dependencies": {
55
55
  "@braintree/sanitize-url": "6.0.2",
@@ -95,8 +95,8 @@
95
95
  "@babel/preset-typescript": "7.24.1",
96
96
  "@size-limit/preset-big-lib": "9.0.0",
97
97
  "@testing-library/dom": "10.4.0",
98
- "@testing-library/jest-dom": "5.16.2",
99
- "@testing-library/react": "16.0.0",
98
+ "@testing-library/jest-dom": "6.6.3",
99
+ "@testing-library/react": "16.2.0",
100
100
  "@types/lodash.debounce": "4.0.8",
101
101
  "@types/pako": "2.0.3",
102
102
  "@types/pica": "5.1.3",