@excalidraw/math 0.18.0-3085f4a → 0.18.0-39103bd
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/dist/dev/index.js +348 -148
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +1 -1
- package/dist/types/common/debug.d.ts +21 -0
- package/dist/types/common/src/appEventBus.d.ts +27 -0
- package/dist/types/common/src/bounds.d.ts +10 -0
- package/dist/types/common/src/colors.d.ts +59 -39
- package/dist/types/common/src/constants.d.ts +47 -34
- package/dist/types/common/src/editorInterface.d.ts +34 -0
- package/dist/types/common/src/font-metadata.d.ts +1 -3
- package/dist/types/common/src/index.d.ts +5 -0
- package/dist/types/common/src/keys.d.ts +1 -1
- package/dist/types/common/src/points.d.ts +1 -1
- package/dist/types/common/src/utility-types.d.ts +0 -1
- package/dist/types/common/src/utils.d.ts +47 -77
- package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
- package/dist/types/element/src/Scene.d.ts +11 -7
- package/dist/types/element/src/align.d.ts +2 -2
- package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/arrows/focus.d.ts +30 -0
- package/dist/types/element/src/arrows/helpers.d.ts +5 -0
- package/dist/types/element/src/binding.d.ts +79 -51
- package/dist/types/element/src/bounds.d.ts +26 -19
- package/dist/types/element/src/collision.d.ts +7 -2
- package/dist/types/element/src/comparisons.d.ts +8 -7
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/distribute.d.ts +3 -2
- package/dist/types/element/src/dragElements.d.ts +30 -3
- package/dist/types/element/src/duplicate.d.ts +7 -6
- package/dist/types/element/src/elbowArrow.d.ts +2 -0
- package/dist/types/element/src/embeddable.d.ts +2 -2
- package/dist/types/element/src/flowchart.d.ts +7 -7
- package/dist/types/element/src/fractionalIndex.d.ts +4 -4
- package/dist/types/element/src/frame.d.ts +14 -9
- package/dist/types/element/src/groups.d.ts +9 -9
- package/dist/types/element/src/heading.d.ts +2 -1
- package/dist/types/element/src/image.d.ts +1 -11
- package/dist/types/element/src/index.d.ts +8 -4
- package/dist/types/element/src/linearElementEditor.d.ts +38 -30
- package/dist/types/element/src/mutateElement.d.ts +5 -1
- package/dist/types/element/src/newElement.d.ts +20 -6
- package/dist/types/element/src/positionElementsOnGrid.d.ts +2 -0
- package/dist/types/element/src/renderElement.d.ts +4 -10
- package/dist/types/element/src/resizeElements.d.ts +12 -12
- package/dist/types/element/src/resizeTest.d.ts +6 -5
- package/dist/types/element/src/selection.d.ts +14 -14
- package/dist/types/element/src/shape.d.ts +9 -8
- package/dist/types/element/src/textElement.d.ts +14 -11
- package/dist/types/element/src/textMeasurements.d.ts +1 -3
- package/dist/types/element/src/textWrapping.d.ts +26 -0
- package/dist/types/{excalidraw/data → element/src}/transform.d.ts +3 -3
- package/dist/types/element/src/transformHandles.d.ts +8 -27
- package/dist/types/element/src/typeChecks.d.ts +29 -31
- package/dist/types/element/src/types.d.ts +20 -14
- package/dist/types/element/src/utils.d.ts +9 -4
- package/dist/types/element/src/zindex.d.ts +7 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +191 -213
- package/dist/types/excalidraw/actions/actionAlign.d.ts +12 -13
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +112 -127
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +412 -1564
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +139 -895
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +54 -62
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +177 -202
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +162 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -6
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +3 -4
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +61 -75
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +111 -126
- package/dist/types/excalidraw/actions/actionExport.d.ts +190 -1410
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -394
- package/dist/types/excalidraw/actions/actionFlip.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionFrame.d.ts +253 -498
- package/dist/types/excalidraw/actions/actionGroup.d.ts +122 -145
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +151 -195
- package/dist/types/excalidraw/actions/actionLink.d.ts +67 -75
- package/dist/types/excalidraw/actions/actionMenu.d.ts +56 -436
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +18 -359
- package/dist/types/excalidraw/actions/actionProperties.d.ts +191 -2527
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +61 -73
- package/dist/types/excalidraw/actions/actionStyles.d.ts +54 -61
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +178 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +69 -78
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +178 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +68 -76
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +57 -72
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +67 -75
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +68 -76
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +68 -76
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -9
- package/dist/types/excalidraw/actions/index.d.ts +5 -3
- package/dist/types/excalidraw/actions/manager.d.ts +1 -0
- package/dist/types/excalidraw/actions/register.d.ts +2 -2
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +11 -7
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +34 -25
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
- package/dist/types/excalidraw/charts/index.d.ts +7 -0
- package/dist/types/excalidraw/clipboard.d.ts +57 -19
- package/dist/types/excalidraw/components/Actions.d.ts +33 -11
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.arrowText.d.ts +72 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +31 -0
- package/dist/types/excalidraw/components/App.d.ts +444 -123
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +73 -0
- package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
- package/dist/types/excalidraw/components/Card.d.ts +1 -3
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -4
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -2
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -1
- package/dist/types/excalidraw/components/CommandPalette/CommandPalette.d.ts +1 -0
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +2 -4
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +4 -4
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
- package/dist/types/excalidraw/components/DefaultSidebar.d.ts +9 -13
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/Ellipsify.d.ts +1 -2
- package/dist/types/excalidraw/components/ErrorDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -2
- package/dist/types/excalidraw/components/FilledButton.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +2 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +3 -1
- package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +0 -1
- package/dist/types/excalidraw/components/HelpDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
- package/dist/types/excalidraw/components/{ToolButton.d.ts → IconButton.d.ts} +16 -19
- package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
- package/dist/types/excalidraw/components/InlineIcon.d.ts +3 -1
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
- package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuControlButtons.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuHeaderContent.d.ts +1 -2
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +2 -3
- package/dist/types/excalidraw/components/LoadingMessage.d.ts +0 -1
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- package/dist/types/excalidraw/components/MobileMenu.d.ts +5 -7
- package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
- package/dist/types/excalidraw/components/Modal.d.ts +0 -1
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +1 -1
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
- package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
- package/dist/types/excalidraw/components/Popover.d.ts +2 -3
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +2 -1
- package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
- package/dist/types/excalidraw/components/RadioGroup.d.ts +0 -1
- package/dist/types/excalidraw/components/RadioSelection.d.ts +4 -4
- package/dist/types/excalidraw/components/Range.d.ts +10 -4
- package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/types/excalidraw/components/ScrollableList.d.ts +0 -1
- package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +16 -22
- package/dist/types/excalidraw/components/Sidebar/SidebarHeader.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/SidebarTab.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +1 -2
- package/dist/types/excalidraw/components/Sidebar/SidebarTabs.d.ts +1 -2
- package/dist/types/excalidraw/components/Spinner.d.ts +4 -4
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +0 -1
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -3
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/index.d.ts +7 -8
- package/dist/types/excalidraw/components/Stats/utils.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatHistoryMenu.d.ts +15 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +23 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/ChatMessage.d.ts +14 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +27 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/index.d.ts +3 -0
- package/dist/types/excalidraw/components/TTDDialog/Chat/useChatAgent.d.ts +8 -0
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +3 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +13 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +12 -29
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +13 -9
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +1 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +9 -0
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +16 -16
- package/dist/types/excalidraw/components/TTDDialog/hooks/useChatManagement.d.ts +13 -0
- package/dist/types/excalidraw/components/TTDDialog/hooks/useMermaidRenderer.d.ts +14 -0
- package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +7 -0
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +95 -0
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +22 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/chat.d.ts +10 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidValidation.d.ts +1 -0
- package/dist/types/excalidraw/components/TextField.d.ts +1 -0
- package/dist/types/excalidraw/components/Toast.d.ts +11 -7
- package/dist/types/excalidraw/components/ToolPopover.d.ts +22 -0
- package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
- package/dist/types/excalidraw/components/Tools.d.ts +145 -0
- package/dist/types/excalidraw/components/Trans.d.ts +2 -2
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +10 -4
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +47 -35
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +7 -5
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +3 -3
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +13 -22
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +5 -4
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +6 -6
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +3 -4
- package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +2 -2
- package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hoc/withInternalFallback.d.ts +1 -1
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +3 -3
- package/dist/types/excalidraw/components/icons.d.ts +52 -22
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +24 -3
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +39 -35
- package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
- package/dist/types/excalidraw/data/blob.d.ts +339 -12
- package/dist/types/excalidraw/data/encode.d.ts +4 -4
- package/dist/types/excalidraw/data/encryption.d.ts +5 -5
- package/dist/types/excalidraw/data/filesystem.d.ts +5 -7
- package/dist/types/excalidraw/data/index.d.ts +8 -9
- package/dist/types/excalidraw/data/json.d.ts +175 -3
- package/dist/types/excalidraw/data/library.d.ts +25 -10
- package/dist/types/excalidraw/data/resave.d.ts +7 -2
- package/dist/types/excalidraw/data/restore.d.ts +25 -10
- package/dist/types/excalidraw/data/types.d.ts +4 -1
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- package/dist/types/excalidraw/editor-jotai.d.ts +11 -11
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- package/dist/types/excalidraw/errors.d.ts +14 -0
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +2 -2
- package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +4 -3
- package/dist/types/excalidraw/hooks/useScrollPosition.d.ts +1 -2
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +14 -0
- package/dist/types/excalidraw/i18n.d.ts +2 -2
- package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
- package/dist/types/excalidraw/lasso/index.d.ts +2 -3
- package/dist/types/excalidraw/renderer/animation.d.ts +16 -0
- package/dist/types/excalidraw/renderer/helpers.d.ts +6 -8
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +7 -15
- package/dist/types/excalidraw/scene/Renderer.d.ts +428 -18
- package/dist/types/excalidraw/scene/export.d.ts +4 -4
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +26 -8
- package/dist/types/excalidraw/shortcut.d.ts +1 -0
- package/dist/types/excalidraw/snapping.d.ts +12 -12
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-bindings.d.ts +1 -1
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-loader.d.ts +1 -1
- package/dist/types/excalidraw/subset/harfbuzz/harfbuzz-wasm.d.ts +1 -1
- package/dist/types/excalidraw/subset/woff2/woff2-loader.d.ts +2 -2
- package/dist/types/excalidraw/subset/woff2/woff2-wasm.d.ts +1 -1
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +486 -51
- package/dist/types/excalidraw/viewport.d.ts +272 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +8 -5
- package/dist/types/fractional-indexing/src/index.d.ts +29 -0
- package/dist/types/laser-pointer/src/index.d.ts +2 -0
- package/dist/types/laser-pointer/src/math.d.ts +16 -0
- package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
- package/dist/types/laser-pointer/src/state.d.ts +36 -0
- package/dist/types/math/src/constants.d.ts +0 -1
- package/dist/types/math/src/curve.d.ts +4 -1
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/pca.d.ts +79 -0
- package/dist/types/math/src/point.d.ts +8 -2
- package/dist/types/math/src/polygon.d.ts +26 -2
- package/dist/types/math/src/range.d.ts +1 -3
- package/dist/types/math/src/segment.d.ts +4 -3
- package/dist/types/math/src/types.d.ts +25 -1
- package/dist/types/utils/src/export.d.ts +8 -8
- package/dist/types/utils/src/index.d.ts +1 -2
- package/dist/types/utils/src/shape.d.ts +6 -6
- package/package.json +2 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +0 -185
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/charts.d.ts +0 -27
- package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -16
- package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
- package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -9
- package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -10
- package/dist/types/excalidraw/components/shapes.d.ts +0 -190
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -85
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
- package/dist/types/excalidraw/index.d.ts +0 -47
- package/dist/types/excalidraw/polyfill.d.ts +0 -2
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -23
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
package/dist/dev/index.js
CHANGED
|
@@ -101,8 +101,8 @@ var vectorNormalize = (v) => {
|
|
|
101
101
|
var vectorNormal = (v) => vector(v[1], -v[0]);
|
|
102
102
|
|
|
103
103
|
// src/point.ts
|
|
104
|
-
function pointFrom(
|
|
105
|
-
return [x, y];
|
|
104
|
+
function pointFrom(xOrCoords, y) {
|
|
105
|
+
return typeof xOrCoords === "object" ? [xOrCoords.x, xOrCoords.y] : [xOrCoords, y];
|
|
106
106
|
}
|
|
107
107
|
function pointFromArray(numberArray) {
|
|
108
108
|
return numberArray.length === 2 ? pointFrom(numberArray[0], numberArray[1]) : void 0;
|
|
@@ -120,7 +120,12 @@ function pointsEqual(a, b, tolerance = PRECISION) {
|
|
|
120
120
|
const abs = Math.abs;
|
|
121
121
|
return abs(a[0] - b[0]) < tolerance && abs(a[1] - b[1]) < tolerance;
|
|
122
122
|
}
|
|
123
|
-
function pointRotateRads(
|
|
123
|
+
function pointRotateRads(point, center, angle) {
|
|
124
|
+
if (!angle) {
|
|
125
|
+
return point;
|
|
126
|
+
}
|
|
127
|
+
const [x, y] = point;
|
|
128
|
+
const [cx, cy] = center;
|
|
124
129
|
return pointFrom(
|
|
125
130
|
(x - cx) * Math.cos(angle) - (y - cy) * Math.sin(angle) + cx,
|
|
126
131
|
(x - cx) * Math.sin(angle) + (y - cy) * Math.cos(angle) + cy
|
|
@@ -147,6 +152,9 @@ var pointScaleFromOrigin = (p, mid, multiplier) => pointTranslate(mid, vectorSca
|
|
|
147
152
|
var isPointWithinBounds = (p, q, r) => {
|
|
148
153
|
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
154
|
};
|
|
155
|
+
var isValidPoint = (point) => {
|
|
156
|
+
return Array.isArray(point) && point.length === 2 && isFiniteNumber(point[0]) && isFiniteNumber(point[1]);
|
|
157
|
+
};
|
|
150
158
|
|
|
151
159
|
// src/constants.ts
|
|
152
160
|
var LegendreGaussN24TValues = [
|
|
@@ -206,41 +214,41 @@ var LegendreGaussN24CValues = [
|
|
|
206
214
|
function curve(a, b, c, d) {
|
|
207
215
|
return [a, b, c, d];
|
|
208
216
|
}
|
|
209
|
-
function
|
|
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) {
|
|
217
|
+
function solveWithAnalyticalJacobian(curve2, lineSegment2, t0, s0, tolerance = 1e-3, iterLimit = 10) {
|
|
216
218
|
let error = Infinity;
|
|
217
219
|
let iter = 0;
|
|
218
220
|
while (error >= tolerance) {
|
|
219
221
|
if (iter >= iterLimit) {
|
|
220
222
|
return null;
|
|
221
223
|
}
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
const
|
|
229
|
-
|
|
224
|
+
const bt = 1 - t0;
|
|
225
|
+
const bt2 = bt * bt;
|
|
226
|
+
const bt3 = bt2 * bt;
|
|
227
|
+
const t0_2 = t0 * t0;
|
|
228
|
+
const t0_3 = t0_2 * t0;
|
|
229
|
+
const bezierX = bt3 * curve2[0][0] + 3 * bt2 * t0 * curve2[1][0] + 3 * bt * t0_2 * curve2[2][0] + t0_3 * curve2[3][0];
|
|
230
|
+
const bezierY = bt3 * curve2[0][1] + 3 * bt2 * t0 * curve2[1][1] + 3 * bt * t0_2 * curve2[2][1] + t0_3 * curve2[3][1];
|
|
231
|
+
const lineX = lineSegment2[0][0] + s0 * (lineSegment2[1][0] - lineSegment2[0][0]);
|
|
232
|
+
const lineY = lineSegment2[0][1] + s0 * (lineSegment2[1][1] - lineSegment2[0][1]);
|
|
233
|
+
const fx = bezierX - lineX;
|
|
234
|
+
const fy = bezierY - lineY;
|
|
235
|
+
error = Math.abs(fx) + Math.abs(fy);
|
|
236
|
+
if (error < tolerance) {
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
const dfx_dt = -3 * bt2 * curve2[0][0] + 3 * bt2 * curve2[1][0] - 6 * bt * t0 * curve2[1][0] - 3 * t0_2 * curve2[2][0] + 6 * bt * t0 * curve2[2][0] + 3 * t0_2 * curve2[3][0];
|
|
240
|
+
const dfy_dt = -3 * bt2 * curve2[0][1] + 3 * bt2 * curve2[1][1] - 6 * bt * t0 * curve2[1][1] - 3 * t0_2 * curve2[2][1] + 6 * bt * t0 * curve2[2][1] + 3 * t0_2 * curve2[3][1];
|
|
241
|
+
const dfx_ds = -(lineSegment2[1][0] - lineSegment2[0][0]);
|
|
242
|
+
const dfy_ds = -(lineSegment2[1][1] - lineSegment2[0][1]);
|
|
243
|
+
const det = dfx_dt * dfy_ds - dfx_ds * dfy_dt;
|
|
244
|
+
if (Math.abs(det) < 1e-12) {
|
|
230
245
|
return null;
|
|
231
246
|
}
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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));
|
|
247
|
+
const invDet = 1 / det;
|
|
248
|
+
const dt = invDet * (dfy_ds * -fx - dfx_ds * -fy);
|
|
249
|
+
const ds = invDet * (-dfy_dt * -fx + dfx_dt * -fy);
|
|
250
|
+
t0 += dt;
|
|
251
|
+
s0 += ds;
|
|
244
252
|
iter += 1;
|
|
245
253
|
}
|
|
246
254
|
return [t0, s0];
|
|
@@ -249,47 +257,57 @@ var bezierEquation = (c, t) => pointFrom(
|
|
|
249
257
|
(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
258
|
(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
259
|
);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
260
|
+
var initial_guesses = [
|
|
261
|
+
[0.5, 0],
|
|
262
|
+
[0.2, 0],
|
|
263
|
+
[0.8, 0]
|
|
264
|
+
];
|
|
265
|
+
var calculate = ([t0, s0], l, c, tolerance = 0.01, iterLimit = 4) => {
|
|
266
|
+
const solution = solveWithAnalyticalJacobian(
|
|
267
|
+
c,
|
|
268
|
+
l,
|
|
269
|
+
t0,
|
|
270
|
+
s0,
|
|
271
|
+
tolerance,
|
|
272
|
+
iterLimit
|
|
273
|
+
);
|
|
274
|
+
if (!solution) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
const [t, s] = solution;
|
|
278
|
+
if (t < 0 || t > 1 || s < 0 || s > 1) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
return bezierEquation(c, t);
|
|
282
|
+
};
|
|
283
|
+
function curveIntersectLineSegment(c, l, opts) {
|
|
284
|
+
let solution = calculate(
|
|
285
|
+
initial_guesses[0],
|
|
286
|
+
l,
|
|
287
|
+
c,
|
|
288
|
+
opts?.tolerance,
|
|
289
|
+
opts?.iterLimit
|
|
256
290
|
);
|
|
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
291
|
if (solution) {
|
|
286
292
|
return [solution];
|
|
287
293
|
}
|
|
288
|
-
solution = calculate(
|
|
294
|
+
solution = calculate(
|
|
295
|
+
initial_guesses[1],
|
|
296
|
+
l,
|
|
297
|
+
c,
|
|
298
|
+
opts?.tolerance,
|
|
299
|
+
opts?.iterLimit
|
|
300
|
+
);
|
|
289
301
|
if (solution) {
|
|
290
302
|
return [solution];
|
|
291
303
|
}
|
|
292
|
-
solution = calculate(
|
|
304
|
+
solution = calculate(
|
|
305
|
+
initial_guesses[2],
|
|
306
|
+
l,
|
|
307
|
+
c,
|
|
308
|
+
opts?.tolerance,
|
|
309
|
+
opts?.iterLimit
|
|
310
|
+
);
|
|
293
311
|
if (solution) {
|
|
294
312
|
return [solution];
|
|
295
313
|
}
|
|
@@ -326,7 +344,7 @@ function curveClosestPoint(c, p, tolerance = 1e-3) {
|
|
|
326
344
|
t1,
|
|
327
345
|
(t) => pointDistance(p, bezierEquation(c, t))
|
|
328
346
|
);
|
|
329
|
-
if (
|
|
347
|
+
if (solution == null) {
|
|
330
348
|
return null;
|
|
331
349
|
}
|
|
332
350
|
return bezierEquation(c, solution);
|
|
@@ -334,7 +352,7 @@ function curveClosestPoint(c, p, tolerance = 1e-3) {
|
|
|
334
352
|
function curvePointDistance(c, p) {
|
|
335
353
|
const closest = curveClosestPoint(c, p);
|
|
336
354
|
if (!closest) {
|
|
337
|
-
return
|
|
355
|
+
return Infinity;
|
|
338
356
|
}
|
|
339
357
|
return pointDistance(p, closest);
|
|
340
358
|
}
|
|
@@ -620,82 +638,98 @@ function linesIntersectAt(a, b) {
|
|
|
620
638
|
return null;
|
|
621
639
|
}
|
|
622
640
|
|
|
623
|
-
// src/
|
|
624
|
-
function
|
|
625
|
-
|
|
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);
|
|
626
650
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
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;
|
|
651
|
+
function principalAxes(points) {
|
|
652
|
+
if (points.length < 2) {
|
|
653
|
+
console.error("Degenerate point set: at least two points are required");
|
|
644
654
|
}
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
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;
|
|
650
665
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
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);
|
|
654
678
|
}
|
|
655
|
-
return
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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;
|
|
661
702
|
}
|
|
662
|
-
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
const
|
|
672
|
-
|
|
673
|
-
let param = -1;
|
|
674
|
-
if (len_sq !== 0) {
|
|
675
|
-
param = dot / len_sq;
|
|
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;
|
|
676
714
|
}
|
|
677
|
-
|
|
678
|
-
let
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
yy = y2;
|
|
685
|
-
} else {
|
|
686
|
-
xx = x1 + param * C;
|
|
687
|
-
yy = y1 + param * D;
|
|
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;
|
|
688
722
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
return
|
|
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);
|
|
699
733
|
}
|
|
700
734
|
|
|
701
735
|
// src/polygon.ts
|
|
@@ -741,21 +775,84 @@ var polygonIncludesPointNonZero = (point, polygon2) => {
|
|
|
741
775
|
}
|
|
742
776
|
return windingNumber !== 0;
|
|
743
777
|
};
|
|
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
778
|
function polygonClose(polygon2) {
|
|
755
779
|
return polygonIsClosed(polygon2) ? polygon2 : [...polygon2, polygon2[0]];
|
|
756
780
|
}
|
|
757
|
-
function polygonIsClosed(polygon2) {
|
|
758
|
-
return pointsEqual(polygon2[0], polygon2[polygon2.length - 1]);
|
|
781
|
+
function polygonIsClosed(polygon2, tolerance = PRECISION) {
|
|
782
|
+
return pointsEqual(polygon2[0], polygon2[polygon2.length - 1], tolerance);
|
|
783
|
+
}
|
|
784
|
+
function polygonSignedArea(polygon2) {
|
|
785
|
+
const pts = polygonIsClosed(polygon2) ? 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) {
|
|
793
|
+
return Math.abs(polygonSignedArea(polygon2));
|
|
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;
|
|
759
856
|
}
|
|
760
857
|
|
|
761
858
|
// src/range.ts
|
|
@@ -787,6 +884,95 @@ var rangeIncludesValue = (value, [min, max]) => {
|
|
|
787
884
|
return value >= min && value <= max;
|
|
788
885
|
};
|
|
789
886
|
|
|
887
|
+
// src/segment.ts
|
|
888
|
+
function lineSegment(a, b) {
|
|
889
|
+
return [a, b];
|
|
890
|
+
}
|
|
891
|
+
var isLineSegment = (segment) => Array.isArray(segment) && segment.length === 2 && isPoint(segment[0]) && isPoint(segment[1]);
|
|
892
|
+
var lineSegmentRotate = (l, angle, origin) => {
|
|
893
|
+
return lineSegment(
|
|
894
|
+
pointRotateRads(l[0], origin || pointCenter(l[0], l[1]), angle),
|
|
895
|
+
pointRotateRads(l[1], origin || pointCenter(l[0], l[1]), angle)
|
|
896
|
+
);
|
|
897
|
+
};
|
|
898
|
+
var segmentsIntersectAt = (a, b) => {
|
|
899
|
+
const a0 = vectorFromPoint(a[0]);
|
|
900
|
+
const a1 = vectorFromPoint(a[1]);
|
|
901
|
+
const b0 = vectorFromPoint(b[0]);
|
|
902
|
+
const b1 = vectorFromPoint(b[1]);
|
|
903
|
+
const r = vectorSubtract(a1, a0);
|
|
904
|
+
const s = vectorSubtract(b1, b0);
|
|
905
|
+
const denominator = vectorCross(r, s);
|
|
906
|
+
if (denominator === 0) {
|
|
907
|
+
return null;
|
|
908
|
+
}
|
|
909
|
+
const i = vectorSubtract(vectorFromPoint(b[0]), vectorFromPoint(a[0]));
|
|
910
|
+
const u = vectorCross(i, r) / denominator;
|
|
911
|
+
const t = vectorCross(i, s) / denominator;
|
|
912
|
+
if (u === 0) {
|
|
913
|
+
return null;
|
|
914
|
+
}
|
|
915
|
+
const p = vectorAdd(a0, vectorScale(r, t));
|
|
916
|
+
if (t >= 0 && t < 1 && u >= 0 && u < 1) {
|
|
917
|
+
return pointFromVector(p);
|
|
918
|
+
}
|
|
919
|
+
return null;
|
|
920
|
+
};
|
|
921
|
+
var pointOnLineSegment = (point, line2, threshold = PRECISION) => {
|
|
922
|
+
const distance = distanceToLineSegment(point, line2);
|
|
923
|
+
if (distance === 0) {
|
|
924
|
+
return true;
|
|
925
|
+
}
|
|
926
|
+
return distance < threshold;
|
|
927
|
+
};
|
|
928
|
+
var distanceToLineSegment = (point, line2) => {
|
|
929
|
+
const [x, y] = point;
|
|
930
|
+
const [[x1, y1], [x2, y2]] = line2;
|
|
931
|
+
const A = x - x1;
|
|
932
|
+
const B = y - y1;
|
|
933
|
+
const C = x2 - x1;
|
|
934
|
+
const D = y2 - y1;
|
|
935
|
+
const dot = A * C + B * D;
|
|
936
|
+
const len_sq = C * C + D * D;
|
|
937
|
+
let param = -1;
|
|
938
|
+
if (len_sq !== 0) {
|
|
939
|
+
param = dot / len_sq;
|
|
940
|
+
}
|
|
941
|
+
let xx;
|
|
942
|
+
let yy;
|
|
943
|
+
if (param < 0) {
|
|
944
|
+
xx = x1;
|
|
945
|
+
yy = y1;
|
|
946
|
+
} else if (param > 1) {
|
|
947
|
+
xx = x2;
|
|
948
|
+
yy = y2;
|
|
949
|
+
} else {
|
|
950
|
+
xx = x1 + param * C;
|
|
951
|
+
yy = y1 + param * D;
|
|
952
|
+
}
|
|
953
|
+
const dx = x - xx;
|
|
954
|
+
const dy = y - yy;
|
|
955
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
956
|
+
};
|
|
957
|
+
function lineSegmentIntersectionPoints(l, s, threshold) {
|
|
958
|
+
const candidate = linesIntersectAt(line(l[0], l[1]), line(s[0], s[1]));
|
|
959
|
+
if (!candidate || !pointOnLineSegment(candidate, s, threshold) || !pointOnLineSegment(candidate, l, threshold)) {
|
|
960
|
+
return null;
|
|
961
|
+
}
|
|
962
|
+
return candidate;
|
|
963
|
+
}
|
|
964
|
+
function lineSegmentsDistance(s1, s2) {
|
|
965
|
+
if (lineSegmentIntersectionPoints(s1, s2)) {
|
|
966
|
+
return 0;
|
|
967
|
+
}
|
|
968
|
+
return Math.min(
|
|
969
|
+
distanceToLineSegment(s1[0], s2),
|
|
970
|
+
distanceToLineSegment(s1[1], s2),
|
|
971
|
+
distanceToLineSegment(s2[0], s1),
|
|
972
|
+
distanceToLineSegment(s2[1], s1)
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
|
|
790
976
|
// src/rectangle.ts
|
|
791
977
|
function rectangle(topLeft, bottomRight) {
|
|
792
978
|
return [topLeft, bottomRight];
|
|
@@ -823,7 +1009,9 @@ export {
|
|
|
823
1009
|
average,
|
|
824
1010
|
bezierEquation,
|
|
825
1011
|
cartesian2Polar,
|
|
1012
|
+
centroid,
|
|
826
1013
|
clamp,
|
|
1014
|
+
convexHull,
|
|
827
1015
|
curve,
|
|
828
1016
|
curveCatmullRomCubicApproxPoints,
|
|
829
1017
|
curveCatmullRomQuadraticApproxPoints,
|
|
@@ -843,6 +1031,7 @@ export {
|
|
|
843
1031
|
ellipseLineIntersectionPoints,
|
|
844
1032
|
ellipseSegmentInterceptPoints,
|
|
845
1033
|
ellipseTouchesPoint,
|
|
1034
|
+
elongation,
|
|
846
1035
|
isCloseTo,
|
|
847
1036
|
isCurve,
|
|
848
1037
|
isFiniteNumber,
|
|
@@ -850,14 +1039,18 @@ export {
|
|
|
850
1039
|
isPoint,
|
|
851
1040
|
isPointWithinBounds,
|
|
852
1041
|
isRightAngleRads,
|
|
1042
|
+
isValidPoint,
|
|
853
1043
|
isVector,
|
|
1044
|
+
kurtosis,
|
|
854
1045
|
line,
|
|
855
1046
|
lineSegment,
|
|
856
1047
|
lineSegmentIntersectionPoints,
|
|
857
1048
|
lineSegmentRotate,
|
|
1049
|
+
lineSegmentsDistance,
|
|
858
1050
|
linesIntersectAt,
|
|
859
1051
|
normalizeRadians,
|
|
860
1052
|
offsetPointsForQuadraticBezier,
|
|
1053
|
+
orientPrincipalAxes,
|
|
861
1054
|
pointCenter,
|
|
862
1055
|
pointDistance,
|
|
863
1056
|
pointDistanceSq,
|
|
@@ -866,16 +1059,20 @@ export {
|
|
|
866
1059
|
pointFromPair,
|
|
867
1060
|
pointFromVector,
|
|
868
1061
|
pointOnLineSegment,
|
|
869
|
-
pointOnPolygon,
|
|
870
1062
|
pointRotateDegs,
|
|
871
1063
|
pointRotateRads,
|
|
872
1064
|
pointScaleFromOrigin,
|
|
873
1065
|
pointTranslate,
|
|
874
1066
|
pointsEqual,
|
|
875
1067
|
polygon,
|
|
1068
|
+
polygonArea,
|
|
876
1069
|
polygonFromPoints,
|
|
877
1070
|
polygonIncludesPoint,
|
|
878
1071
|
polygonIncludesPointNonZero,
|
|
1072
|
+
polygonIsClosed,
|
|
1073
|
+
polygonSignedArea,
|
|
1074
|
+
principalAxes,
|
|
1075
|
+
principalCoords,
|
|
879
1076
|
radiansBetweenAngles,
|
|
880
1077
|
radiansDifference,
|
|
881
1078
|
radiansToDegrees,
|
|
@@ -891,6 +1088,9 @@ export {
|
|
|
891
1088
|
round,
|
|
892
1089
|
roundToStep,
|
|
893
1090
|
segmentsIntersectAt,
|
|
1091
|
+
simplifyConvexPolygon,
|
|
1092
|
+
skewness,
|
|
1093
|
+
standardizedMoment,
|
|
894
1094
|
triangleIncludesPoint,
|
|
895
1095
|
vector,
|
|
896
1096
|
vectorAdd,
|