@excalidraw/math 0.18.0-d2463f87d
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.
- package/README.md +19 -0
- package/dist/dev/index.js +907 -0
- package/dist/dev/index.js.map +7 -0
- package/dist/prod/index.js +1 -0
- package/dist/types/common/src/binary-heap.d.ts +12 -0
- package/dist/types/common/src/colors.d.ts +62 -0
- package/dist/types/common/src/constants.d.ts +343 -0
- package/dist/types/common/src/emitter.d.ts +16 -0
- package/dist/types/common/src/font-metadata.d.ts +48 -0
- package/dist/types/common/src/index.d.ts +12 -0
- package/dist/types/common/src/keys.d.ts +189 -0
- package/dist/types/common/src/points.d.ts +9 -0
- package/dist/types/common/src/promise-pool.d.ts +6 -0
- package/dist/types/common/src/queue.d.ts +9 -0
- package/dist/types/common/src/random.d.ts +3 -0
- package/dist/types/common/src/url.d.ts +7 -0
- package/dist/types/common/src/utility-types.d.ts +38 -0
- package/dist/types/common/src/utils.d.ts +267 -0
- package/dist/types/element/src/Scene.d.ts +76 -0
- package/dist/types/element/src/align.d.ts +7 -0
- package/dist/types/element/src/binding.d.ts +110 -0
- package/dist/types/element/src/bounds.d.ts +89 -0
- package/dist/types/element/src/collision.d.ts +32 -0
- package/dist/types/element/src/comparisons.d.ts +8 -0
- package/dist/types/element/src/containerCache.d.ts +11 -0
- package/dist/types/element/src/cropElement.d.ts +19 -0
- package/dist/types/element/src/delta.d.ts +216 -0
- package/dist/types/element/src/distance.d.ts +3 -0
- package/dist/types/element/src/distribute.d.ts +6 -0
- package/dist/types/element/src/dragElements.d.ts +33 -0
- package/dist/types/element/src/duplicate.d.ts +63 -0
- package/dist/types/element/src/elbowArrow.d.ts +17 -0
- package/dist/types/element/src/elementLink.d.ts +13 -0
- package/dist/types/element/src/embeddable.d.ts +10 -0
- package/dist/types/element/src/flowchart.d.ts +26 -0
- package/dist/types/element/src/fractionalIndex.d.ts +57 -0
- package/dist/types/element/src/frame.d.ts +70 -0
- package/dist/types/element/src/groups.d.ts +33 -0
- package/dist/types/element/src/heading.d.ts +15 -0
- package/dist/types/element/src/image.d.ts +32 -0
- package/dist/types/element/src/index.d.ts +57 -0
- package/dist/types/element/src/linearElementEditor.d.ts +116 -0
- package/dist/types/element/src/mutateElement.d.ts +21 -0
- package/dist/types/element/src/newElement.d.ts +62 -0
- package/dist/types/element/src/renderElement.d.ts +28 -0
- package/dist/types/element/src/resizeElements.d.ts +32 -0
- package/dist/types/element/src/resizeTest.d.ts +15 -0
- package/dist/types/element/src/selection.d.ts +38 -0
- package/dist/types/element/src/shape.d.ts +42 -0
- package/dist/types/element/src/showSelectedShapeActions.d.ts +3 -0
- package/dist/types/element/src/sizeHelpers.d.ts +35 -0
- package/dist/types/element/src/sortElements.d.ts +2 -0
- package/dist/types/element/src/store.d.ts +231 -0
- package/dist/types/element/src/textElement.d.ts +40 -0
- package/dist/types/element/src/textMeasurements.d.ts +41 -0
- package/dist/types/element/src/textWrapping.d.ts +13 -0
- package/dist/types/element/src/transformHandles.d.ts +55 -0
- package/dist/types/element/src/typeChecks.d.ts +57 -0
- package/dist/types/element/src/types.d.ts +295 -0
- package/dist/types/element/src/utils.d.ts +31 -0
- package/dist/types/element/src/zindex.d.ts +7 -0
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +528 -0
- package/dist/types/excalidraw/actions/actionAlign.d.ts +110 -0
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +389 -0
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +2416 -0
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +1172 -0
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +189 -0
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +568 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +35 -0
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +18 -0
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +211 -0
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +375 -0
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +186 -0
- package/dist/types/excalidraw/actions/actionExport.d.ts +1648 -0
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +398 -0
- package/dist/types/excalidraw/actions/actionFlip.d.ts +35 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +1245 -0
- package/dist/types/excalidraw/actions/actionGroup.d.ts +387 -0
- package/dist/types/excalidraw/actions/actionHistory.d.ts +6 -0
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +683 -0
- package/dist/types/excalidraw/actions/actionLink.d.ts +190 -0
- package/dist/types/excalidraw/actions/actionMenu.d.ts +548 -0
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +363 -0
- package/dist/types/excalidraw/actions/actionProperties.d.ts +2774 -0
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +189 -0
- package/dist/types/excalidraw/actions/actionStyles.d.ts +203 -0
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +17 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +192 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +190 -0
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +183 -0
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +189 -0
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +190 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +190 -0
- package/dist/types/excalidraw/actions/actionZindex.d.ts +75 -0
- package/dist/types/excalidraw/actions/index.d.ts +28 -0
- package/dist/types/excalidraw/actions/manager.d.ts +21 -0
- package/dist/types/excalidraw/actions/register.d.ts +5 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +4 -0
- package/dist/types/excalidraw/actions/types.d.ts +47 -0
- package/dist/types/excalidraw/analytics.d.ts +1 -0
- package/dist/types/excalidraw/animated-trail.d.ts +39 -0
- package/dist/types/excalidraw/animation-frame-handler.d.ts +16 -0
- package/dist/types/excalidraw/appState.d.ts +96 -0
- package/dist/types/excalidraw/charts.d.ts +27 -0
- package/dist/types/excalidraw/clients.d.ts +14 -0
- package/dist/types/excalidraw/clipboard.d.ts +66 -0
- package/dist/types/excalidraw/components/Actions.d.ts +34 -0
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +4 -0
- package/dist/types/excalidraw/components/App.d.ts +559 -0
- package/dist/types/excalidraw/components/Avatar.d.ts +11 -0
- package/dist/types/excalidraw/components/BraveMeasureTextError.d.ts +2 -0
- package/dist/types/excalidraw/components/Button.d.ts +17 -0
- package/dist/types/excalidraw/components/ButtonIcon.d.ts +16 -0
- package/dist/types/excalidraw/components/ButtonSeparator.d.ts +1 -0
- package/dist/types/excalidraw/components/Card.d.ts +7 -0
- package/dist/types/excalidraw/components/CheckboxItem.d.ts +8 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +10 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +23 -0
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +8 -0
- package/dist/types/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +7 -0
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +17 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerHeading.d.ts +5 -0
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +8 -0
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +9 -0
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +21 -0
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +21 -0
- package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +18 -0
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +2 -0
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +26 -0
- package/dist/types/excalidraw/components/ConfirmDialog.d.ts +10 -0
- package/dist/types/excalidraw/components/ContextMenu.d.ts +16 -0
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
- package/dist/types/excalidraw/components/DarkModeToggle.d.ts +7 -0
- package/dist/types/excalidraw/components/DefaultSidebar.d.ts +31 -0
- package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +4 -0
- package/dist/types/excalidraw/components/Dialog.d.ts +13 -0
- package/dist/types/excalidraw/components/DialogActionButton.d.ts +10 -0
- package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +7 -0
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +12 -0
- package/dist/types/excalidraw/components/ErrorDialog.d.ts +5 -0
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +16 -0
- package/dist/types/excalidraw/components/EyeDropper.d.ts +28 -0
- package/dist/types/excalidraw/components/FilledButton.d.ts +18 -0
- package/dist/types/excalidraw/components/FixedSideContainer.d.ts +9 -0
- package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +10 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +21 -0
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +26 -0
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +6 -0
- package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +14 -0
- package/dist/types/excalidraw/components/HandButton.d.ts +10 -0
- package/dist/types/excalidraw/components/HelpButton.d.ts +7 -0
- package/dist/types/excalidraw/components/HelpDialog.d.ts +4 -0
- package/dist/types/excalidraw/components/HintViewer.d.ts +10 -0
- package/dist/types/excalidraw/components/IconPicker.d.ts +15 -0
- package/dist/types/excalidraw/components/ImageExportDialog.d.ts +14 -0
- package/dist/types/excalidraw/components/InitializeApp.d.ts +10 -0
- package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -0
- package/dist/types/excalidraw/components/Island.d.ts +10 -0
- package/dist/types/excalidraw/components/JSONExportDialog.d.ts +15 -0
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +10 -0
- package/dist/types/excalidraw/components/LayerUI.d.ts +31 -0
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +10 -0
- package/dist/types/excalidraw/components/LibraryMenuBrowseButton.d.ts +7 -0
- package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +9 -0
- package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +18 -0
- package/dist/types/excalidraw/components/LibraryMenuItems.d.ts +14 -0
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +23 -0
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +15 -0
- package/dist/types/excalidraw/components/LoadingMessage.d.ts +6 -0
- package/dist/types/excalidraw/components/LockButton.d.ts +10 -0
- package/dist/types/excalidraw/components/MagicButton.d.ts +10 -0
- package/dist/types/excalidraw/components/MobileMenu.d.ts +25 -0
- package/dist/types/excalidraw/components/Modal.d.ts +12 -0
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +17 -0
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +17 -0
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +22 -0
- package/dist/types/excalidraw/components/PasteChartDialog.d.ts +8 -0
- package/dist/types/excalidraw/components/PenModeButton.d.ts +12 -0
- package/dist/types/excalidraw/components/Popover.d.ts +15 -0
- package/dist/types/excalidraw/components/ProjectName.d.ts +10 -0
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +15 -0
- package/dist/types/excalidraw/components/PublishLibrary.d.ts +16 -0
- package/dist/types/excalidraw/components/QuickSearch.d.ts +9 -0
- package/dist/types/excalidraw/components/RadioGroup.d.ts +14 -0
- package/dist/types/excalidraw/components/RadioSelection.d.ts +20 -0
- package/dist/types/excalidraw/components/Range.d.ts +8 -0
- package/dist/types/excalidraw/components/SVGLayer.d.ts +7 -0
- package/dist/types/excalidraw/components/ScrollableList.d.ts +9 -0
- package/dist/types/excalidraw/components/SearchMenu.d.ts +5 -0
- package/dist/types/excalidraw/components/Section.d.ts +6 -0
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +76 -0
- package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +7 -0
- package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +9 -0
- package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +10 -0
- package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +7 -0
- package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +7 -0
- package/dist/types/excalidraw/components/Sidebar/SidebarTrigger.d.ts +6 -0
- package/dist/types/excalidraw/components/Sidebar/common.d.ts +34 -0
- package/dist/types/excalidraw/components/Spinner.d.ts +8 -0
- package/dist/types/excalidraw/components/Stack.d.ts +15 -0
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +11 -0
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +11 -0
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +11 -0
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +11 -0
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +45 -0
- package/dist/types/excalidraw/components/Stats/FontSize.d.ts +11 -0
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +11 -0
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +14 -0
- package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +12 -0
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +14 -0
- package/dist/types/excalidraw/components/Stats/Position.d.ts +12 -0
- package/dist/types/excalidraw/components/Stats/index.d.ts +36 -0
- package/dist/types/excalidraw/components/Stats/utils.d.ts +19 -0
- package/dist/types/excalidraw/components/Switch.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +6 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +30 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +8 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +17 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +4 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +8 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +7 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +33 -0
- package/dist/types/excalidraw/components/TextField.d.ts +21 -0
- package/dist/types/excalidraw/components/Toast.d.ts +9 -0
- package/dist/types/excalidraw/components/ToolButton.d.ts +49 -0
- package/dist/types/excalidraw/components/Tooltip.d.ts +18 -0
- package/dist/types/excalidraw/components/Trans.d.ts +9 -0
- package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/dist/types/excalidraw/components/UserList.d.ts +18 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +30 -0
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +14 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +19 -0
- package/dist/types/excalidraw/components/canvases/index.d.ts +3 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +86 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +15 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +11 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +46 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +8 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +18 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +7 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +16 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSeparator.d.ts +5 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +11 -0
- package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +6 -0
- package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +3 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +12 -0
- package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +8 -0
- package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +4 -0
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +19 -0
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +10 -0
- package/dist/types/excalidraw/components/icons.d.ts +225 -0
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +10 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +64 -0
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +83 -0
- package/dist/types/excalidraw/components/shapes.d.ts +62 -0
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +58 -0
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +19 -0
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +85 -0
- package/dist/types/excalidraw/context/tunnels.d.ts +21 -0
- package/dist/types/excalidraw/context/ui-appState.d.ts +4 -0
- package/dist/types/excalidraw/cursor.d.ts +5 -0
- package/dist/types/excalidraw/data/EditorLocalStorage.d.ts +8 -0
- package/dist/types/excalidraw/data/blob.d.ts +53 -0
- package/dist/types/excalidraw/data/encode.d.ts +55 -0
- package/dist/types/excalidraw/data/encryption.d.ts +9 -0
- package/dist/types/excalidraw/data/filesystem.d.ts +21 -0
- package/dist/types/excalidraw/data/image.d.ts +9 -0
- package/dist/types/excalidraw/data/index.d.ts +22 -0
- package/dist/types/excalidraw/data/json.d.ts +16 -0
- package/dist/types/excalidraw/data/library.d.ts +112 -0
- package/dist/types/excalidraw/data/reconcile.d.ts +6 -0
- package/dist/types/excalidraw/data/resave.d.ts +5 -0
- package/dist/types/excalidraw/data/restore.d.ts +21 -0
- package/dist/types/excalidraw/data/transform.d.ts +81 -0
- package/dist/types/excalidraw/data/types.d.ts +45 -0
- package/dist/types/excalidraw/deburr.d.ts +1 -0
- package/dist/types/excalidraw/editor-jotai.d.ts +56 -0
- package/dist/types/excalidraw/eraser/index.d.ts +12 -0
- package/dist/types/excalidraw/errors.d.ts +29 -0
- package/dist/types/excalidraw/fonts/Cascadia/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/ComicShanns/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/Emoji/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/ExcalidrawFontFace.d.ts +25 -0
- package/dist/types/excalidraw/fonts/Excalifont/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/Fonts.d.ts +79 -0
- package/dist/types/excalidraw/fonts/Helvetica/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/Liberation/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/Lilita/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/Nunito/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/Virgil/index.d.ts +2 -0
- package/dist/types/excalidraw/fonts/Xiaolai/index.d.ts +8 -0
- package/dist/types/excalidraw/fonts/index.d.ts +1 -0
- package/dist/types/excalidraw/gesture.d.ts +6 -0
- package/dist/types/excalidraw/history.d.ts +48 -0
- package/dist/types/excalidraw/hooks/useCallbackRefState.d.ts +1 -0
- package/dist/types/excalidraw/hooks/useCopiedIndicator.d.ts +5 -0
- package/dist/types/excalidraw/hooks/useCreatePortalContainer.d.ts +4 -0
- package/dist/types/excalidraw/hooks/useEmitter.d.ts +2 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +11 -0
- package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +20 -0
- package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +2 -0
- package/dist/types/excalidraw/hooks/useStable.d.ts +1 -0
- package/dist/types/excalidraw/hooks/useStableCallback.d.ts +4 -0
- package/dist/types/excalidraw/hooks/useTransition.d.ts +2 -0
- package/dist/types/excalidraw/i18n.d.ts +24 -0
- package/dist/types/excalidraw/index.d.ts +46 -0
- package/dist/types/excalidraw/laser-trails.d.ts +20 -0
- package/dist/types/excalidraw/lasso/index.d.ts +16 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +13 -0
- package/dist/types/excalidraw/mermaid.d.ts +2 -0
- package/dist/types/excalidraw/polyfill.d.ts +2 -0
- package/dist/types/excalidraw/reactUtils.d.ts +14 -0
- package/dist/types/excalidraw/renderer/helpers.d.ts +18 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +20 -0
- package/dist/types/excalidraw/renderer/renderNewElementScene.d.ts +7 -0
- package/dist/types/excalidraw/renderer/renderSnaps.d.ts +2 -0
- package/dist/types/excalidraw/renderer/roundRect.d.ts +11 -0
- package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -0
- package/dist/types/excalidraw/renderer/staticSvgScene.d.ts +5 -0
- package/dist/types/excalidraw/scene/Renderer.d.ts +27 -0
- package/dist/types/excalidraw/scene/export.d.ts +36 -0
- package/dist/types/excalidraw/scene/index.d.ts +4 -0
- package/dist/types/excalidraw/scene/normalize.d.ts +4 -0
- package/dist/types/excalidraw/scene/scroll.d.ts +23 -0
- package/dist/types/excalidraw/scene/scrollbars.d.ts +11 -0
- package/dist/types/excalidraw/scene/types.d.ts +120 -0
- package/dist/types/excalidraw/scene/zoom.d.ts +12 -0
- package/dist/types/excalidraw/snapping.d.ts +111 -0
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +45 -0
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +13 -0
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +2 -0
- package/dist/types/excalidraw/subset/subset-main.d.ts +12 -0
- package/dist/types/excalidraw/subset/subset-shared.chunk.d.ts +32 -0
- package/dist/types/excalidraw/subset/subset-worker.chunk.d.ts +15 -0
- package/dist/types/excalidraw/subset/woff2/woff2-bindings.d.ts +31 -0
- package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +14 -0
- package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +2 -0
- package/dist/types/excalidraw/types.d.ts +706 -0
- package/dist/types/excalidraw/workers.d.ts +36 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +24 -0
- package/dist/types/math/src/angle.d.ts +19 -0
- package/dist/types/math/src/constants.d.ts +3 -0
- package/dist/types/math/src/curve.d.ts +74 -0
- package/dist/types/math/src/ellipse.d.ts +44 -0
- package/dist/types/math/src/index.d.ts +13 -0
- package/dist/types/math/src/line.d.ts +17 -0
- package/dist/types/math/src/point.d.ts +122 -0
- package/dist/types/math/src/polygon.d.ts +6 -0
- package/dist/types/math/src/range.d.ts +44 -0
- package/dist/types/math/src/rectangle.d.ts +5 -0
- package/dist/types/math/src/segment.d.ts +39 -0
- package/dist/types/math/src/triangle.d.ts +11 -0
- package/dist/types/math/src/types.d.ts +106 -0
- package/dist/types/math/src/utils.d.ts +7 -0
- package/dist/types/math/src/vector.d.ts +94 -0
- package/dist/types/utils/src/bbox.d.ts +9 -0
- package/dist/types/utils/src/export.d.ts +35 -0
- package/dist/types/utils/src/index.d.ts +4 -0
- package/dist/types/utils/src/shape.d.ts +58 -0
- package/dist/types/utils/src/withinBounds.d.ts +19 -0
- package/package.json +66 -0
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
var PRECISION = 1e-4;
|
|
3
|
+
var clamp = (value, min, max) => {
|
|
4
|
+
return Math.min(Math.max(value, min), max);
|
|
5
|
+
};
|
|
6
|
+
var round = (value, precision, func = "round") => {
|
|
7
|
+
const multiplier = Math.pow(10, precision);
|
|
8
|
+
return Math[func]((value + Number.EPSILON) * multiplier) / multiplier;
|
|
9
|
+
};
|
|
10
|
+
var roundToStep = (value, step, func = "round") => {
|
|
11
|
+
const factor = 1 / step;
|
|
12
|
+
return Math[func](value * factor) / factor;
|
|
13
|
+
};
|
|
14
|
+
var average = (a, b) => (a + b) / 2;
|
|
15
|
+
var isFiniteNumber = (value) => {
|
|
16
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
17
|
+
};
|
|
18
|
+
var isCloseTo = (a, b, precision = PRECISION) => Math.abs(a - b) < precision;
|
|
19
|
+
|
|
20
|
+
// src/angle.ts
|
|
21
|
+
var normalizeRadians = (angle) => angle < 0 ? angle % (2 * Math.PI) + 2 * Math.PI : angle % (2 * Math.PI);
|
|
22
|
+
var cartesian2Polar = ([
|
|
23
|
+
x,
|
|
24
|
+
y
|
|
25
|
+
]) => [
|
|
26
|
+
Math.hypot(x, y),
|
|
27
|
+
normalizeRadians(Math.atan2(y, x))
|
|
28
|
+
];
|
|
29
|
+
function degreesToRadians(degrees) {
|
|
30
|
+
return degrees * Math.PI / 180;
|
|
31
|
+
}
|
|
32
|
+
function radiansToDegrees(degrees) {
|
|
33
|
+
return degrees * 180 / Math.PI;
|
|
34
|
+
}
|
|
35
|
+
function isRightAngleRads(rads) {
|
|
36
|
+
return Math.abs(Math.sin(2 * rads)) < PRECISION;
|
|
37
|
+
}
|
|
38
|
+
function radiansBetweenAngles(a, min, max) {
|
|
39
|
+
a = normalizeRadians(a);
|
|
40
|
+
min = normalizeRadians(min);
|
|
41
|
+
max = normalizeRadians(max);
|
|
42
|
+
if (min < max) {
|
|
43
|
+
return a >= min && a <= max;
|
|
44
|
+
}
|
|
45
|
+
return a >= min || a <= max;
|
|
46
|
+
}
|
|
47
|
+
function radiansDifference(a, b) {
|
|
48
|
+
a = normalizeRadians(a);
|
|
49
|
+
b = normalizeRadians(b);
|
|
50
|
+
let diff = a - b;
|
|
51
|
+
if (diff < -Math.PI) {
|
|
52
|
+
diff = diff + 2 * Math.PI;
|
|
53
|
+
} else if (diff > Math.PI) {
|
|
54
|
+
diff = diff - 2 * Math.PI;
|
|
55
|
+
}
|
|
56
|
+
return Math.abs(diff);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/vector.ts
|
|
60
|
+
function vector(x, y, originX = 0, originY = 0) {
|
|
61
|
+
return [x - originX, y - originY];
|
|
62
|
+
}
|
|
63
|
+
function vectorFromPoint(p, origin = [0, 0], threshold, defaultValue = [0, 1]) {
|
|
64
|
+
const vec = vector(p[0] - origin[0], p[1] - origin[1]);
|
|
65
|
+
if (threshold && vectorMagnitudeSq(vec) < threshold * threshold) {
|
|
66
|
+
return defaultValue;
|
|
67
|
+
}
|
|
68
|
+
return vec;
|
|
69
|
+
}
|
|
70
|
+
function vectorCross(a, b) {
|
|
71
|
+
return a[0] * b[1] - b[0] * a[1];
|
|
72
|
+
}
|
|
73
|
+
function vectorDot(a, b) {
|
|
74
|
+
return a[0] * b[0] + a[1] * b[1];
|
|
75
|
+
}
|
|
76
|
+
function isVector(v) {
|
|
77
|
+
return Array.isArray(v) && v.length === 2 && typeof v[0] === "number" && !isNaN(v[0]) && typeof v[1] === "number" && !isNaN(v[1]);
|
|
78
|
+
}
|
|
79
|
+
function vectorAdd(a, b) {
|
|
80
|
+
return [a[0] + b[0], a[1] + b[1]];
|
|
81
|
+
}
|
|
82
|
+
function vectorSubtract(start, end) {
|
|
83
|
+
return [start[0] - end[0], start[1] - end[1]];
|
|
84
|
+
}
|
|
85
|
+
function vectorScale(v, scalar) {
|
|
86
|
+
return vector(v[0] * scalar, v[1] * scalar);
|
|
87
|
+
}
|
|
88
|
+
function vectorMagnitudeSq(v) {
|
|
89
|
+
return v[0] * v[0] + v[1] * v[1];
|
|
90
|
+
}
|
|
91
|
+
function vectorMagnitude(v) {
|
|
92
|
+
return Math.sqrt(vectorMagnitudeSq(v));
|
|
93
|
+
}
|
|
94
|
+
var vectorNormalize = (v) => {
|
|
95
|
+
const m = vectorMagnitude(v);
|
|
96
|
+
if (m === 0) {
|
|
97
|
+
return vector(0, 0);
|
|
98
|
+
}
|
|
99
|
+
return vector(v[0] / m, v[1] / m);
|
|
100
|
+
};
|
|
101
|
+
var vectorNormal = (v) => vector(v[1], -v[0]);
|
|
102
|
+
|
|
103
|
+
// src/point.ts
|
|
104
|
+
function pointFrom(x, y) {
|
|
105
|
+
return [x, y];
|
|
106
|
+
}
|
|
107
|
+
function pointFromArray(numberArray) {
|
|
108
|
+
return numberArray.length === 2 ? pointFrom(numberArray[0], numberArray[1]) : void 0;
|
|
109
|
+
}
|
|
110
|
+
function pointFromPair(pair) {
|
|
111
|
+
return pair;
|
|
112
|
+
}
|
|
113
|
+
function pointFromVector(v, offset = pointFrom(0, 0)) {
|
|
114
|
+
return pointFrom(offset[0] + v[0], offset[1] + v[1]);
|
|
115
|
+
}
|
|
116
|
+
function isPoint(p) {
|
|
117
|
+
return Array.isArray(p) && p.length === 2 && typeof p[0] === "number" && !isNaN(p[0]) && typeof p[1] === "number" && !isNaN(p[1]);
|
|
118
|
+
}
|
|
119
|
+
function pointsEqual(a, b, tolerance = PRECISION) {
|
|
120
|
+
const abs = Math.abs;
|
|
121
|
+
return abs(a[0] - b[0]) < tolerance && abs(a[1] - b[1]) < tolerance;
|
|
122
|
+
}
|
|
123
|
+
function pointRotateRads([x, y], [cx, cy], angle) {
|
|
124
|
+
return pointFrom(
|
|
125
|
+
(x - cx) * Math.cos(angle) - (y - cy) * Math.sin(angle) + cx,
|
|
126
|
+
(x - cx) * Math.sin(angle) + (y - cy) * Math.cos(angle) + cy
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function pointRotateDegs(point, center, angle) {
|
|
130
|
+
return pointRotateRads(point, center, degreesToRadians(angle));
|
|
131
|
+
}
|
|
132
|
+
function pointTranslate(p, v = [0, 0]) {
|
|
133
|
+
return pointFrom(p[0] + v[0], p[1] + v[1]);
|
|
134
|
+
}
|
|
135
|
+
function pointCenter(a, b) {
|
|
136
|
+
return pointFrom((a[0] + b[0]) / 2, (a[1] + b[1]) / 2);
|
|
137
|
+
}
|
|
138
|
+
function pointDistance(a, b) {
|
|
139
|
+
return Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
140
|
+
}
|
|
141
|
+
function pointDistanceSq(a, b) {
|
|
142
|
+
const xDiff = b[0] - a[0];
|
|
143
|
+
const yDiff = b[1] - a[1];
|
|
144
|
+
return xDiff * xDiff + yDiff * yDiff;
|
|
145
|
+
}
|
|
146
|
+
var pointScaleFromOrigin = (p, mid, multiplier) => pointTranslate(mid, vectorScale(vectorFromPoint(p, mid), multiplier));
|
|
147
|
+
var isPointWithinBounds = (p, q, r) => {
|
|
148
|
+
return q[0] <= Math.max(p[0], r[0]) && q[0] >= Math.min(p[0], r[0]) && q[1] <= Math.max(p[1], r[1]) && q[1] >= Math.min(p[1], r[1]);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/constants.ts
|
|
152
|
+
var LegendreGaussN24TValues = [
|
|
153
|
+
-0.06405689286260563,
|
|
154
|
+
0.06405689286260563,
|
|
155
|
+
-0.1911188674736163,
|
|
156
|
+
0.1911188674736163,
|
|
157
|
+
-0.3150426796961634,
|
|
158
|
+
0.3150426796961634,
|
|
159
|
+
-0.4337935076260451,
|
|
160
|
+
0.4337935076260451,
|
|
161
|
+
-0.5454214713888396,
|
|
162
|
+
0.5454214713888396,
|
|
163
|
+
-0.6480936519369755,
|
|
164
|
+
0.6480936519369755,
|
|
165
|
+
-0.7401241915785544,
|
|
166
|
+
0.7401241915785544,
|
|
167
|
+
-0.820001985973903,
|
|
168
|
+
0.820001985973903,
|
|
169
|
+
-0.8864155270044011,
|
|
170
|
+
0.8864155270044011,
|
|
171
|
+
-0.9382745520027328,
|
|
172
|
+
0.9382745520027328,
|
|
173
|
+
-0.9747285559713095,
|
|
174
|
+
0.9747285559713095,
|
|
175
|
+
-0.9951872199970213,
|
|
176
|
+
0.9951872199970213
|
|
177
|
+
];
|
|
178
|
+
var LegendreGaussN24CValues = [
|
|
179
|
+
0.12793819534675216,
|
|
180
|
+
0.12793819534675216,
|
|
181
|
+
0.1258374563468283,
|
|
182
|
+
0.1258374563468283,
|
|
183
|
+
0.12167047292780339,
|
|
184
|
+
0.12167047292780339,
|
|
185
|
+
0.1155056680537256,
|
|
186
|
+
0.1155056680537256,
|
|
187
|
+
0.10744427011596563,
|
|
188
|
+
0.10744427011596563,
|
|
189
|
+
0.09761865210411388,
|
|
190
|
+
0.09761865210411388,
|
|
191
|
+
0.08619016153195327,
|
|
192
|
+
0.08619016153195327,
|
|
193
|
+
0.0733464814110803,
|
|
194
|
+
0.0733464814110803,
|
|
195
|
+
0.05929858491543678,
|
|
196
|
+
0.05929858491543678,
|
|
197
|
+
0.04427743881741981,
|
|
198
|
+
0.04427743881741981,
|
|
199
|
+
0.028531388628933663,
|
|
200
|
+
0.028531388628933663,
|
|
201
|
+
0.0123412297999872,
|
|
202
|
+
0.0123412297999872
|
|
203
|
+
];
|
|
204
|
+
|
|
205
|
+
// src/curve.ts
|
|
206
|
+
function curve(a, b, c, d) {
|
|
207
|
+
return [a, b, c, d];
|
|
208
|
+
}
|
|
209
|
+
function gradient(f, t0, s0, delta = 1e-6) {
|
|
210
|
+
return [
|
|
211
|
+
(f(t0 + delta, s0) - f(t0 - delta, s0)) / (2 * delta),
|
|
212
|
+
(f(t0, s0 + delta) - f(t0, s0 - delta)) / (2 * delta)
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
function solve(f, t0, s0, tolerance = 1e-3, iterLimit = 10) {
|
|
216
|
+
let error = Infinity;
|
|
217
|
+
let iter = 0;
|
|
218
|
+
while (error >= tolerance) {
|
|
219
|
+
if (iter >= iterLimit) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
const y0 = f(t0, s0);
|
|
223
|
+
const jacobian = [
|
|
224
|
+
gradient((t, s) => f(t, s)[0], t0, s0),
|
|
225
|
+
gradient((t, s) => f(t, s)[1], t0, s0)
|
|
226
|
+
];
|
|
227
|
+
const b = [[-y0[0]], [-y0[1]]];
|
|
228
|
+
const det = jacobian[0][0] * jacobian[1][1] - jacobian[0][1] * jacobian[1][0];
|
|
229
|
+
if (det === 0) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
const iJ = [
|
|
233
|
+
[jacobian[1][1] / det, -jacobian[0][1] / det],
|
|
234
|
+
[-jacobian[1][0] / det, jacobian[0][0] / det]
|
|
235
|
+
];
|
|
236
|
+
const h = [
|
|
237
|
+
[iJ[0][0] * b[0][0] + iJ[0][1] * b[1][0]],
|
|
238
|
+
[iJ[1][0] * b[0][0] + iJ[1][1] * b[1][0]]
|
|
239
|
+
];
|
|
240
|
+
t0 = t0 + h[0][0];
|
|
241
|
+
s0 = s0 + h[1][0];
|
|
242
|
+
const [tErr, sErr] = f(t0, s0);
|
|
243
|
+
error = Math.max(Math.abs(tErr), Math.abs(sErr));
|
|
244
|
+
iter += 1;
|
|
245
|
+
}
|
|
246
|
+
return [t0, s0];
|
|
247
|
+
}
|
|
248
|
+
var bezierEquation = (c, t) => pointFrom(
|
|
249
|
+
(1 - t) ** 3 * c[0][0] + 3 * (1 - t) ** 2 * t * c[1][0] + 3 * (1 - t) * t ** 2 * c[2][0] + t ** 3 * c[3][0],
|
|
250
|
+
(1 - t) ** 3 * c[0][1] + 3 * (1 - t) ** 2 * t * c[1][1] + 3 * (1 - t) * t ** 2 * c[2][1] + t ** 3 * c[3][1]
|
|
251
|
+
);
|
|
252
|
+
function curveIntersectLineSegment(c, l) {
|
|
253
|
+
const line2 = (s) => pointFrom(
|
|
254
|
+
l[0][0] + s * (l[1][0] - l[0][0]),
|
|
255
|
+
l[0][1] + s * (l[1][1] - l[0][1])
|
|
256
|
+
);
|
|
257
|
+
const initial_guesses = [
|
|
258
|
+
[0.5, 0],
|
|
259
|
+
[0.2, 0],
|
|
260
|
+
[0.8, 0]
|
|
261
|
+
];
|
|
262
|
+
const calculate = ([t0, s0]) => {
|
|
263
|
+
const solution2 = solve(
|
|
264
|
+
(t2, s2) => {
|
|
265
|
+
const bezier_point = bezierEquation(c, t2);
|
|
266
|
+
const line_point = line2(s2);
|
|
267
|
+
return [
|
|
268
|
+
bezier_point[0] - line_point[0],
|
|
269
|
+
bezier_point[1] - line_point[1]
|
|
270
|
+
];
|
|
271
|
+
},
|
|
272
|
+
t0,
|
|
273
|
+
s0
|
|
274
|
+
);
|
|
275
|
+
if (!solution2) {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
const [t, s] = solution2;
|
|
279
|
+
if (t < 0 || t > 1 || s < 0 || s > 1) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
return bezierEquation(c, t);
|
|
283
|
+
};
|
|
284
|
+
let solution = calculate(initial_guesses[0]);
|
|
285
|
+
if (solution) {
|
|
286
|
+
return [solution];
|
|
287
|
+
}
|
|
288
|
+
solution = calculate(initial_guesses[1]);
|
|
289
|
+
if (solution) {
|
|
290
|
+
return [solution];
|
|
291
|
+
}
|
|
292
|
+
solution = calculate(initial_guesses[2]);
|
|
293
|
+
if (solution) {
|
|
294
|
+
return [solution];
|
|
295
|
+
}
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
298
|
+
function curveClosestPoint(c, p, tolerance = 1e-3) {
|
|
299
|
+
const localMinimum = (min, max, f, e = tolerance) => {
|
|
300
|
+
let m = min;
|
|
301
|
+
let n = max;
|
|
302
|
+
let k;
|
|
303
|
+
while (n - m > e) {
|
|
304
|
+
k = (n + m) / 2;
|
|
305
|
+
if (f(k - e) < f(k + e)) {
|
|
306
|
+
n = k;
|
|
307
|
+
} else {
|
|
308
|
+
m = k;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return k;
|
|
312
|
+
};
|
|
313
|
+
const maxSteps = 30;
|
|
314
|
+
let closestStep = 0;
|
|
315
|
+
for (let min = Infinity, step = 0; step < maxSteps; step++) {
|
|
316
|
+
const d = pointDistance(p, bezierEquation(c, step / maxSteps));
|
|
317
|
+
if (d < min) {
|
|
318
|
+
min = d;
|
|
319
|
+
closestStep = step;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const t0 = Math.max((closestStep - 1) / maxSteps, 0);
|
|
323
|
+
const t1 = Math.min((closestStep + 1) / maxSteps, 1);
|
|
324
|
+
const solution = localMinimum(
|
|
325
|
+
t0,
|
|
326
|
+
t1,
|
|
327
|
+
(t) => pointDistance(p, bezierEquation(c, t))
|
|
328
|
+
);
|
|
329
|
+
if (!solution) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
return bezierEquation(c, solution);
|
|
333
|
+
}
|
|
334
|
+
function curvePointDistance(c, p) {
|
|
335
|
+
const closest = curveClosestPoint(c, p);
|
|
336
|
+
if (!closest) {
|
|
337
|
+
return 0;
|
|
338
|
+
}
|
|
339
|
+
return pointDistance(p, closest);
|
|
340
|
+
}
|
|
341
|
+
function isCurve(v) {
|
|
342
|
+
return Array.isArray(v) && v.length === 4 && isPoint(v[0]) && isPoint(v[1]) && isPoint(v[2]) && isPoint(v[3]);
|
|
343
|
+
}
|
|
344
|
+
function curveTangent([p0, p1, p2, p3], t) {
|
|
345
|
+
return vector(
|
|
346
|
+
-3 * (1 - t) * (1 - t) * p0[0] + 3 * (1 - t) * (1 - t) * p1[0] - 6 * t * (1 - t) * p1[0] - 3 * t * t * p2[0] + 6 * t * (1 - t) * p2[0] + 3 * t * t * p3[0],
|
|
347
|
+
-3 * (1 - t) * (1 - t) * p0[1] + 3 * (1 - t) * (1 - t) * p1[1] - 6 * t * (1 - t) * p1[1] - 3 * t * t * p2[1] + 6 * t * (1 - t) * p2[1] + 3 * t * t * p3[1]
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
function curveCatmullRomQuadraticApproxPoints(points, tension = 0.5) {
|
|
351
|
+
if (points.length < 2) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const pointSets = [];
|
|
355
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
356
|
+
const p0 = points[i - 1 < 0 ? 0 : i - 1];
|
|
357
|
+
const p1 = points[i];
|
|
358
|
+
const p2 = points[i + 1 >= points.length ? points.length - 1 : i + 1];
|
|
359
|
+
const cpX = p1[0] + (p2[0] - p0[0]) * tension / 2;
|
|
360
|
+
const cpY = p1[1] + (p2[1] - p0[1]) * tension / 2;
|
|
361
|
+
pointSets.push([
|
|
362
|
+
pointFrom(cpX, cpY),
|
|
363
|
+
pointFrom(p2[0], p2[1])
|
|
364
|
+
]);
|
|
365
|
+
}
|
|
366
|
+
return pointSets;
|
|
367
|
+
}
|
|
368
|
+
function curveCatmullRomCubicApproxPoints(points, tension = 0.5) {
|
|
369
|
+
if (points.length < 2) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
const pointSets = [];
|
|
373
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
374
|
+
const p0 = points[i - 1 < 0 ? 0 : i - 1];
|
|
375
|
+
const p1 = points[i];
|
|
376
|
+
const p2 = points[i + 1 >= points.length ? points.length - 1 : i + 1];
|
|
377
|
+
const p3 = points[i + 2 >= points.length ? points.length - 1 : i + 2];
|
|
378
|
+
const tangent1 = [(p2[0] - p0[0]) * tension, (p2[1] - p0[1]) * tension];
|
|
379
|
+
const tangent2 = [(p3[0] - p1[0]) * tension, (p3[1] - p1[1]) * tension];
|
|
380
|
+
const cp1x = p1[0] + tangent1[0] / 3;
|
|
381
|
+
const cp1y = p1[1] + tangent1[1] / 3;
|
|
382
|
+
const cp2x = p2[0] - tangent2[0] / 3;
|
|
383
|
+
const cp2y = p2[1] - tangent2[1] / 3;
|
|
384
|
+
pointSets.push(
|
|
385
|
+
curve(
|
|
386
|
+
pointFrom(p1[0], p1[1]),
|
|
387
|
+
pointFrom(cp1x, cp1y),
|
|
388
|
+
pointFrom(cp2x, cp2y),
|
|
389
|
+
pointFrom(p2[0], p2[1])
|
|
390
|
+
)
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
return pointSets;
|
|
394
|
+
}
|
|
395
|
+
function curveOffsetPoints([p0, p1, p2, p3], offset, steps = 50) {
|
|
396
|
+
const offsetPoints = [];
|
|
397
|
+
for (let i = 0; i <= steps; i++) {
|
|
398
|
+
const t = i / steps;
|
|
399
|
+
const c = curve(p0, p1, p2, p3);
|
|
400
|
+
const point = bezierEquation(c, t);
|
|
401
|
+
const tangent = vectorNormalize(curveTangent(c, t));
|
|
402
|
+
const normal = vectorNormal(tangent);
|
|
403
|
+
offsetPoints.push(pointFromVector(vectorScale(normal, offset), point));
|
|
404
|
+
}
|
|
405
|
+
return offsetPoints;
|
|
406
|
+
}
|
|
407
|
+
function offsetPointsForQuadraticBezier(p0, p1, p2, offsetDist, steps = 50) {
|
|
408
|
+
const offsetPoints = [];
|
|
409
|
+
for (let i = 0; i <= steps; i++) {
|
|
410
|
+
const t = i / steps;
|
|
411
|
+
const t1 = 1 - t;
|
|
412
|
+
const point = pointFrom(
|
|
413
|
+
t1 * t1 * p0[0] + 2 * t1 * t * p1[0] + t * t * p2[0],
|
|
414
|
+
t1 * t1 * p0[1] + 2 * t1 * t * p1[1] + t * t * p2[1]
|
|
415
|
+
);
|
|
416
|
+
const tangentX = 2 * (1 - t) * (p1[0] - p0[0]) + 2 * t * (p2[0] - p1[0]);
|
|
417
|
+
const tangentY = 2 * (1 - t) * (p1[1] - p0[1]) + 2 * t * (p2[1] - p1[1]);
|
|
418
|
+
const tangent = vectorNormalize(vector(tangentX, tangentY));
|
|
419
|
+
const normal = vectorNormal(tangent);
|
|
420
|
+
offsetPoints.push(pointFromVector(vectorScale(normal, offsetDist), point));
|
|
421
|
+
}
|
|
422
|
+
return offsetPoints;
|
|
423
|
+
}
|
|
424
|
+
function curveLength(c) {
|
|
425
|
+
const z2 = 0.5;
|
|
426
|
+
let sum = 0;
|
|
427
|
+
for (let i = 0; i < 24; i++) {
|
|
428
|
+
const t = z2 * LegendreGaussN24TValues[i] + z2;
|
|
429
|
+
const derivativeVector = curveTangent(c, t);
|
|
430
|
+
const magnitude = Math.sqrt(
|
|
431
|
+
derivativeVector[0] * derivativeVector[0] + derivativeVector[1] * derivativeVector[1]
|
|
432
|
+
);
|
|
433
|
+
sum += LegendreGaussN24CValues[i] * magnitude;
|
|
434
|
+
}
|
|
435
|
+
return z2 * sum;
|
|
436
|
+
}
|
|
437
|
+
function curveLengthAtParameter(c, t) {
|
|
438
|
+
if (t <= 0) {
|
|
439
|
+
return 0;
|
|
440
|
+
}
|
|
441
|
+
if (t >= 1) {
|
|
442
|
+
return curveLength(c);
|
|
443
|
+
}
|
|
444
|
+
const z1 = t / 2;
|
|
445
|
+
const z2 = t / 2;
|
|
446
|
+
let sum = 0;
|
|
447
|
+
for (let i = 0; i < 24; i++) {
|
|
448
|
+
const parameter = z1 * LegendreGaussN24TValues[i] + z2;
|
|
449
|
+
const derivativeVector = curveTangent(c, parameter);
|
|
450
|
+
const magnitude = Math.sqrt(
|
|
451
|
+
derivativeVector[0] * derivativeVector[0] + derivativeVector[1] * derivativeVector[1]
|
|
452
|
+
);
|
|
453
|
+
sum += LegendreGaussN24CValues[i] * magnitude;
|
|
454
|
+
}
|
|
455
|
+
return z1 * sum;
|
|
456
|
+
}
|
|
457
|
+
function curvePointAtLength(c, percent) {
|
|
458
|
+
if (percent <= 0) {
|
|
459
|
+
return bezierEquation(c, 0);
|
|
460
|
+
}
|
|
461
|
+
if (percent >= 1) {
|
|
462
|
+
return bezierEquation(c, 1);
|
|
463
|
+
}
|
|
464
|
+
const totalLength = curveLength(c);
|
|
465
|
+
const targetLength = totalLength * percent;
|
|
466
|
+
let tMin = 0;
|
|
467
|
+
let tMax = 1;
|
|
468
|
+
let t = percent;
|
|
469
|
+
let currentLength = 0;
|
|
470
|
+
const tolerance = totalLength * 1e-4;
|
|
471
|
+
const maxIterations = 20;
|
|
472
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
473
|
+
currentLength = curveLengthAtParameter(c, t);
|
|
474
|
+
const error = Math.abs(currentLength - targetLength);
|
|
475
|
+
if (error < tolerance) {
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
if (currentLength < targetLength) {
|
|
479
|
+
tMin = t;
|
|
480
|
+
} else {
|
|
481
|
+
tMax = t;
|
|
482
|
+
}
|
|
483
|
+
t = (tMin + tMax) / 2;
|
|
484
|
+
}
|
|
485
|
+
return bezierEquation(c, t);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// src/ellipse.ts
|
|
489
|
+
function ellipse(center, halfWidth, halfHeight) {
|
|
490
|
+
return {
|
|
491
|
+
center,
|
|
492
|
+
halfWidth,
|
|
493
|
+
halfHeight
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
var ellipseIncludesPoint = (p, ellipse2) => {
|
|
497
|
+
const { center, halfWidth, halfHeight } = ellipse2;
|
|
498
|
+
const normalizedX = (p[0] - center[0]) / halfWidth;
|
|
499
|
+
const normalizedY = (p[1] - center[1]) / halfHeight;
|
|
500
|
+
return normalizedX * normalizedX + normalizedY * normalizedY <= 1;
|
|
501
|
+
};
|
|
502
|
+
var ellipseTouchesPoint = (point, ellipse2, threshold = PRECISION) => {
|
|
503
|
+
return ellipseDistanceFromPoint(point, ellipse2) <= threshold;
|
|
504
|
+
};
|
|
505
|
+
var ellipseDistanceFromPoint = (p, ellipse2) => {
|
|
506
|
+
const { halfWidth, halfHeight, center } = ellipse2;
|
|
507
|
+
const a = halfWidth;
|
|
508
|
+
const b = halfHeight;
|
|
509
|
+
const translatedPoint = vectorAdd(
|
|
510
|
+
vectorFromPoint(p),
|
|
511
|
+
vectorScale(vectorFromPoint(center), -1)
|
|
512
|
+
);
|
|
513
|
+
const px = Math.abs(translatedPoint[0]);
|
|
514
|
+
const py = Math.abs(translatedPoint[1]);
|
|
515
|
+
let tx = 0.707;
|
|
516
|
+
let ty = 0.707;
|
|
517
|
+
for (let i = 0; i < 3; i++) {
|
|
518
|
+
const x = a * tx;
|
|
519
|
+
const y = b * ty;
|
|
520
|
+
const ex = (a * a - b * b) * tx ** 3 / a;
|
|
521
|
+
const ey = (b * b - a * a) * ty ** 3 / b;
|
|
522
|
+
const rx = x - ex;
|
|
523
|
+
const ry = y - ey;
|
|
524
|
+
const qx = px - ex;
|
|
525
|
+
const qy = py - ey;
|
|
526
|
+
const r = Math.hypot(ry, rx);
|
|
527
|
+
const q = Math.hypot(qy, qx);
|
|
528
|
+
tx = Math.min(1, Math.max(0, (qx * r / q + ex) / a));
|
|
529
|
+
ty = Math.min(1, Math.max(0, (qy * r / q + ey) / b));
|
|
530
|
+
const t = Math.hypot(ty, tx);
|
|
531
|
+
tx /= t;
|
|
532
|
+
ty /= t;
|
|
533
|
+
}
|
|
534
|
+
const [minX, minY] = [
|
|
535
|
+
a * tx * Math.sign(translatedPoint[0]),
|
|
536
|
+
b * ty * Math.sign(translatedPoint[1])
|
|
537
|
+
];
|
|
538
|
+
return pointDistance(pointFromVector(translatedPoint), pointFrom(minX, minY));
|
|
539
|
+
};
|
|
540
|
+
function ellipseSegmentInterceptPoints(e, s) {
|
|
541
|
+
const rx = e.halfWidth;
|
|
542
|
+
const ry = e.halfHeight;
|
|
543
|
+
const dir = vectorFromPoint(s[1], s[0]);
|
|
544
|
+
const diff = vector(s[0][0] - e.center[0], s[0][1] - e.center[1]);
|
|
545
|
+
const mDir = vector(dir[0] / (rx * rx), dir[1] / (ry * ry));
|
|
546
|
+
const mDiff = vector(diff[0] / (rx * rx), diff[1] / (ry * ry));
|
|
547
|
+
const a = vectorDot(dir, mDir);
|
|
548
|
+
const b = vectorDot(dir, mDiff);
|
|
549
|
+
const c = vectorDot(diff, mDiff) - 1;
|
|
550
|
+
const d = b * b - a * c;
|
|
551
|
+
const intersections = [];
|
|
552
|
+
if (d > 0) {
|
|
553
|
+
const t_a = (-b - Math.sqrt(d)) / a;
|
|
554
|
+
const t_b = (-b + Math.sqrt(d)) / a;
|
|
555
|
+
if (0 <= t_a && t_a <= 1) {
|
|
556
|
+
intersections.push(
|
|
557
|
+
pointFrom(
|
|
558
|
+
s[0][0] + (s[1][0] - s[0][0]) * t_a,
|
|
559
|
+
s[0][1] + (s[1][1] - s[0][1]) * t_a
|
|
560
|
+
)
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
if (0 <= t_b && t_b <= 1) {
|
|
564
|
+
intersections.push(
|
|
565
|
+
pointFrom(
|
|
566
|
+
s[0][0] + (s[1][0] - s[0][0]) * t_b,
|
|
567
|
+
s[0][1] + (s[1][1] - s[0][1]) * t_b
|
|
568
|
+
)
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
} else if (d === 0) {
|
|
572
|
+
const t = -b / a;
|
|
573
|
+
if (0 <= t && t <= 1) {
|
|
574
|
+
intersections.push(
|
|
575
|
+
pointFrom(
|
|
576
|
+
s[0][0] + (s[1][0] - s[0][0]) * t,
|
|
577
|
+
s[0][1] + (s[1][1] - s[0][1]) * t
|
|
578
|
+
)
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return intersections;
|
|
583
|
+
}
|
|
584
|
+
function ellipseLineIntersectionPoints({ center, halfWidth, halfHeight }, [g, h]) {
|
|
585
|
+
const [cx, cy] = center;
|
|
586
|
+
const x1 = g[0] - cx;
|
|
587
|
+
const y1 = g[1] - cy;
|
|
588
|
+
const x2 = h[0] - cx;
|
|
589
|
+
const y2 = h[1] - cy;
|
|
590
|
+
const a = Math.pow(x2 - x1, 2) / Math.pow(halfWidth, 2) + Math.pow(y2 - y1, 2) / Math.pow(halfHeight, 2);
|
|
591
|
+
const b = 2 * (x1 * (x2 - x1) / Math.pow(halfWidth, 2) + y1 * (y2 - y1) / Math.pow(halfHeight, 2));
|
|
592
|
+
const c = Math.pow(x1, 2) / Math.pow(halfWidth, 2) + Math.pow(y1, 2) / Math.pow(halfHeight, 2) - 1;
|
|
593
|
+
const t1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
|
|
594
|
+
const t2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
|
|
595
|
+
const candidates = [
|
|
596
|
+
pointFrom(x1 + t1 * (x2 - x1) + cx, y1 + t1 * (y2 - y1) + cy),
|
|
597
|
+
pointFrom(x1 + t2 * (x2 - x1) + cx, y1 + t2 * (y2 - y1) + cy)
|
|
598
|
+
].filter((p) => !isNaN(p[0]) && !isNaN(p[1]));
|
|
599
|
+
if (candidates.length === 2 && pointsEqual(candidates[0], candidates[1])) {
|
|
600
|
+
return [candidates[0]];
|
|
601
|
+
}
|
|
602
|
+
return candidates;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// src/line.ts
|
|
606
|
+
function line(a, b) {
|
|
607
|
+
return [a, b];
|
|
608
|
+
}
|
|
609
|
+
function linesIntersectAt(a, b) {
|
|
610
|
+
const A1 = a[1][1] - a[0][1];
|
|
611
|
+
const B1 = a[0][0] - a[1][0];
|
|
612
|
+
const A2 = b[1][1] - b[0][1];
|
|
613
|
+
const B2 = b[0][0] - b[1][0];
|
|
614
|
+
const D = A1 * B2 - A2 * B1;
|
|
615
|
+
if (D !== 0) {
|
|
616
|
+
const C1 = A1 * a[0][0] + B1 * a[0][1];
|
|
617
|
+
const C2 = A2 * b[0][0] + B2 * b[0][1];
|
|
618
|
+
return pointFrom((C1 * B2 - C2 * B1) / D, (A1 * C2 - A2 * C1) / D);
|
|
619
|
+
}
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
// src/segment.ts
|
|
624
|
+
function lineSegment(a, b) {
|
|
625
|
+
return [a, b];
|
|
626
|
+
}
|
|
627
|
+
var isLineSegment = (segment) => Array.isArray(segment) && segment.length === 2 && isPoint(segment[0]) && isPoint(segment[0]);
|
|
628
|
+
var lineSegmentRotate = (l, angle, origin) => {
|
|
629
|
+
return lineSegment(
|
|
630
|
+
pointRotateRads(l[0], origin || pointCenter(l[0], l[1]), angle),
|
|
631
|
+
pointRotateRads(l[1], origin || pointCenter(l[0], l[1]), angle)
|
|
632
|
+
);
|
|
633
|
+
};
|
|
634
|
+
var segmentsIntersectAt = (a, b) => {
|
|
635
|
+
const a0 = vectorFromPoint(a[0]);
|
|
636
|
+
const a1 = vectorFromPoint(a[1]);
|
|
637
|
+
const b0 = vectorFromPoint(b[0]);
|
|
638
|
+
const b1 = vectorFromPoint(b[1]);
|
|
639
|
+
const r = vectorSubtract(a1, a0);
|
|
640
|
+
const s = vectorSubtract(b1, b0);
|
|
641
|
+
const denominator = vectorCross(r, s);
|
|
642
|
+
if (denominator === 0) {
|
|
643
|
+
return null;
|
|
644
|
+
}
|
|
645
|
+
const i = vectorSubtract(vectorFromPoint(b[0]), vectorFromPoint(a[0]));
|
|
646
|
+
const u = vectorCross(i, r) / denominator;
|
|
647
|
+
const t = vectorCross(i, s) / denominator;
|
|
648
|
+
if (u === 0) {
|
|
649
|
+
return null;
|
|
650
|
+
}
|
|
651
|
+
const p = vectorAdd(a0, vectorScale(r, t));
|
|
652
|
+
if (t >= 0 && t < 1 && u >= 0 && u < 1) {
|
|
653
|
+
return pointFromVector(p);
|
|
654
|
+
}
|
|
655
|
+
return null;
|
|
656
|
+
};
|
|
657
|
+
var pointOnLineSegment = (point, line2, threshold = PRECISION) => {
|
|
658
|
+
const distance = distanceToLineSegment(point, line2);
|
|
659
|
+
if (distance === 0) {
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
return distance < threshold;
|
|
663
|
+
};
|
|
664
|
+
var distanceToLineSegment = (point, line2) => {
|
|
665
|
+
const [x, y] = point;
|
|
666
|
+
const [[x1, y1], [x2, y2]] = line2;
|
|
667
|
+
const A = x - x1;
|
|
668
|
+
const B = y - y1;
|
|
669
|
+
const C = x2 - x1;
|
|
670
|
+
const D = y2 - y1;
|
|
671
|
+
const dot = A * C + B * D;
|
|
672
|
+
const len_sq = C * C + D * D;
|
|
673
|
+
let param = -1;
|
|
674
|
+
if (len_sq !== 0) {
|
|
675
|
+
param = dot / len_sq;
|
|
676
|
+
}
|
|
677
|
+
let xx;
|
|
678
|
+
let yy;
|
|
679
|
+
if (param < 0) {
|
|
680
|
+
xx = x1;
|
|
681
|
+
yy = y1;
|
|
682
|
+
} else if (param > 1) {
|
|
683
|
+
xx = x2;
|
|
684
|
+
yy = y2;
|
|
685
|
+
} else {
|
|
686
|
+
xx = x1 + param * C;
|
|
687
|
+
yy = y1 + param * D;
|
|
688
|
+
}
|
|
689
|
+
const dx = x - xx;
|
|
690
|
+
const dy = y - yy;
|
|
691
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
692
|
+
};
|
|
693
|
+
function lineSegmentIntersectionPoints(l, s, threshold) {
|
|
694
|
+
const candidate = linesIntersectAt(line(l[0], l[1]), line(s[0], s[1]));
|
|
695
|
+
if (!candidate || !pointOnLineSegment(candidate, s, threshold) || !pointOnLineSegment(candidate, l, threshold)) {
|
|
696
|
+
return null;
|
|
697
|
+
}
|
|
698
|
+
return candidate;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/polygon.ts
|
|
702
|
+
function polygon(...points) {
|
|
703
|
+
return polygonClose(points);
|
|
704
|
+
}
|
|
705
|
+
function polygonFromPoints(points) {
|
|
706
|
+
return polygonClose(points);
|
|
707
|
+
}
|
|
708
|
+
var polygonIncludesPoint = (point, polygon2) => {
|
|
709
|
+
const x = point[0];
|
|
710
|
+
const y = point[1];
|
|
711
|
+
let inside = false;
|
|
712
|
+
for (let i = 0, j = polygon2.length - 1; i < polygon2.length; j = i++) {
|
|
713
|
+
const xi = polygon2[i][0];
|
|
714
|
+
const yi = polygon2[i][1];
|
|
715
|
+
const xj = polygon2[j][0];
|
|
716
|
+
const yj = polygon2[j][1];
|
|
717
|
+
if ((yi > y && yj <= y || yi <= y && yj > y) && x < (xj - xi) * (y - yi) / (yj - yi) + xi) {
|
|
718
|
+
inside = !inside;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return inside;
|
|
722
|
+
};
|
|
723
|
+
var polygonIncludesPointNonZero = (point, polygon2) => {
|
|
724
|
+
const [x, y] = point;
|
|
725
|
+
let windingNumber = 0;
|
|
726
|
+
for (let i = 0; i < polygon2.length; i++) {
|
|
727
|
+
const j = (i + 1) % polygon2.length;
|
|
728
|
+
const [xi, yi] = polygon2[i];
|
|
729
|
+
const [xj, yj] = polygon2[j];
|
|
730
|
+
if (yi <= y) {
|
|
731
|
+
if (yj > y) {
|
|
732
|
+
if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) > 0) {
|
|
733
|
+
windingNumber++;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
} else if (yj <= y) {
|
|
737
|
+
if ((xj - xi) * (y - yi) - (x - xi) * (yj - yi) < 0) {
|
|
738
|
+
windingNumber--;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return windingNumber !== 0;
|
|
743
|
+
};
|
|
744
|
+
var pointOnPolygon = (p, poly, threshold = PRECISION) => {
|
|
745
|
+
let on = false;
|
|
746
|
+
for (let i = 0, l = poly.length - 1; i < l; i++) {
|
|
747
|
+
if (pointOnLineSegment(p, lineSegment(poly[i], poly[i + 1]), threshold)) {
|
|
748
|
+
on = true;
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return on;
|
|
753
|
+
};
|
|
754
|
+
function polygonClose(polygon2) {
|
|
755
|
+
return polygonIsClosed(polygon2) ? polygon2 : [...polygon2, polygon2[0]];
|
|
756
|
+
}
|
|
757
|
+
function polygonIsClosed(polygon2) {
|
|
758
|
+
return pointsEqual(polygon2[0], polygon2[polygon2.length - 1]);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// src/range.ts
|
|
762
|
+
import { toBrandedType } from "@excalidraw/common";
|
|
763
|
+
function rangeInclusive(start, end) {
|
|
764
|
+
return toBrandedType([start, end]);
|
|
765
|
+
}
|
|
766
|
+
function rangeInclusiveFromPair(pair) {
|
|
767
|
+
return toBrandedType(pair);
|
|
768
|
+
}
|
|
769
|
+
var rangesOverlap = ([a0, a1], [b0, b1]) => {
|
|
770
|
+
if (a0 <= b0) {
|
|
771
|
+
return a1 >= b0;
|
|
772
|
+
}
|
|
773
|
+
if (a0 >= b0) {
|
|
774
|
+
return b1 >= a0;
|
|
775
|
+
}
|
|
776
|
+
return false;
|
|
777
|
+
};
|
|
778
|
+
var rangeIntersection = ([a0, a1], [b0, b1]) => {
|
|
779
|
+
const rangeStart = Math.max(a0, b0);
|
|
780
|
+
const rangeEnd = Math.min(a1, b1);
|
|
781
|
+
if (rangeStart <= rangeEnd) {
|
|
782
|
+
return toBrandedType([rangeStart, rangeEnd]);
|
|
783
|
+
}
|
|
784
|
+
return null;
|
|
785
|
+
};
|
|
786
|
+
var rangeIncludesValue = (value, [min, max]) => {
|
|
787
|
+
return value >= min && value <= max;
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
// src/rectangle.ts
|
|
791
|
+
function rectangle(topLeft, bottomRight) {
|
|
792
|
+
return [topLeft, bottomRight];
|
|
793
|
+
}
|
|
794
|
+
function rectangleFromNumberSequence(minX, minY, maxX, maxY) {
|
|
795
|
+
return rectangle(pointFrom(minX, minY), pointFrom(maxX, maxY));
|
|
796
|
+
}
|
|
797
|
+
function rectangleIntersectLineSegment(r, l) {
|
|
798
|
+
return [
|
|
799
|
+
lineSegment(r[0], pointFrom(r[1][0], r[0][1])),
|
|
800
|
+
lineSegment(pointFrom(r[1][0], r[0][1]), r[1]),
|
|
801
|
+
lineSegment(r[1], pointFrom(r[0][0], r[1][1])),
|
|
802
|
+
lineSegment(pointFrom(r[0][0], r[1][1]), r[0])
|
|
803
|
+
].map((s) => lineSegmentIntersectionPoints(l, s)).filter((i) => !!i);
|
|
804
|
+
}
|
|
805
|
+
function rectangleIntersectRectangle(rectangle1, rectangle2) {
|
|
806
|
+
const [[minX1, minY1], [maxX1, maxY1]] = rectangle1;
|
|
807
|
+
const [[minX2, minY2], [maxX2, maxY2]] = rectangle2;
|
|
808
|
+
return minX1 < maxX2 && maxX1 > minX2 && minY1 < maxY2 && maxY1 > minY2;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// src/triangle.ts
|
|
812
|
+
function triangleIncludesPoint([a, b, c], p) {
|
|
813
|
+
const triangleSign = (p1, p2, p3) => (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1]);
|
|
814
|
+
const d1 = triangleSign(p, a, b);
|
|
815
|
+
const d2 = triangleSign(p, b, c);
|
|
816
|
+
const d3 = triangleSign(p, c, a);
|
|
817
|
+
const has_neg = d1 < 0 || d2 < 0 || d3 < 0;
|
|
818
|
+
const has_pos = d1 > 0 || d2 > 0 || d3 > 0;
|
|
819
|
+
return !(has_neg && has_pos);
|
|
820
|
+
}
|
|
821
|
+
export {
|
|
822
|
+
PRECISION,
|
|
823
|
+
average,
|
|
824
|
+
bezierEquation,
|
|
825
|
+
cartesian2Polar,
|
|
826
|
+
clamp,
|
|
827
|
+
curve,
|
|
828
|
+
curveCatmullRomCubicApproxPoints,
|
|
829
|
+
curveCatmullRomQuadraticApproxPoints,
|
|
830
|
+
curveClosestPoint,
|
|
831
|
+
curveIntersectLineSegment,
|
|
832
|
+
curveLength,
|
|
833
|
+
curveLengthAtParameter,
|
|
834
|
+
curveOffsetPoints,
|
|
835
|
+
curvePointAtLength,
|
|
836
|
+
curvePointDistance,
|
|
837
|
+
curveTangent,
|
|
838
|
+
degreesToRadians,
|
|
839
|
+
distanceToLineSegment,
|
|
840
|
+
ellipse,
|
|
841
|
+
ellipseDistanceFromPoint,
|
|
842
|
+
ellipseIncludesPoint,
|
|
843
|
+
ellipseLineIntersectionPoints,
|
|
844
|
+
ellipseSegmentInterceptPoints,
|
|
845
|
+
ellipseTouchesPoint,
|
|
846
|
+
isCloseTo,
|
|
847
|
+
isCurve,
|
|
848
|
+
isFiniteNumber,
|
|
849
|
+
isLineSegment,
|
|
850
|
+
isPoint,
|
|
851
|
+
isPointWithinBounds,
|
|
852
|
+
isRightAngleRads,
|
|
853
|
+
isVector,
|
|
854
|
+
line,
|
|
855
|
+
lineSegment,
|
|
856
|
+
lineSegmentIntersectionPoints,
|
|
857
|
+
lineSegmentRotate,
|
|
858
|
+
linesIntersectAt,
|
|
859
|
+
normalizeRadians,
|
|
860
|
+
offsetPointsForQuadraticBezier,
|
|
861
|
+
pointCenter,
|
|
862
|
+
pointDistance,
|
|
863
|
+
pointDistanceSq,
|
|
864
|
+
pointFrom,
|
|
865
|
+
pointFromArray,
|
|
866
|
+
pointFromPair,
|
|
867
|
+
pointFromVector,
|
|
868
|
+
pointOnLineSegment,
|
|
869
|
+
pointOnPolygon,
|
|
870
|
+
pointRotateDegs,
|
|
871
|
+
pointRotateRads,
|
|
872
|
+
pointScaleFromOrigin,
|
|
873
|
+
pointTranslate,
|
|
874
|
+
pointsEqual,
|
|
875
|
+
polygon,
|
|
876
|
+
polygonFromPoints,
|
|
877
|
+
polygonIncludesPoint,
|
|
878
|
+
polygonIncludesPointNonZero,
|
|
879
|
+
radiansBetweenAngles,
|
|
880
|
+
radiansDifference,
|
|
881
|
+
radiansToDegrees,
|
|
882
|
+
rangeIncludesValue,
|
|
883
|
+
rangeInclusive,
|
|
884
|
+
rangeInclusiveFromPair,
|
|
885
|
+
rangeIntersection,
|
|
886
|
+
rangesOverlap,
|
|
887
|
+
rectangle,
|
|
888
|
+
rectangleFromNumberSequence,
|
|
889
|
+
rectangleIntersectLineSegment,
|
|
890
|
+
rectangleIntersectRectangle,
|
|
891
|
+
round,
|
|
892
|
+
roundToStep,
|
|
893
|
+
segmentsIntersectAt,
|
|
894
|
+
triangleIncludesPoint,
|
|
895
|
+
vector,
|
|
896
|
+
vectorAdd,
|
|
897
|
+
vectorCross,
|
|
898
|
+
vectorDot,
|
|
899
|
+
vectorFromPoint,
|
|
900
|
+
vectorMagnitude,
|
|
901
|
+
vectorMagnitudeSq,
|
|
902
|
+
vectorNormal,
|
|
903
|
+
vectorNormalize,
|
|
904
|
+
vectorScale,
|
|
905
|
+
vectorSubtract
|
|
906
|
+
};
|
|
907
|
+
//# sourceMappingURL=index.js.map
|