@excalidraw/excalidraw 0.17.1-7441-0269e5a → 0.17.1-7441-4c9a6f4
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/browser/excalidraw-assets/{chunk-V52YQ6TH.js → chunk-LZCCI7PN.js} +1181 -1675
- package/dist/browser/excalidraw-assets/{image-MZHH7VY4.js → image-CG4AV2NT.js} +1 -1
- package/dist/browser/excalidraw-assets/{image-2MHILQWB.css → image-EO7USLQY.css} +1 -1
- package/dist/browser/index.css +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/packages/excalidraw/actions/actionAddToLibrary.js +59 -0
- package/dist/packages/excalidraw/actions/actionAlign.js +124 -0
- package/dist/packages/excalidraw/actions/actionBoundText.js +213 -0
- package/dist/packages/excalidraw/actions/actionCanvas.js +354 -0
- package/dist/packages/excalidraw/actions/actionClipboard.js +221 -0
- package/dist/packages/excalidraw/actions/actionDeleteSelected.js +129 -0
- package/dist/packages/excalidraw/actions/actionDistribute.js +56 -0
- package/dist/packages/excalidraw/actions/actionDuplicateSelection.js +181 -0
- package/dist/packages/excalidraw/actions/actionElementLock.js +89 -0
- package/dist/packages/excalidraw/actions/actionExport.js +195 -0
- package/dist/packages/excalidraw/actions/actionFinalize.js +150 -0
- package/dist/packages/excalidraw/actions/actionFlip.js +52 -0
- package/dist/packages/excalidraw/actions/actionFrame.js +113 -0
- package/dist/packages/excalidraw/actions/actionGroup.js +162 -0
- package/dist/packages/excalidraw/actions/actionHistory.js +57 -0
- package/dist/packages/excalidraw/actions/actionLinearEditor.js +41 -0
- package/dist/packages/excalidraw/actions/actionMenu.js +53 -0
- package/dist/packages/excalidraw/actions/actionNavigate.js +43 -0
- package/dist/packages/excalidraw/actions/actionProperties.js +683 -0
- package/dist/packages/excalidraw/actions/actionSelectAll.js +40 -0
- package/dist/packages/excalidraw/actions/actionStyles.js +118 -0
- package/dist/packages/excalidraw/actions/actionToggleGridMode.js +27 -0
- package/dist/packages/excalidraw/actions/actionToggleObjectsSnapMode.js +26 -0
- package/dist/packages/excalidraw/actions/actionToggleStats.js +19 -0
- package/dist/packages/excalidraw/actions/actionToggleViewMode.js +25 -0
- package/dist/packages/excalidraw/actions/actionToggleZenMode.js +25 -0
- package/dist/packages/excalidraw/actions/actionZindex.js +86 -0
- package/dist/packages/excalidraw/actions/index.js +25 -0
- package/dist/packages/excalidraw/actions/manager.js +110 -0
- package/dist/packages/excalidraw/actions/register.js +5 -0
- package/dist/packages/excalidraw/actions/shortcuts.js +52 -0
- package/dist/packages/excalidraw/align.js +36 -0
- package/dist/packages/excalidraw/analytics.js +30 -0
- package/dist/packages/excalidraw/appState.js +222 -0
- package/dist/packages/excalidraw/charts.js +365 -0
- package/dist/packages/excalidraw/clients.js +34 -0
- package/dist/packages/excalidraw/clipboard.js +351 -0
- package/dist/packages/excalidraw/colors.js +124 -0
- package/dist/packages/excalidraw/components/Actions.js +127 -0
- package/dist/packages/excalidraw/components/Actions.scss +92 -0
- package/dist/packages/excalidraw/components/ActiveConfirmDialog.js +22 -0
- package/dist/packages/excalidraw/components/App.js +6177 -0
- package/dist/packages/excalidraw/components/Avatar.js +15 -0
- package/dist/packages/excalidraw/components/Avatar.scss +7 -0
- package/dist/packages/excalidraw/components/BraveMeasureTextError.js +6 -0
- package/dist/packages/excalidraw/components/Button.js +14 -0
- package/dist/packages/excalidraw/components/Button.scss +7 -0
- package/dist/packages/excalidraw/components/ButtonIconCycle.js +11 -0
- package/dist/packages/excalidraw/components/ButtonIconSelect.js +6 -0
- package/dist/packages/excalidraw/components/ButtonSelect.js +3 -0
- package/dist/packages/excalidraw/components/Card.js +14 -0
- package/dist/packages/excalidraw/components/Card.scss +57 -0
- package/dist/packages/excalidraw/components/CheckboxItem.js +10 -0
- package/dist/packages/excalidraw/components/CheckboxItem.scss +91 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorInput.js +67 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorPicker.js +138 -0
- package/dist/packages/excalidraw/components/ColorPicker/ColorPicker.scss +441 -0
- package/dist/packages/excalidraw/components/ColorPicker/CustomColorList.js +24 -0
- package/dist/packages/excalidraw/components/ColorPicker/HotkeyLabel.js +8 -0
- package/dist/packages/excalidraw/components/ColorPicker/Picker.js +86 -0
- package/dist/packages/excalidraw/components/ColorPicker/PickerColorList.js +33 -0
- package/dist/packages/excalidraw/components/ColorPicker/PickerHeading.js +3 -0
- package/dist/packages/excalidraw/components/ColorPicker/ShadeList.js +44 -0
- package/dist/packages/excalidraw/components/ColorPicker/TopPicks.js +27 -0
- package/dist/packages/excalidraw/components/ColorPicker/colorPickerUtils.js +83 -0
- package/dist/packages/excalidraw/components/ColorPicker/keyboardNavHandlers.js +174 -0
- package/dist/packages/excalidraw/components/ConfirmDialog.js +27 -0
- package/dist/packages/excalidraw/components/ConfirmDialog.scss +11 -0
- package/dist/packages/excalidraw/components/ContextMenu.js +56 -0
- package/dist/packages/excalidraw/components/ContextMenu.scss +98 -0
- package/dist/packages/excalidraw/components/DarkModeToggle.js +16 -0
- package/dist/packages/excalidraw/components/DefaultSidebar.js +48 -0
- package/dist/packages/excalidraw/components/Dialog.js +74 -0
- package/dist/packages/excalidraw/components/Dialog.scss +48 -0
- package/dist/packages/excalidraw/components/DialogActionButton.js +9 -0
- package/dist/packages/excalidraw/components/DialogActionButton.scss +47 -0
- package/dist/packages/excalidraw/components/ErrorDialog.js +18 -0
- package/dist/packages/excalidraw/components/ExcalidrawLogo.js +7 -0
- package/dist/packages/excalidraw/components/ExcalidrawLogo.scss +73 -0
- package/dist/packages/excalidraw/components/ExportDialog.scss +129 -0
- package/dist/packages/excalidraw/components/EyeDropper.js +130 -0
- package/dist/packages/excalidraw/components/EyeDropper.scss +48 -0
- package/dist/packages/excalidraw/components/FilledButton.js +7 -0
- package/dist/packages/excalidraw/components/FilledButton.scss +191 -0
- package/dist/packages/excalidraw/components/FixedSideContainer.js +4 -0
- package/dist/packages/excalidraw/components/FixedSideContainer.scss +40 -0
- package/dist/packages/excalidraw/components/FollowMode/FollowMode.js +7 -0
- package/dist/packages/excalidraw/components/FollowMode/FollowMode.scss +59 -0
- package/dist/packages/excalidraw/components/HandButton.js +9 -0
- package/dist/packages/excalidraw/components/HelpButton.js +4 -0
- package/dist/packages/excalidraw/components/HelpDialog.js +79 -0
- package/dist/packages/excalidraw/components/HelpDialog.scss +130 -0
- package/dist/packages/excalidraw/components/HintViewer.js +97 -0
- package/dist/packages/excalidraw/components/HintViewer.scss +37 -0
- package/dist/packages/excalidraw/components/IconPicker.js +99 -0
- package/dist/packages/excalidraw/components/IconPicker.scss +143 -0
- package/dist/packages/excalidraw/components/ImageExportDialog.js +127 -0
- package/dist/packages/excalidraw/components/ImageExportDialog.scss +173 -0
- package/dist/packages/excalidraw/components/InitializeApp.js +16 -0
- package/dist/packages/excalidraw/components/InlineIcon.js +10 -0
- package/dist/packages/excalidraw/components/Island.js +5 -0
- package/dist/packages/excalidraw/components/Island.scss +16 -0
- package/dist/packages/excalidraw/components/JSONExportDialog.js +35 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserPathManager.js +225 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserPointerButton.js +10 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserTool.js +15 -0
- package/dist/packages/excalidraw/components/LaserTool/LaserToolOverlay.scss +20 -0
- package/dist/packages/excalidraw/components/LayerUI.js +189 -0
- package/dist/packages/excalidraw/components/LayerUI.scss +112 -0
- package/dist/packages/excalidraw/components/LibraryMenu.js +99 -0
- package/dist/packages/excalidraw/components/LibraryMenu.scss +150 -0
- package/dist/packages/excalidraw/components/LibraryMenuBrowseButton.js +8 -0
- package/dist/packages/excalidraw/components/LibraryMenuControlButtons.js +6 -0
- package/dist/packages/excalidraw/components/LibraryMenuHeaderContent.js +126 -0
- package/dist/packages/excalidraw/components/LibraryMenuItems.js +138 -0
- package/dist/packages/excalidraw/components/LibraryMenuItems.scss +99 -0
- package/dist/packages/excalidraw/components/LibraryMenuSection.js +21 -0
- package/dist/packages/excalidraw/components/LibraryUnit.js +52 -0
- package/dist/packages/excalidraw/components/LibraryUnit.scss +185 -0
- package/dist/packages/excalidraw/components/LoadingMessage.js +24 -0
- package/dist/packages/excalidraw/components/LockButton.js +14 -0
- package/dist/packages/excalidraw/components/MagicButton.js +9 -0
- package/dist/packages/excalidraw/components/MagicSettings.js +46 -0
- package/dist/packages/excalidraw/components/MagicSettings.scss +18 -0
- package/dist/packages/excalidraw/components/MobileMenu.js +45 -0
- package/dist/packages/excalidraw/components/Modal.js +23 -0
- package/dist/packages/excalidraw/components/Modal.scss +121 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.js +31 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.scss +126 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.js +32 -0
- package/dist/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.js +19 -0
- package/dist/packages/excalidraw/components/Paragraph.js +4 -0
- package/dist/packages/excalidraw/components/PasteChartDialog.js +63 -0
- package/dist/packages/excalidraw/components/PasteChartDialog.scss +46 -0
- package/dist/packages/excalidraw/components/PenModeButton.js +13 -0
- package/dist/packages/excalidraw/components/Popover.js +111 -0
- package/dist/packages/excalidraw/components/Popover.scss +8 -0
- package/dist/packages/excalidraw/components/ProjectName.js +30 -0
- package/dist/packages/excalidraw/components/ProjectName.scss +25 -0
- package/dist/packages/excalidraw/components/PublishLibrary.js +214 -0
- package/dist/packages/excalidraw/components/PublishLibrary.scss +172 -0
- package/dist/packages/excalidraw/components/RadioGroup.js +8 -0
- package/dist/packages/excalidraw/components/RadioGroup.scss +91 -0
- package/dist/packages/excalidraw/components/Section.js +8 -0
- package/dist/packages/excalidraw/components/ShareableLinkDialog.js +33 -0
- package/dist/packages/excalidraw/components/ShareableLinkDialog.scss +91 -0
- package/dist/packages/excalidraw/components/Sidebar/Sidebar.js +145 -0
- package/dist/packages/excalidraw/components/Sidebar/Sidebar.scss +176 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarHeader.js +16 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTab.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabTrigger.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabTriggers.js +6 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTabs.js +17 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTrigger.js +18 -0
- package/dist/packages/excalidraw/components/Sidebar/SidebarTrigger.scss +37 -0
- package/dist/packages/excalidraw/components/Sidebar/common.js +2 -0
- package/dist/packages/excalidraw/components/Spinner.js +14 -0
- package/dist/packages/excalidraw/components/Spinner.scss +49 -0
- package/dist/packages/excalidraw/components/Stack.js +24 -0
- package/dist/packages/excalidraw/components/Stack.scss +19 -0
- package/dist/packages/excalidraw/components/Stats.js +13 -0
- package/dist/packages/excalidraw/components/Stats.scss +54 -0
- package/dist/packages/excalidraw/components/Switch.js +10 -0
- package/dist/packages/excalidraw/components/Switch.scss +118 -0
- package/dist/packages/excalidraw/components/TTDDialog/MermaidToExcalidraw.js +58 -0
- package/dist/packages/excalidraw/components/TTDDialog/MermaidToExcalidraw.scss +10 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialog.js +194 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialog.scss +315 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogInput.js +28 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogOutput.js +8 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogPanel.js +11 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogPanels.js +4 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.js +5 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTab.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabTrigger.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabTriggers.js +6 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTabs.js +39 -0
- package/dist/packages/excalidraw/components/TTDDialog/TTDDialogTrigger.js +16 -0
- package/dist/packages/excalidraw/components/TTDDialog/common.js +88 -0
- package/dist/packages/excalidraw/components/TextField.js +25 -0
- package/dist/packages/excalidraw/components/TextField.scss +109 -0
- package/dist/packages/excalidraw/components/TextInput.scss +7 -0
- package/dist/packages/excalidraw/components/Toast.js +30 -0
- package/dist/packages/excalidraw/components/Toast.scss +49 -0
- package/dist/packages/excalidraw/components/ToolButton.js +72 -0
- package/dist/packages/excalidraw/components/ToolIcon.scss +184 -0
- package/dist/packages/excalidraw/components/Toolbar.scss +50 -0
- package/dist/packages/excalidraw/components/Tooltip.js +60 -0
- package/dist/packages/excalidraw/components/Tooltip.scss +47 -0
- package/dist/packages/excalidraw/components/Trans.js +139 -0
- package/dist/packages/excalidraw/components/UserList.js +96 -0
- package/dist/packages/excalidraw/components/UserList.scss +136 -0
- package/dist/packages/excalidraw/components/canvases/InteractiveCanvas.js +120 -0
- package/dist/packages/excalidraw/components/canvases/StaticCanvas.js +85 -0
- package/dist/packages/excalidraw/components/canvases/index.js +3 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenu.js +24 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenu.scss +148 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuContent.js +21 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuGroup.js +6 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItem.js +23 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemContent.js +7 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.js +5 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuItemLink.js +9 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuSeparator.js +8 -0
- package/dist/packages/excalidraw/components/dropdownMenu/DropdownMenuTrigger.js +12 -0
- package/dist/packages/excalidraw/components/dropdownMenu/common.js +20 -0
- package/dist/packages/excalidraw/components/dropdownMenu/dropdownMenuUtils.js +27 -0
- package/dist/packages/excalidraw/components/footer/Footer.js +25 -0
- package/dist/packages/excalidraw/components/footer/FooterCenter.js +14 -0
- package/dist/packages/excalidraw/components/footer/FooterCenter.scss +11 -0
- package/dist/packages/excalidraw/components/hoc/withInternalFallback.js +57 -0
- package/dist/packages/excalidraw/components/icons.js +220 -0
- package/dist/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.js +13 -0
- package/dist/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.scss +72 -0
- package/dist/packages/excalidraw/components/main-menu/DefaultItems.js +116 -0
- package/dist/packages/excalidraw/components/main-menu/DefaultItems.scss +21 -0
- package/dist/packages/excalidraw/components/main-menu/MainMenu.js +36 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.Center.js +69 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.Hints.js +20 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.js +11 -0
- package/dist/packages/excalidraw/components/welcome-screen/WelcomeScreen.scss +285 -0
- package/dist/packages/excalidraw/constants.js +312 -0
- package/dist/packages/excalidraw/context/tunnels.js +21 -0
- package/dist/packages/excalidraw/context/ui-appState.js +3 -0
- package/dist/packages/excalidraw/css/app.scss +39 -0
- package/dist/packages/excalidraw/css/styles.scss +757 -0
- package/dist/packages/excalidraw/css/theme.scss +252 -0
- package/dist/packages/excalidraw/css/variables.module.scss +174 -0
- package/dist/packages/excalidraw/cursor.js +72 -0
- package/dist/packages/excalidraw/data/EditorLocalStorage.js +42 -0
- package/dist/packages/excalidraw/data/ai/types.js +1 -0
- package/dist/packages/excalidraw/data/blob.js +378 -0
- package/dist/packages/excalidraw/data/encode.js +231 -0
- package/dist/packages/excalidraw/data/encryption.js +53 -0
- package/dist/packages/excalidraw/data/filesystem.js +65 -0
- package/dist/packages/excalidraw/data/image.js +91 -0
- package/dist/packages/excalidraw/data/index.js +120 -0
- package/dist/packages/excalidraw/data/json.js +93 -0
- package/dist/packages/excalidraw/data/library.js +376 -0
- package/dist/packages/excalidraw/data/magic.js +73 -0
- package/dist/packages/excalidraw/data/resave.js +22 -0
- package/dist/packages/excalidraw/data/restore.js +438 -0
- package/dist/packages/excalidraw/data/transform.js +442 -0
- package/dist/packages/excalidraw/data/types.js +1 -0
- package/dist/packages/excalidraw/data/url.js +30 -0
- package/dist/packages/excalidraw/distribute.js +58 -0
- package/dist/packages/excalidraw/element/ElementCanvasButtons.js +31 -0
- package/dist/packages/excalidraw/element/ElementCanvasButtons.scss +14 -0
- package/dist/packages/excalidraw/element/Hyperlink.js +350 -0
- package/dist/packages/excalidraw/element/Hyperlink.scss +70 -0
- package/dist/packages/excalidraw/element/binding.js +412 -0
- package/dist/packages/excalidraw/element/bounds.js +613 -0
- package/dist/packages/excalidraw/element/collision.js +727 -0
- package/dist/packages/excalidraw/element/dragElements.js +119 -0
- package/dist/packages/excalidraw/element/embeddable.js +305 -0
- package/dist/packages/excalidraw/element/image.js +91 -0
- package/dist/packages/excalidraw/element/index.js +24 -0
- package/dist/packages/excalidraw/element/linearElementEditor.js +867 -0
- package/dist/packages/excalidraw/element/mutateElement.js +112 -0
- package/dist/packages/excalidraw/element/newElement.js +389 -0
- package/dist/packages/excalidraw/element/resizeElements.js +597 -0
- package/dist/packages/excalidraw/element/resizeTest.js +95 -0
- package/dist/packages/excalidraw/element/showSelectedShapeActions.js +9 -0
- package/dist/packages/excalidraw/element/sizeHelpers.js +131 -0
- package/dist/packages/excalidraw/element/sortElements.js +104 -0
- package/dist/packages/excalidraw/element/textElement.js +716 -0
- package/dist/packages/excalidraw/element/textWysiwyg.js +500 -0
- package/dist/packages/excalidraw/element/transformHandles.js +155 -0
- package/dist/packages/excalidraw/element/typeChecks.js +141 -0
- package/dist/packages/excalidraw/element/types.js +1 -0
- package/dist/packages/excalidraw/emitter.js +36 -0
- package/dist/packages/excalidraw/errors.js +20 -0
- package/dist/packages/excalidraw/frame.js +373 -0
- package/dist/packages/excalidraw/ga.js +268 -0
- package/dist/packages/excalidraw/gadirections.js +18 -0
- package/dist/packages/excalidraw/galines.js +32 -0
- package/dist/packages/excalidraw/gapoints.js +30 -0
- package/dist/packages/excalidraw/gatransforms.js +23 -0
- package/dist/packages/excalidraw/gesture.js +9 -0
- package/dist/packages/excalidraw/groups.js +225 -0
- package/dist/packages/excalidraw/history.js +190 -0
- package/dist/packages/excalidraw/hooks/useCallbackRefState.js +6 -0
- package/dist/packages/excalidraw/hooks/useCreatePortalContainer.js +32 -0
- package/dist/packages/excalidraw/hooks/useLibraryItemSvg.js +62 -0
- package/dist/packages/excalidraw/hooks/useOutsideClick.js +67 -0
- package/dist/packages/excalidraw/hooks/useScrollPosition.js +23 -0
- package/dist/packages/excalidraw/hooks/useStable.js +6 -0
- package/dist/packages/excalidraw/hooks/useTransition.js +7 -0
- package/dist/packages/excalidraw/i18n.js +137 -0
- package/dist/packages/excalidraw/index-node.d.ts +1 -0
- package/dist/packages/excalidraw/index-node.js +73 -0
- package/{types → dist/packages}/excalidraw/index.d.ts +1 -1
- package/dist/packages/excalidraw/index.js +116 -0
- package/dist/packages/excalidraw/jotai.js +18 -0
- package/dist/packages/excalidraw/keys.js +84 -0
- package/dist/packages/excalidraw/locales/ar-SA.json +525 -0
- package/dist/packages/excalidraw/locales/az-AZ.json +525 -0
- package/dist/packages/excalidraw/locales/bg-BG.json +525 -0
- package/dist/packages/excalidraw/locales/bn-BD.json +525 -0
- package/dist/packages/excalidraw/locales/ca-ES.json +525 -0
- package/dist/packages/excalidraw/locales/cs-CZ.json +525 -0
- package/dist/packages/excalidraw/locales/da-DK.json +525 -0
- package/dist/packages/excalidraw/locales/de-DE.json +525 -0
- package/dist/packages/excalidraw/locales/el-GR.json +525 -0
- package/dist/packages/excalidraw/locales/en.json +535 -0
- package/dist/packages/excalidraw/locales/es-ES.json +525 -0
- package/dist/packages/excalidraw/locales/eu-ES.json +525 -0
- package/dist/packages/excalidraw/locales/fa-IR.json +525 -0
- package/dist/packages/excalidraw/locales/fi-FI.json +525 -0
- package/dist/packages/excalidraw/locales/fr-FR.json +525 -0
- package/dist/packages/excalidraw/locales/gl-ES.json +525 -0
- package/dist/packages/excalidraw/locales/he-IL.json +525 -0
- package/dist/packages/excalidraw/locales/hi-IN.json +525 -0
- package/dist/packages/excalidraw/locales/hu-HU.json +525 -0
- package/dist/packages/excalidraw/locales/id-ID.json +525 -0
- package/dist/packages/excalidraw/locales/it-IT.json +525 -0
- package/dist/packages/excalidraw/locales/ja-JP.json +525 -0
- package/dist/packages/excalidraw/locales/kaa.json +525 -0
- package/dist/packages/excalidraw/locales/kab-KAB.json +525 -0
- package/dist/packages/excalidraw/locales/kk-KZ.json +525 -0
- package/dist/packages/excalidraw/locales/km-KH.json +525 -0
- package/dist/packages/excalidraw/locales/ko-KR.json +525 -0
- package/dist/packages/excalidraw/locales/ku-TR.json +525 -0
- package/dist/packages/excalidraw/locales/lt-LT.json +525 -0
- package/dist/packages/excalidraw/locales/lv-LV.json +525 -0
- package/dist/packages/excalidraw/locales/mr-IN.json +525 -0
- package/dist/packages/excalidraw/locales/my-MM.json +525 -0
- package/dist/packages/excalidraw/locales/nb-NO.json +525 -0
- package/dist/packages/excalidraw/locales/nl-NL.json +525 -0
- package/dist/packages/excalidraw/locales/nn-NO.json +525 -0
- package/dist/packages/excalidraw/locales/oc-FR.json +525 -0
- package/dist/packages/excalidraw/locales/pa-IN.json +525 -0
- package/dist/packages/excalidraw/locales/percentages.json +56 -0
- package/dist/packages/excalidraw/locales/pl-PL.json +525 -0
- package/dist/packages/excalidraw/locales/pt-BR.json +525 -0
- package/dist/packages/excalidraw/locales/pt-PT.json +525 -0
- package/dist/packages/excalidraw/locales/ro-RO.json +525 -0
- package/dist/packages/excalidraw/locales/ru-RU.json +525 -0
- package/dist/packages/excalidraw/locales/si-LK.json +525 -0
- package/dist/packages/excalidraw/locales/sk-SK.json +525 -0
- package/dist/packages/excalidraw/locales/sl-SI.json +525 -0
- package/dist/packages/excalidraw/locales/sv-SE.json +525 -0
- package/dist/packages/excalidraw/locales/ta-IN.json +525 -0
- package/dist/packages/excalidraw/locales/th-TH.json +525 -0
- package/dist/packages/excalidraw/locales/tr-TR.json +525 -0
- package/dist/packages/excalidraw/locales/uk-UA.json +525 -0
- package/dist/packages/excalidraw/locales/vi-VN.json +525 -0
- package/dist/packages/excalidraw/locales/zh-CN.json +525 -0
- package/dist/packages/excalidraw/locales/zh-HK.json +525 -0
- package/dist/packages/excalidraw/locales/zh-TW.json +525 -0
- package/dist/packages/excalidraw/math.js +364 -0
- package/dist/packages/excalidraw/points.js +38 -0
- package/dist/packages/excalidraw/polyfill.js +32 -0
- package/dist/packages/excalidraw/random.js +11 -0
- package/dist/packages/excalidraw/renderer/renderElement.js +871 -0
- package/dist/packages/excalidraw/renderer/renderScene.js +859 -0
- package/dist/packages/excalidraw/renderer/renderSnaps.js +114 -0
- package/dist/packages/excalidraw/renderer/roundRect.js +28 -0
- package/dist/packages/excalidraw/scene/Fonts.js +71 -0
- package/dist/packages/excalidraw/scene/Renderer.js +65 -0
- package/dist/packages/excalidraw/scene/Scene.js +230 -0
- package/dist/packages/excalidraw/scene/Shape.js +322 -0
- package/dist/packages/excalidraw/scene/ShapeCache.js +42 -0
- package/dist/packages/excalidraw/scene/comparisons.js +67 -0
- package/dist/packages/excalidraw/scene/export.js +304 -0
- package/dist/packages/excalidraw/scene/index.js +5 -0
- package/dist/packages/excalidraw/scene/scroll.js +35 -0
- package/dist/packages/excalidraw/scene/scrollbars.js +85 -0
- package/dist/packages/excalidraw/scene/selection.js +134 -0
- package/dist/packages/excalidraw/scene/types.js +1 -0
- package/dist/packages/excalidraw/scene/zoom.js +22 -0
- package/dist/packages/excalidraw/shapes.js +84 -0
- package/dist/packages/excalidraw/snapping.js +838 -0
- package/dist/packages/excalidraw/types.js +6 -0
- package/dist/packages/excalidraw/utility-types.js +1 -0
- package/dist/packages/excalidraw/utils.js +668 -0
- package/dist/packages/excalidraw/zindex.js +349 -0
- package/dist/packages/utils/bbox.js +42 -0
- package/dist/packages/utils/export.js +109 -0
- package/dist/packages/utils/withinBounds.js +125 -0
- package/dist/public/fonts/Assistant-Bold.woff2 +0 -0
- package/dist/public/fonts/Assistant-Medium.woff2 +0 -0
- package/dist/public/fonts/Assistant-Regular.woff2 +0 -0
- package/dist/public/fonts/Assistant-SemiBold.woff2 +0 -0
- package/dist/public/fonts/Cascadia.ttf +0 -0
- package/dist/public/fonts/Cascadia.woff2 +0 -0
- package/dist/public/fonts/FG_Virgil.ttf +0 -0
- package/dist/public/fonts/FG_Virgil.woff2 +0 -0
- package/dist/public/fonts/Virgil.woff2 +0 -0
- package/dist/public/fonts/fonts.css +38 -0
- package/package.json +8 -5
- package/dist/index.css +0 -5796
- package/dist/index.js +0 -71898
- /package/{types → dist/packages}/excalidraw/actions/actionAddToLibrary.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionAlign.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionBoundText.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionClipboard.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDeleteSelected.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDistribute.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionDuplicateSelection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionElementLock.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionExport.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFinalize.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFlip.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionFrame.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionHistory.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionLinearEditor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionNavigate.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionProperties.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionSelectAll.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionStyles.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleGridMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleStats.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleViewMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionToggleZenMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/actionZindex.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/manager.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/register.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/shortcuts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/actions/types.d.ts +0 -0
- /package/{types/excalidraw/index-node.d.ts → dist/packages/excalidraw/actions/types.js} +0 -0
- /package/{types → dist/packages}/excalidraw/align.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/analytics.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/appState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/charts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/clients.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/clipboard.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/colors.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Actions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ActiveConfirmDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/App.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Avatar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/BraveMeasureTextError.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Button.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonIconCycle.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonIconSelect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ButtonSelect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Card.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/CheckboxItem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ColorInput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ColorPicker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/CustomColorList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/HotkeyLabel.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/Picker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/PickerColorList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/PickerHeading.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/ShadeList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/TopPicks.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ConfirmDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ContextMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DarkModeToggle.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DefaultSidebar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Dialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/DialogActionButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ErrorDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ExcalidrawLogo.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/EyeDropper.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FilledButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FixedSideContainer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/FollowMode/FollowMode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HandButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HelpButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HelpDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/HintViewer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/IconPicker.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ImageExportDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/InitializeApp.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/InlineIcon.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Island.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/JSONExportDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserPathManager.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserPointerButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LaserTool/LaserTool.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LayerUI.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuBrowseButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuControlButtons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuHeaderContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuItems.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryMenuSection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LibraryUnit.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LoadingMessage.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/LockButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MagicButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MagicSettings.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/MobileMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Modal.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirm.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Paragraph.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PasteChartDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PenModeButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Popover.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ProjectName.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/PublishLibrary.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/RadioGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Section.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ShareableLinkDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/Sidebar.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarHeader.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTab.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabTriggers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTabs.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/SidebarTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Sidebar/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Spinner.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Stack.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Stats.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Switch.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialog.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogPanel.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogPanels.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogSubmitShortcut.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTab.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabTriggers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTabs.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TTDDialog/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/TextField.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Toast.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/ToolButton.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Tooltip.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/Trans.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/UserList.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/InteractiveCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/StaticCanvas.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/canvases/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuGroup.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemCustom.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuItemLink.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuSeparator.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/DropdownMenuTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/common.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/footer/Footer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/footer/FooterCenter.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/hoc/withInternalFallback.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/icons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/main-menu/DefaultItems.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/main-menu/MainMenu.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/constants.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/context/tunnels.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/context/ui-appState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/cursor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/EditorLocalStorage.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/ai/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/blob.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/encode.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/encryption.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/filesystem.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/image.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/json.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/library.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/magic.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/resave.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/restore.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/transform.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/data/url.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/distribute.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/ElementCanvasButtons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/Hyperlink.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/binding.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/bounds.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/collision.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/dragElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/embeddable.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/image.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/linearElementEditor.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/mutateElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/newElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/resizeElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/resizeTest.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/showSelectedShapeActions.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/sizeHelpers.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/sortElements.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/textElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/textWysiwyg.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/transformHandles.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/typeChecks.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/element/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/emitter.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/errors.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/frame.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/ga.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gadirections.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/galines.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gapoints.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gatransforms.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/gesture.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/groups.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/history.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useCallbackRefState.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useCreatePortalContainer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useLibraryItemSvg.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useOutsideClick.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useScrollPosition.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useStable.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/hooks/useTransition.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/i18n.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/jotai.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/keys.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/math.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/points.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/polyfill.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/random.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderElement.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderScene.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/renderSnaps.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/renderer/roundRect.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Fonts.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Renderer.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Scene.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/Shape.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/ShapeCache.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/comparisons.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/export.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/index.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/scroll.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/scrollbars.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/selection.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/scene/zoom.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/shapes.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/snapping.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/utility-types.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/utils.d.ts +0 -0
- /package/{types → dist/packages}/excalidraw/zindex.d.ts +0 -0
- /package/{types → dist/packages}/utils/bbox.d.ts +0 -0
- /package/{types → dist/packages}/utils/export.d.ts +0 -0
- /package/{types → dist/packages}/utils/withinBounds.d.ts +0 -0
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
import * as GA from "../ga";
|
|
2
|
+
import * as GAPoint from "../gapoints";
|
|
3
|
+
import * as GADirection from "../gadirections";
|
|
4
|
+
import * as GALine from "../galines";
|
|
5
|
+
import * as GATransform from "../gatransforms";
|
|
6
|
+
import { distance2d, rotatePoint, isPathALoop, isPointInPolygon, rotate, } from "../math";
|
|
7
|
+
import { pointsOnBezierCurves } from "points-on-curve";
|
|
8
|
+
import { getElementAbsoluteCoords, getCurvePathOps, getRectangleBoxAbsoluteCoords, } from "./bounds";
|
|
9
|
+
import { hasBoundTextElement, isFrameLikeElement, isIframeLikeElement, isImageElement, } from "./typeChecks";
|
|
10
|
+
import { isTextElement } from ".";
|
|
11
|
+
import { isTransparent } from "../utils";
|
|
12
|
+
import { shouldShowBoundingBox } from "./transformHandles";
|
|
13
|
+
import { getBoundTextElement } from "./textElement";
|
|
14
|
+
import { ShapeCache } from "../scene/ShapeCache";
|
|
15
|
+
const isElementDraggableFromInside = (element) => {
|
|
16
|
+
if (element.type === "arrow") {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (element.type === "freedraw") {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const isDraggableFromInside = !isTransparent(element.backgroundColor) ||
|
|
23
|
+
hasBoundTextElement(element) ||
|
|
24
|
+
isIframeLikeElement(element);
|
|
25
|
+
if (element.type === "line") {
|
|
26
|
+
return isDraggableFromInside && isPathALoop(element.points);
|
|
27
|
+
}
|
|
28
|
+
return isDraggableFromInside || isImageElement(element);
|
|
29
|
+
};
|
|
30
|
+
export const hitTest = (element, appState, frameNameBoundsCache, x, y) => {
|
|
31
|
+
// How many pixels off the shape boundary we still consider a hit
|
|
32
|
+
const threshold = 10 / appState.zoom.value;
|
|
33
|
+
const point = [x, y];
|
|
34
|
+
if (isElementSelected(appState, element) &&
|
|
35
|
+
shouldShowBoundingBox([element], appState)) {
|
|
36
|
+
return isPointHittingElementBoundingBox(element, point, threshold, frameNameBoundsCache);
|
|
37
|
+
}
|
|
38
|
+
const boundTextElement = getBoundTextElement(element);
|
|
39
|
+
if (boundTextElement) {
|
|
40
|
+
const isHittingBoundTextElement = hitTest(boundTextElement, appState, frameNameBoundsCache, x, y);
|
|
41
|
+
if (isHittingBoundTextElement) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return isHittingElementNotConsideringBoundingBox(element, appState, frameNameBoundsCache, point);
|
|
46
|
+
};
|
|
47
|
+
export const isHittingElementBoundingBoxWithoutHittingElement = (element, appState, frameNameBoundsCache, x, y) => {
|
|
48
|
+
const threshold = 10 / appState.zoom.value;
|
|
49
|
+
// So that bound text element hit is considered within bounding box of container even if its outside actual bounding box of element
|
|
50
|
+
// eg for linear elements text can be outside the element bounding box
|
|
51
|
+
const boundTextElement = getBoundTextElement(element);
|
|
52
|
+
if (boundTextElement &&
|
|
53
|
+
hitTest(boundTextElement, appState, frameNameBoundsCache, x, y)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return (!isHittingElementNotConsideringBoundingBox(element, appState, frameNameBoundsCache, [x, y]) &&
|
|
57
|
+
isPointHittingElementBoundingBox(element, [x, y], threshold, frameNameBoundsCache));
|
|
58
|
+
};
|
|
59
|
+
export const isHittingElementNotConsideringBoundingBox = (element, appState, frameNameBoundsCache, point) => {
|
|
60
|
+
const threshold = 10 / appState.zoom.value;
|
|
61
|
+
const check = isTextElement(element)
|
|
62
|
+
? isStrictlyInside
|
|
63
|
+
: isElementDraggableFromInside(element)
|
|
64
|
+
? isInsideCheck
|
|
65
|
+
: isNearCheck;
|
|
66
|
+
return hitTestPointAgainstElement({
|
|
67
|
+
element,
|
|
68
|
+
point,
|
|
69
|
+
threshold,
|
|
70
|
+
check,
|
|
71
|
+
frameNameBoundsCache,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const isElementSelected = (appState, element) => appState.selectedElementIds[element.id];
|
|
75
|
+
export const isPointHittingElementBoundingBox = (element, [x, y], threshold, frameNameBoundsCache) => {
|
|
76
|
+
// frames needs be checked differently so as to be able to drag it
|
|
77
|
+
// by its frame, whether it has been selected or not
|
|
78
|
+
// this logic here is not ideal
|
|
79
|
+
// TODO: refactor it later...
|
|
80
|
+
if (isFrameLikeElement(element)) {
|
|
81
|
+
return hitTestPointAgainstElement({
|
|
82
|
+
element,
|
|
83
|
+
point: [x, y],
|
|
84
|
+
threshold,
|
|
85
|
+
check: isInsideCheck,
|
|
86
|
+
frameNameBoundsCache,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
90
|
+
const elementCenterX = (x1 + x2) / 2;
|
|
91
|
+
const elementCenterY = (y1 + y2) / 2;
|
|
92
|
+
// reverse rotate to take element's angle into account.
|
|
93
|
+
const [rotatedX, rotatedY] = rotate(x, y, elementCenterX, elementCenterY, -element.angle);
|
|
94
|
+
return (rotatedX > x1 - threshold &&
|
|
95
|
+
rotatedX < x2 + threshold &&
|
|
96
|
+
rotatedY > y1 - threshold &&
|
|
97
|
+
rotatedY < y2 + threshold);
|
|
98
|
+
};
|
|
99
|
+
export const bindingBorderTest = (element, { x, y }) => {
|
|
100
|
+
const threshold = maxBindingGap(element, element.width, element.height);
|
|
101
|
+
const check = isOutsideCheck;
|
|
102
|
+
const point = [x, y];
|
|
103
|
+
return hitTestPointAgainstElement({
|
|
104
|
+
element,
|
|
105
|
+
point,
|
|
106
|
+
threshold,
|
|
107
|
+
check,
|
|
108
|
+
frameNameBoundsCache: null,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
export const maxBindingGap = (element, elementWidth, elementHeight) => {
|
|
112
|
+
// Aligns diamonds with rectangles
|
|
113
|
+
const shapeRatio = element.type === "diamond" ? 1 / Math.sqrt(2) : 1;
|
|
114
|
+
const smallerDimension = shapeRatio * Math.min(elementWidth, elementHeight);
|
|
115
|
+
// We make the bindable boundary bigger for bigger elements
|
|
116
|
+
return Math.max(16, Math.min(0.25 * smallerDimension, 32));
|
|
117
|
+
};
|
|
118
|
+
const hitTestPointAgainstElement = (args) => {
|
|
119
|
+
switch (args.element.type) {
|
|
120
|
+
case "rectangle":
|
|
121
|
+
case "iframe":
|
|
122
|
+
case "embeddable":
|
|
123
|
+
case "image":
|
|
124
|
+
case "text":
|
|
125
|
+
case "diamond":
|
|
126
|
+
case "ellipse":
|
|
127
|
+
const distance = distanceToBindableElement(args.element, args.point);
|
|
128
|
+
return args.check(distance, args.threshold);
|
|
129
|
+
case "freedraw": {
|
|
130
|
+
if (!args.check(distanceToRectangle(args.element, args.point), args.threshold)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
return hitTestFreeDrawElement(args.element, args.point, args.threshold);
|
|
134
|
+
}
|
|
135
|
+
case "arrow":
|
|
136
|
+
case "line":
|
|
137
|
+
return hitTestLinear(args);
|
|
138
|
+
case "selection":
|
|
139
|
+
console.warn("This should not happen, we need to investigate why it does.");
|
|
140
|
+
return false;
|
|
141
|
+
case "frame":
|
|
142
|
+
case "magicframe": {
|
|
143
|
+
// check distance to frame element first
|
|
144
|
+
if (args.check(distanceToBindableElement(args.element, args.point), args.threshold)) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
const frameNameBounds = args.frameNameBoundsCache?.get(args.element);
|
|
148
|
+
if (frameNameBounds) {
|
|
149
|
+
return args.check(distanceToRectangleBox(frameNameBounds, args.point), args.threshold);
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
export const distanceToBindableElement = (element, point) => {
|
|
156
|
+
switch (element.type) {
|
|
157
|
+
case "rectangle":
|
|
158
|
+
case "image":
|
|
159
|
+
case "text":
|
|
160
|
+
case "iframe":
|
|
161
|
+
case "embeddable":
|
|
162
|
+
case "frame":
|
|
163
|
+
case "magicframe":
|
|
164
|
+
return distanceToRectangle(element, point);
|
|
165
|
+
case "diamond":
|
|
166
|
+
return distanceToDiamond(element, point);
|
|
167
|
+
case "ellipse":
|
|
168
|
+
return distanceToEllipse(element, point);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const isStrictlyInside = (distance, threshold) => {
|
|
172
|
+
return distance < 0;
|
|
173
|
+
};
|
|
174
|
+
const isInsideCheck = (distance, threshold) => {
|
|
175
|
+
return distance < threshold;
|
|
176
|
+
};
|
|
177
|
+
const isNearCheck = (distance, threshold) => {
|
|
178
|
+
return Math.abs(distance) < threshold;
|
|
179
|
+
};
|
|
180
|
+
const isOutsideCheck = (distance, threshold) => {
|
|
181
|
+
return 0 <= distance && distance < threshold;
|
|
182
|
+
};
|
|
183
|
+
const distanceToRectangle = (element, point) => {
|
|
184
|
+
const [, pointRel, hwidth, hheight] = pointRelativeToElement(element, point);
|
|
185
|
+
return Math.max(GAPoint.distanceToLine(pointRel, GALine.equation(0, 1, -hheight)), GAPoint.distanceToLine(pointRel, GALine.equation(1, 0, -hwidth)));
|
|
186
|
+
};
|
|
187
|
+
const distanceToRectangleBox = (box, point) => {
|
|
188
|
+
const [, pointRel, hwidth, hheight] = pointRelativeToDivElement(point, box);
|
|
189
|
+
return Math.max(GAPoint.distanceToLine(pointRel, GALine.equation(0, 1, -hheight)), GAPoint.distanceToLine(pointRel, GALine.equation(1, 0, -hwidth)));
|
|
190
|
+
};
|
|
191
|
+
const distanceToDiamond = (element, point) => {
|
|
192
|
+
const [, pointRel, hwidth, hheight] = pointRelativeToElement(element, point);
|
|
193
|
+
const side = GALine.equation(hheight, hwidth, -hheight * hwidth);
|
|
194
|
+
return GAPoint.distanceToLine(pointRel, side);
|
|
195
|
+
};
|
|
196
|
+
const distanceToEllipse = (element, point) => {
|
|
197
|
+
const [pointRel, tangent] = ellipseParamsForTest(element, point);
|
|
198
|
+
return -GALine.sign(tangent) * GAPoint.distanceToLine(pointRel, tangent);
|
|
199
|
+
};
|
|
200
|
+
const ellipseParamsForTest = (element, point) => {
|
|
201
|
+
const [, pointRel, hwidth, hheight] = pointRelativeToElement(element, point);
|
|
202
|
+
const [px, py] = GAPoint.toTuple(pointRel);
|
|
203
|
+
// We're working in positive quadrant, so start with `t = 45deg`, `tx=cos(t)`
|
|
204
|
+
let tx = 0.707;
|
|
205
|
+
let ty = 0.707;
|
|
206
|
+
const a = hwidth;
|
|
207
|
+
const b = hheight;
|
|
208
|
+
// This is a numerical method to find the params tx, ty at which
|
|
209
|
+
// the ellipse has the closest point to the given point
|
|
210
|
+
[0, 1, 2, 3].forEach((_) => {
|
|
211
|
+
const xx = a * tx;
|
|
212
|
+
const yy = b * ty;
|
|
213
|
+
const ex = ((a * a - b * b) * tx ** 3) / a;
|
|
214
|
+
const ey = ((b * b - a * a) * ty ** 3) / b;
|
|
215
|
+
const rx = xx - ex;
|
|
216
|
+
const ry = yy - ey;
|
|
217
|
+
const qx = px - ex;
|
|
218
|
+
const qy = py - ey;
|
|
219
|
+
const r = Math.hypot(ry, rx);
|
|
220
|
+
const q = Math.hypot(qy, qx);
|
|
221
|
+
tx = Math.min(1, Math.max(0, ((qx * r) / q + ex) / a));
|
|
222
|
+
ty = Math.min(1, Math.max(0, ((qy * r) / q + ey) / b));
|
|
223
|
+
const t = Math.hypot(ty, tx);
|
|
224
|
+
tx /= t;
|
|
225
|
+
ty /= t;
|
|
226
|
+
});
|
|
227
|
+
const closestPoint = GA.point(a * tx, b * ty);
|
|
228
|
+
const tangent = GALine.orthogonalThrough(pointRel, closestPoint);
|
|
229
|
+
return [pointRel, tangent];
|
|
230
|
+
};
|
|
231
|
+
const hitTestFreeDrawElement = (element, point, threshold) => {
|
|
232
|
+
// Check point-distance-to-line-segment for every segment in the
|
|
233
|
+
// element's points (its input points, not its outline points).
|
|
234
|
+
// This is... okay? It's plenty fast, but the GA library may
|
|
235
|
+
// have a faster option.
|
|
236
|
+
let x;
|
|
237
|
+
let y;
|
|
238
|
+
if (element.angle === 0) {
|
|
239
|
+
x = point[0] - element.x;
|
|
240
|
+
y = point[1] - element.y;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
// Counter-rotate the point around center before testing
|
|
244
|
+
const [minX, minY, maxX, maxY] = getElementAbsoluteCoords(element);
|
|
245
|
+
const rotatedPoint = rotatePoint(point, [minX + (maxX - minX) / 2, minY + (maxY - minY) / 2], -element.angle);
|
|
246
|
+
x = rotatedPoint[0] - element.x;
|
|
247
|
+
y = rotatedPoint[1] - element.y;
|
|
248
|
+
}
|
|
249
|
+
let [A, B] = element.points;
|
|
250
|
+
let P;
|
|
251
|
+
// For freedraw dots
|
|
252
|
+
if (distance2d(A[0], A[1], x, y) < threshold ||
|
|
253
|
+
distance2d(B[0], B[1], x, y) < threshold) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
// For freedraw lines
|
|
257
|
+
for (let i = 0; i < element.points.length; i++) {
|
|
258
|
+
const delta = [B[0] - A[0], B[1] - A[1]];
|
|
259
|
+
const length = Math.hypot(delta[1], delta[0]);
|
|
260
|
+
const U = [delta[0] / length, delta[1] / length];
|
|
261
|
+
const C = [x - A[0], y - A[1]];
|
|
262
|
+
const d = (C[0] * U[0] + C[1] * U[1]) / Math.hypot(U[1], U[0]);
|
|
263
|
+
P = [A[0] + U[0] * d, A[1] + U[1] * d];
|
|
264
|
+
const da = distance2d(P[0], P[1], A[0], A[1]);
|
|
265
|
+
const db = distance2d(P[0], P[1], B[0], B[1]);
|
|
266
|
+
P = db < da && da > length ? B : da < db && db > length ? A : P;
|
|
267
|
+
if (Math.hypot(y - P[1], x - P[0]) < threshold) {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
A = B;
|
|
271
|
+
B = element.points[i + 1];
|
|
272
|
+
}
|
|
273
|
+
const shape = ShapeCache.get(element);
|
|
274
|
+
// for filled freedraw shapes, support
|
|
275
|
+
// selecting from inside
|
|
276
|
+
if (shape && shape.sets.length) {
|
|
277
|
+
return element.fillStyle === "solid"
|
|
278
|
+
? hitTestCurveInside(shape, x, y, "round")
|
|
279
|
+
: hitTestRoughShape(shape, x, y, threshold);
|
|
280
|
+
}
|
|
281
|
+
return false;
|
|
282
|
+
};
|
|
283
|
+
const hitTestLinear = (args) => {
|
|
284
|
+
const { element, threshold } = args;
|
|
285
|
+
if (!ShapeCache.get(element)) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
const [point, pointAbs, hwidth, hheight] = pointRelativeToElement(args.element, args.point);
|
|
289
|
+
const side1 = GALine.equation(0, 1, -hheight);
|
|
290
|
+
const side2 = GALine.equation(1, 0, -hwidth);
|
|
291
|
+
if (!isInsideCheck(GAPoint.distanceToLine(pointAbs, side1), threshold) ||
|
|
292
|
+
!isInsideCheck(GAPoint.distanceToLine(pointAbs, side2), threshold)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
const [relX, relY] = GAPoint.toTuple(point);
|
|
296
|
+
const shape = ShapeCache.get(element);
|
|
297
|
+
if (!shape) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
if (args.check === isInsideCheck) {
|
|
301
|
+
const hit = shape.some((subshape) => hitTestCurveInside(subshape, relX, relY, element.roundness ? "round" : "sharp"));
|
|
302
|
+
if (hit) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// hit test all "subshapes" of the linear element
|
|
307
|
+
return shape.some((subshape) => hitTestRoughShape(subshape, relX, relY, threshold));
|
|
308
|
+
};
|
|
309
|
+
// Returns:
|
|
310
|
+
// 1. the point relative to the elements (x, y) position
|
|
311
|
+
// 2. the point relative to the element's center with positive (x, y)
|
|
312
|
+
// 3. half element width
|
|
313
|
+
// 4. half element height
|
|
314
|
+
//
|
|
315
|
+
// Note that for linear elements the (x, y) position is not at the
|
|
316
|
+
// top right corner of their boundary.
|
|
317
|
+
//
|
|
318
|
+
// Rectangles, diamonds and ellipses are symmetrical over axes,
|
|
319
|
+
// and other elements have a rectangular boundary,
|
|
320
|
+
// so we only need to perform hit tests for the positive quadrant.
|
|
321
|
+
const pointRelativeToElement = (element, pointTuple) => {
|
|
322
|
+
const point = GAPoint.from(pointTuple);
|
|
323
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
324
|
+
const center = coordsCenter(x1, y1, x2, y2);
|
|
325
|
+
// GA has angle orientation opposite to `rotate`
|
|
326
|
+
const rotate = GATransform.rotation(center, element.angle);
|
|
327
|
+
const pointRotated = GATransform.apply(rotate, point);
|
|
328
|
+
const pointRelToCenter = GA.sub(pointRotated, GADirection.from(center));
|
|
329
|
+
const pointRelToCenterAbs = GAPoint.abs(pointRelToCenter);
|
|
330
|
+
const elementPos = GA.offset(element.x, element.y);
|
|
331
|
+
const pointRelToPos = GA.sub(pointRotated, elementPos);
|
|
332
|
+
const halfWidth = (x2 - x1) / 2;
|
|
333
|
+
const halfHeight = (y2 - y1) / 2;
|
|
334
|
+
return [pointRelToPos, pointRelToCenterAbs, halfWidth, halfHeight];
|
|
335
|
+
};
|
|
336
|
+
const pointRelativeToDivElement = (pointTuple, rectangle) => {
|
|
337
|
+
const point = GAPoint.from(pointTuple);
|
|
338
|
+
const [x1, y1, x2, y2] = getRectangleBoxAbsoluteCoords(rectangle);
|
|
339
|
+
const center = coordsCenter(x1, y1, x2, y2);
|
|
340
|
+
const rotate = GATransform.rotation(center, rectangle.angle);
|
|
341
|
+
const pointRotated = GATransform.apply(rotate, point);
|
|
342
|
+
const pointRelToCenter = GA.sub(pointRotated, GADirection.from(center));
|
|
343
|
+
const pointRelToCenterAbs = GAPoint.abs(pointRelToCenter);
|
|
344
|
+
const elementPos = GA.offset(rectangle.x, rectangle.y);
|
|
345
|
+
const pointRelToPos = GA.sub(pointRotated, elementPos);
|
|
346
|
+
const halfWidth = (x2 - x1) / 2;
|
|
347
|
+
const halfHeight = (y2 - y1) / 2;
|
|
348
|
+
return [pointRelToPos, pointRelToCenterAbs, halfWidth, halfHeight];
|
|
349
|
+
};
|
|
350
|
+
// Returns point in absolute coordinates
|
|
351
|
+
export const pointInAbsoluteCoords = (element,
|
|
352
|
+
// Point relative to the element position
|
|
353
|
+
point) => {
|
|
354
|
+
const [x, y] = point;
|
|
355
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
356
|
+
const cx = (x2 - x1) / 2;
|
|
357
|
+
const cy = (y2 - y1) / 2;
|
|
358
|
+
const [rotatedX, rotatedY] = rotate(x, y, cx, cy, element.angle);
|
|
359
|
+
return [element.x + rotatedX, element.y + rotatedY];
|
|
360
|
+
};
|
|
361
|
+
const relativizationToElementCenter = (element) => {
|
|
362
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
363
|
+
const center = coordsCenter(x1, y1, x2, y2);
|
|
364
|
+
// GA has angle orientation opposite to `rotate`
|
|
365
|
+
const rotate = GATransform.rotation(center, element.angle);
|
|
366
|
+
const translate = GA.reverse(GATransform.translation(GADirection.from(center)));
|
|
367
|
+
return GATransform.compose(rotate, translate);
|
|
368
|
+
};
|
|
369
|
+
const coordsCenter = (x1, y1, x2, y2) => {
|
|
370
|
+
return GA.point((x1 + x2) / 2, (y1 + y2) / 2);
|
|
371
|
+
};
|
|
372
|
+
// The focus distance is the oriented ratio between the size of
|
|
373
|
+
// the `element` and the "focus image" of the element on which
|
|
374
|
+
// all focus points lie, so it's a number between -1 and 1.
|
|
375
|
+
// The line going through `a` and `b` is a tangent to the "focus image"
|
|
376
|
+
// of the element.
|
|
377
|
+
export const determineFocusDistance = (element,
|
|
378
|
+
// Point on the line, in absolute coordinates
|
|
379
|
+
a,
|
|
380
|
+
// Another point on the line, in absolute coordinates (closer to element)
|
|
381
|
+
b) => {
|
|
382
|
+
const relateToCenter = relativizationToElementCenter(element);
|
|
383
|
+
const aRel = GATransform.apply(relateToCenter, GAPoint.from(a));
|
|
384
|
+
const bRel = GATransform.apply(relateToCenter, GAPoint.from(b));
|
|
385
|
+
const line = GALine.through(aRel, bRel);
|
|
386
|
+
const q = element.height / element.width;
|
|
387
|
+
const hwidth = element.width / 2;
|
|
388
|
+
const hheight = element.height / 2;
|
|
389
|
+
const n = line[2];
|
|
390
|
+
const m = line[3];
|
|
391
|
+
const c = line[1];
|
|
392
|
+
const mabs = Math.abs(m);
|
|
393
|
+
const nabs = Math.abs(n);
|
|
394
|
+
let ret;
|
|
395
|
+
switch (element.type) {
|
|
396
|
+
case "rectangle":
|
|
397
|
+
case "image":
|
|
398
|
+
case "text":
|
|
399
|
+
case "iframe":
|
|
400
|
+
case "embeddable":
|
|
401
|
+
case "frame":
|
|
402
|
+
case "magicframe":
|
|
403
|
+
ret = c / (hwidth * (nabs + q * mabs));
|
|
404
|
+
break;
|
|
405
|
+
case "diamond":
|
|
406
|
+
ret = mabs < nabs ? c / (nabs * hwidth) : c / (mabs * hheight);
|
|
407
|
+
break;
|
|
408
|
+
case "ellipse":
|
|
409
|
+
ret = c / (hwidth * Math.sqrt(n ** 2 + q ** 2 * m ** 2));
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
return ret || 0;
|
|
413
|
+
};
|
|
414
|
+
export const determineFocusPoint = (element,
|
|
415
|
+
// The oriented, relative distance from the center of `element` of the
|
|
416
|
+
// returned focusPoint
|
|
417
|
+
focus, adjecentPoint) => {
|
|
418
|
+
if (focus === 0) {
|
|
419
|
+
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
|
|
420
|
+
const center = coordsCenter(x1, y1, x2, y2);
|
|
421
|
+
return GAPoint.toTuple(center);
|
|
422
|
+
}
|
|
423
|
+
const relateToCenter = relativizationToElementCenter(element);
|
|
424
|
+
const adjecentPointRel = GATransform.apply(relateToCenter, GAPoint.from(adjecentPoint));
|
|
425
|
+
const reverseRelateToCenter = GA.reverse(relateToCenter);
|
|
426
|
+
let point;
|
|
427
|
+
switch (element.type) {
|
|
428
|
+
case "rectangle":
|
|
429
|
+
case "image":
|
|
430
|
+
case "text":
|
|
431
|
+
case "diamond":
|
|
432
|
+
case "iframe":
|
|
433
|
+
case "embeddable":
|
|
434
|
+
case "frame":
|
|
435
|
+
case "magicframe":
|
|
436
|
+
point = findFocusPointForRectangulars(element, focus, adjecentPointRel);
|
|
437
|
+
break;
|
|
438
|
+
case "ellipse":
|
|
439
|
+
point = findFocusPointForEllipse(element, focus, adjecentPointRel);
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
return GAPoint.toTuple(GATransform.apply(reverseRelateToCenter, point));
|
|
443
|
+
};
|
|
444
|
+
// Returns 2 or 0 intersection points between line going through `a` and `b`
|
|
445
|
+
// and the `element`, in ascending order of distance from `a`.
|
|
446
|
+
export const intersectElementWithLine = (element,
|
|
447
|
+
// Point on the line, in absolute coordinates
|
|
448
|
+
a,
|
|
449
|
+
// Another point on the line, in absolute coordinates
|
|
450
|
+
b,
|
|
451
|
+
// If given, the element is inflated by this value
|
|
452
|
+
gap = 0) => {
|
|
453
|
+
const relateToCenter = relativizationToElementCenter(element);
|
|
454
|
+
const aRel = GATransform.apply(relateToCenter, GAPoint.from(a));
|
|
455
|
+
const bRel = GATransform.apply(relateToCenter, GAPoint.from(b));
|
|
456
|
+
const line = GALine.through(aRel, bRel);
|
|
457
|
+
const reverseRelateToCenter = GA.reverse(relateToCenter);
|
|
458
|
+
const intersections = getSortedElementLineIntersections(element, line, aRel, gap);
|
|
459
|
+
return intersections.map((point) => GAPoint.toTuple(GATransform.apply(reverseRelateToCenter, point)));
|
|
460
|
+
};
|
|
461
|
+
const getSortedElementLineIntersections = (element,
|
|
462
|
+
// Relative to element center
|
|
463
|
+
line,
|
|
464
|
+
// Relative to element center
|
|
465
|
+
nearPoint, gap = 0) => {
|
|
466
|
+
let intersections;
|
|
467
|
+
switch (element.type) {
|
|
468
|
+
case "rectangle":
|
|
469
|
+
case "image":
|
|
470
|
+
case "text":
|
|
471
|
+
case "diamond":
|
|
472
|
+
case "iframe":
|
|
473
|
+
case "embeddable":
|
|
474
|
+
case "frame":
|
|
475
|
+
case "magicframe":
|
|
476
|
+
const corners = getCorners(element);
|
|
477
|
+
intersections = corners
|
|
478
|
+
.flatMap((point, i) => {
|
|
479
|
+
const edge = [point, corners[(i + 1) % 4]];
|
|
480
|
+
return intersectSegment(line, offsetSegment(edge, gap));
|
|
481
|
+
})
|
|
482
|
+
.concat(corners.flatMap((point) => getCircleIntersections(point, gap, line)));
|
|
483
|
+
break;
|
|
484
|
+
case "ellipse":
|
|
485
|
+
intersections = getEllipseIntersections(element, gap, line);
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
if (intersections.length < 2) {
|
|
489
|
+
// Ignore the "edge" case of only intersecting with a single corner
|
|
490
|
+
return [];
|
|
491
|
+
}
|
|
492
|
+
const sortedIntersections = intersections.sort((i1, i2) => GAPoint.distance(i1, nearPoint) - GAPoint.distance(i2, nearPoint));
|
|
493
|
+
return [
|
|
494
|
+
sortedIntersections[0],
|
|
495
|
+
sortedIntersections[sortedIntersections.length - 1],
|
|
496
|
+
];
|
|
497
|
+
};
|
|
498
|
+
const getCorners = (element, scale = 1) => {
|
|
499
|
+
const hx = (scale * element.width) / 2;
|
|
500
|
+
const hy = (scale * element.height) / 2;
|
|
501
|
+
switch (element.type) {
|
|
502
|
+
case "rectangle":
|
|
503
|
+
case "image":
|
|
504
|
+
case "text":
|
|
505
|
+
case "iframe":
|
|
506
|
+
case "embeddable":
|
|
507
|
+
case "frame":
|
|
508
|
+
case "magicframe":
|
|
509
|
+
return [
|
|
510
|
+
GA.point(hx, hy),
|
|
511
|
+
GA.point(hx, -hy),
|
|
512
|
+
GA.point(-hx, -hy),
|
|
513
|
+
GA.point(-hx, hy),
|
|
514
|
+
];
|
|
515
|
+
case "diamond":
|
|
516
|
+
return [
|
|
517
|
+
GA.point(0, hy),
|
|
518
|
+
GA.point(hx, 0),
|
|
519
|
+
GA.point(0, -hy),
|
|
520
|
+
GA.point(-hx, 0),
|
|
521
|
+
];
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
// Returns intersection of `line` with `segment`, with `segment` moved by
|
|
525
|
+
// `gap` in its polar direction.
|
|
526
|
+
// If intersection coincides with second segment point returns empty array.
|
|
527
|
+
const intersectSegment = (line, segment) => {
|
|
528
|
+
const [a, b] = segment;
|
|
529
|
+
const aDist = GAPoint.distanceToLine(a, line);
|
|
530
|
+
const bDist = GAPoint.distanceToLine(b, line);
|
|
531
|
+
if (aDist * bDist >= 0) {
|
|
532
|
+
// The intersection is outside segment `(a, b)`
|
|
533
|
+
return [];
|
|
534
|
+
}
|
|
535
|
+
return [GAPoint.intersect(line, GALine.through(a, b))];
|
|
536
|
+
};
|
|
537
|
+
const offsetSegment = (segment, distance) => {
|
|
538
|
+
const [a, b] = segment;
|
|
539
|
+
const offset = GATransform.translationOrthogonal(GADirection.fromTo(a, b), distance);
|
|
540
|
+
return [GATransform.apply(offset, a), GATransform.apply(offset, b)];
|
|
541
|
+
};
|
|
542
|
+
const getEllipseIntersections = (element, gap, line) => {
|
|
543
|
+
const a = element.width / 2 + gap;
|
|
544
|
+
const b = element.height / 2 + gap;
|
|
545
|
+
const m = line[2];
|
|
546
|
+
const n = line[3];
|
|
547
|
+
const c = line[1];
|
|
548
|
+
const squares = a * a * m * m + b * b * n * n;
|
|
549
|
+
const discr = squares - c * c;
|
|
550
|
+
if (squares === 0 || discr <= 0) {
|
|
551
|
+
return [];
|
|
552
|
+
}
|
|
553
|
+
const discrRoot = Math.sqrt(discr);
|
|
554
|
+
const xn = -a * a * m * c;
|
|
555
|
+
const yn = -b * b * n * c;
|
|
556
|
+
return [
|
|
557
|
+
GA.point((xn + a * b * n * discrRoot) / squares, (yn - a * b * m * discrRoot) / squares),
|
|
558
|
+
GA.point((xn - a * b * n * discrRoot) / squares, (yn + a * b * m * discrRoot) / squares),
|
|
559
|
+
];
|
|
560
|
+
};
|
|
561
|
+
export const getCircleIntersections = (center, radius, line) => {
|
|
562
|
+
if (radius === 0) {
|
|
563
|
+
return GAPoint.distanceToLine(line, center) === 0 ? [center] : [];
|
|
564
|
+
}
|
|
565
|
+
const m = line[2];
|
|
566
|
+
const n = line[3];
|
|
567
|
+
const c = line[1];
|
|
568
|
+
const [a, b] = GAPoint.toTuple(center);
|
|
569
|
+
const r = radius;
|
|
570
|
+
const squares = m * m + n * n;
|
|
571
|
+
const discr = r * r * squares - (m * a + n * b + c) ** 2;
|
|
572
|
+
if (squares === 0 || discr <= 0) {
|
|
573
|
+
return [];
|
|
574
|
+
}
|
|
575
|
+
const discrRoot = Math.sqrt(discr);
|
|
576
|
+
const xn = a * n * n - b * m * n - m * c;
|
|
577
|
+
const yn = b * m * m - a * m * n - n * c;
|
|
578
|
+
return [
|
|
579
|
+
GA.point((xn + n * discrRoot) / squares, (yn - m * discrRoot) / squares),
|
|
580
|
+
GA.point((xn - n * discrRoot) / squares, (yn + m * discrRoot) / squares),
|
|
581
|
+
];
|
|
582
|
+
};
|
|
583
|
+
// The focus point is the tangent point of the "focus image" of the
|
|
584
|
+
// `element`, where the tangent goes through `point`.
|
|
585
|
+
export const findFocusPointForEllipse = (ellipse,
|
|
586
|
+
// Between -1 and 1 (not 0) the relative size of the "focus image" of
|
|
587
|
+
// the element on which the focus point lies
|
|
588
|
+
relativeDistance,
|
|
589
|
+
// The point for which we're trying to find the focus point, relative
|
|
590
|
+
// to the ellipse center.
|
|
591
|
+
point) => {
|
|
592
|
+
const relativeDistanceAbs = Math.abs(relativeDistance);
|
|
593
|
+
const a = (ellipse.width * relativeDistanceAbs) / 2;
|
|
594
|
+
const b = (ellipse.height * relativeDistanceAbs) / 2;
|
|
595
|
+
const orientation = Math.sign(relativeDistance);
|
|
596
|
+
const [px, pyo] = GAPoint.toTuple(point);
|
|
597
|
+
// The calculation below can't handle py = 0
|
|
598
|
+
const py = pyo === 0 ? 0.0001 : pyo;
|
|
599
|
+
const squares = px ** 2 * b ** 2 + py ** 2 * a ** 2;
|
|
600
|
+
// Tangent mx + ny + 1 = 0
|
|
601
|
+
const m = (-px * b ** 2 +
|
|
602
|
+
orientation * py * Math.sqrt(Math.max(0, squares - a ** 2 * b ** 2))) /
|
|
603
|
+
squares;
|
|
604
|
+
let n = (-m * px - 1) / py;
|
|
605
|
+
if (n === 0) {
|
|
606
|
+
// if zero {-0, 0}, fall back to a same-sign value in the similar range
|
|
607
|
+
n = (Object.is(n, -0) ? -1 : 1) * 0.01;
|
|
608
|
+
}
|
|
609
|
+
const x = -(a ** 2 * m) / (n ** 2 * b ** 2 + m ** 2 * a ** 2);
|
|
610
|
+
return GA.point(x, (-m * x - 1) / n);
|
|
611
|
+
};
|
|
612
|
+
export const findFocusPointForRectangulars = (element,
|
|
613
|
+
// Between -1 and 1 for how far away should the focus point be relative
|
|
614
|
+
// to the size of the element. Sign determines orientation.
|
|
615
|
+
relativeDistance,
|
|
616
|
+
// The point for which we're trying to find the focus point, relative
|
|
617
|
+
// to the element center.
|
|
618
|
+
point) => {
|
|
619
|
+
const relativeDistanceAbs = Math.abs(relativeDistance);
|
|
620
|
+
const orientation = Math.sign(relativeDistance);
|
|
621
|
+
const corners = getCorners(element, relativeDistanceAbs);
|
|
622
|
+
let maxDistance = 0;
|
|
623
|
+
let tangentPoint = null;
|
|
624
|
+
corners.forEach((corner) => {
|
|
625
|
+
const distance = orientation * GALine.through(point, corner)[1];
|
|
626
|
+
if (distance > maxDistance) {
|
|
627
|
+
maxDistance = distance;
|
|
628
|
+
tangentPoint = corner;
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
return tangentPoint;
|
|
632
|
+
};
|
|
633
|
+
const pointInBezierEquation = (p0, p1, p2, p3, [mx, my], lineThreshold) => {
|
|
634
|
+
// B(t) = p0 * (1-t)^3 + 3p1 * t * (1-t)^2 + 3p2 * t^2 * (1-t) + p3 * t^3
|
|
635
|
+
const equation = (t, idx) => Math.pow(1 - t, 3) * p3[idx] +
|
|
636
|
+
3 * t * Math.pow(1 - t, 2) * p2[idx] +
|
|
637
|
+
3 * Math.pow(t, 2) * (1 - t) * p1[idx] +
|
|
638
|
+
p0[idx] * Math.pow(t, 3);
|
|
639
|
+
// go through t in increments of 0.01
|
|
640
|
+
let t = 0;
|
|
641
|
+
while (t <= 1.0) {
|
|
642
|
+
const tx = equation(t, 0);
|
|
643
|
+
const ty = equation(t, 1);
|
|
644
|
+
const diff = Math.sqrt(Math.pow(tx - mx, 2) + Math.pow(ty - my, 2));
|
|
645
|
+
if (diff < lineThreshold) {
|
|
646
|
+
return true;
|
|
647
|
+
}
|
|
648
|
+
t += 0.01;
|
|
649
|
+
}
|
|
650
|
+
return false;
|
|
651
|
+
};
|
|
652
|
+
const hitTestCurveInside = (drawable, x, y, roundness) => {
|
|
653
|
+
const ops = getCurvePathOps(drawable);
|
|
654
|
+
const points = [];
|
|
655
|
+
let odd = false; // select one line out of double lines
|
|
656
|
+
for (const operation of ops) {
|
|
657
|
+
if (operation.op === "move") {
|
|
658
|
+
odd = !odd;
|
|
659
|
+
if (odd) {
|
|
660
|
+
points.push([operation.data[0], operation.data[1]]);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
else if (operation.op === "bcurveTo") {
|
|
664
|
+
if (odd) {
|
|
665
|
+
points.push([operation.data[0], operation.data[1]]);
|
|
666
|
+
points.push([operation.data[2], operation.data[3]]);
|
|
667
|
+
points.push([operation.data[4], operation.data[5]]);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
else if (operation.op === "lineTo") {
|
|
671
|
+
if (odd) {
|
|
672
|
+
points.push([operation.data[0], operation.data[1]]);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
if (points.length >= 4) {
|
|
677
|
+
if (roundness === "sharp") {
|
|
678
|
+
return isPointInPolygon(points, x, y);
|
|
679
|
+
}
|
|
680
|
+
const polygonPoints = pointsOnBezierCurves(points, 10, 5);
|
|
681
|
+
return isPointInPolygon(polygonPoints, x, y);
|
|
682
|
+
}
|
|
683
|
+
return false;
|
|
684
|
+
};
|
|
685
|
+
const hitTestRoughShape = (drawable, x, y, lineThreshold) => {
|
|
686
|
+
// read operations from first opSet
|
|
687
|
+
const ops = getCurvePathOps(drawable);
|
|
688
|
+
// set start position as (0,0) just in case
|
|
689
|
+
// move operation does not exist (unlikely but it is worth safekeeping it)
|
|
690
|
+
let currentP = [0, 0];
|
|
691
|
+
return ops.some(({ op, data }, idx) => {
|
|
692
|
+
// There are only four operation types:
|
|
693
|
+
// move, bcurveTo, lineTo, and curveTo
|
|
694
|
+
if (op === "move") {
|
|
695
|
+
// change starting point
|
|
696
|
+
currentP = data;
|
|
697
|
+
// move operation does not draw anything; so, it always
|
|
698
|
+
// returns false
|
|
699
|
+
}
|
|
700
|
+
else if (op === "bcurveTo") {
|
|
701
|
+
// create points from bezier curve
|
|
702
|
+
// bezier curve stores data as a flattened array of three positions
|
|
703
|
+
// [x1, y1, x2, y2, x3, y3]
|
|
704
|
+
const p1 = [data[0], data[1]];
|
|
705
|
+
const p2 = [data[2], data[3]];
|
|
706
|
+
const p3 = [data[4], data[5]];
|
|
707
|
+
const p0 = currentP;
|
|
708
|
+
currentP = p3;
|
|
709
|
+
// check if points are on the curve
|
|
710
|
+
// cubic bezier curves require four parameters
|
|
711
|
+
// the first parameter is the last stored position (p0)
|
|
712
|
+
const retVal = pointInBezierEquation(p0, p1, p2, p3, [x, y], lineThreshold);
|
|
713
|
+
// set end point of bezier curve as the new starting point for
|
|
714
|
+
// upcoming operations as each operation is based on the last drawn
|
|
715
|
+
// position of the previous operation
|
|
716
|
+
return retVal;
|
|
717
|
+
}
|
|
718
|
+
else if (op === "lineTo") {
|
|
719
|
+
return hitTestCurveInside(drawable, x, y, "sharp");
|
|
720
|
+
}
|
|
721
|
+
else if (op === "qcurveTo") {
|
|
722
|
+
// TODO: Implement this
|
|
723
|
+
console.warn("qcurveTo is not implemented yet");
|
|
724
|
+
}
|
|
725
|
+
return false;
|
|
726
|
+
});
|
|
727
|
+
};
|