tldraw 5.2.0-next.e2b8d10bf10e → 5.2.0
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/DOCS.md +20294 -0
- package/README.md +13 -1
- package/RELEASE_NOTES.md +2908 -0
- package/dist-cjs/index.d.ts +110 -23
- package/dist-cjs/index.js +3 -3
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawImage.js +0 -1
- package/dist-cjs/lib/TldrawImage.js.map +2 -2
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js +2 -1
- package/dist-cjs/lib/bindings/arrow/ArrowBindingUtil.js.map +2 -2
- package/dist-cjs/lib/defaultEmbedDefinitions.js +3 -2
- package/dist-cjs/lib/defaultEmbedDefinitions.js.map +2 -2
- package/dist-cjs/lib/defaultOverlayUtils.js +11 -11
- package/dist-cjs/lib/defaultOverlayUtils.js.map +2 -2
- package/dist-cjs/lib/overlays/SelectionForegroundOverlayUtil.js +76 -64
- package/dist-cjs/lib/overlays/SelectionForegroundOverlayUtil.js.map +2 -2
- package/dist-cjs/lib/overlays/ShapeHandleOverlayUtil.js +1 -1
- package/dist-cjs/lib/overlays/ShapeHandleOverlayUtil.js.map +2 -2
- package/dist-cjs/lib/overlays/ShapeIndicatorOverlayUtil.js +107 -0
- package/dist-cjs/lib/overlays/ShapeIndicatorOverlayUtil.js.map +7 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +3 -0
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js +12 -3
- package/dist-cjs/lib/shapes/bookmark/BookmarkShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js +54 -6
- package/dist-cjs/lib/shapes/bookmark/bookmarks.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js +2 -1
- package/dist-cjs/lib/shapes/draw/DrawShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/getPath.js +1 -1
- package/dist-cjs/lib/shapes/draw/getPath.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +45 -47
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js +2 -1
- package/dist-cjs/lib/shapes/embed/EmbedShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js +23 -18
- package/dist-cjs/lib/shapes/frame/FrameShapeTool.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js +1 -1
- package/dist-cjs/lib/shapes/geo/GeoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +3 -0
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js +11 -7
- package/dist-cjs/lib/shapes/highlight/HighlightShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js +3 -11
- package/dist-cjs/lib/shapes/image/ImageShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +5 -1
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +31 -41
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js +1 -1
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +28 -6
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js +3 -2
- package/dist-cjs/lib/shapes/shared/PlainTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js +3 -3
- package/dist-cjs/lib/shapes/shared/RichTextLabel.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/defaultStyleDefs.js +17 -3
- package/dist-cjs/lib/shapes/shared/defaultStyleDefs.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/freehand/core.js +424 -0
- package/dist-cjs/lib/shapes/shared/freehand/core.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/fmt.js +106 -0
- package/dist-cjs/lib/shapes/shared/freehand/fmt.js.map +7 -0
- package/dist-cjs/lib/shapes/shared/freehand/getStroke.js +6 -6
- package/dist-cjs/lib/shapes/shared/freehand/getStroke.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/freehand/getStrokeOutlinePoints.js +320 -86
- package/dist-cjs/lib/shapes/shared/freehand/getStrokeOutlinePoints.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/freehand/getStrokePoints.js +20 -96
- package/dist-cjs/lib/shapes/shared/freehand/getStrokePoints.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/freehand/svg.js +55 -19
- package/dist-cjs/lib/shapes/shared/freehand/svg.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/freehand/svgInk.js +189 -97
- package/dist-cjs/lib/shapes/shared/freehand/svgInk.js.map +3 -3
- package/dist-cjs/lib/shapes/shared/freehand/types.js.map +1 -1
- package/dist-cjs/lib/shapes/shared/interpolate-props.js +6 -2
- package/dist-cjs/lib/shapes/shared/interpolate-props.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +3 -0
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/HandTool.js +16 -6
- package/dist-cjs/lib/tools/HandTool/HandTool.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js +10 -1
- package/dist-cjs/lib/tools/HandTool/childStates/Dragging.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js +84 -0
- package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js.map +7 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +12 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +4 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +107 -46
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/ui/TldrawUi.js +4 -3
- package/dist-cjs/lib/ui/TldrawUi.js.map +2 -2
- package/dist-cjs/lib/ui/components/A11y.js +2 -0
- package/dist-cjs/lib/ui/components/A11y.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +14 -1
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenuContent.js +0 -6
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/DefaultFollowingIndicator.js.map +2 -2
- package/dist-cjs/lib/ui/components/Dialogs.js +17 -37
- package/dist-cjs/lib/ui/components/Dialogs.js.map +2 -2
- package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js +19 -4
- package/dist-cjs/lib/ui/components/HelperButtons/BackToContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js +12 -2
- package/dist-cjs/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +47 -70
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js +25 -46
- package/dist-cjs/lib/ui/components/Minimap/MinimapManager.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/DefaultPeopleMenuAvatar.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/DefaultPeopleMenuContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/DefaultPeopleMenuFacePile.js.map +2 -2
- package/dist-cjs/lib/ui/components/SharePanel/DefaultPeopleMenuItem.js +1 -1
- package/dist-cjs/lib/ui/components/SharePanel/DefaultPeopleMenuItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js +1 -0
- package/dist-cjs/lib/ui/components/StylePanel/StylePanelButtonPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/menu-items.js +7 -0
- package/dist-cjs/lib/ui/components/menu-items.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDropdownMenu.js +2 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiDropdownMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js +14 -3
- package/dist-cjs/lib/ui/components/primitives/TldrawUiIcon.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js +2 -0
- package/dist-cjs/lib/ui/components/primitives/TldrawUiInput.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js +2 -0
- package/dist-cjs/lib/ui/components/primitives/TldrawUiPopover.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js +0 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuSubmenu.js +1 -2
- package/dist-cjs/lib/ui/components/primitives/menus/TldrawUiMenuSubmenu.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +70 -1
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/context/asset-urls.js +5 -8
- package/dist-cjs/lib/ui/context/asset-urls.js.map +2 -2
- package/dist-cjs/lib/ui/context/events.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js +13 -0
- package/dist-cjs/lib/ui/hooks/useKeyboardShortcuts.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTools.js +1 -1
- package/dist-cjs/lib/ui/hooks/useTools.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useTranslation/TLUiTranslationKey.js.map +1 -1
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js +2 -0
- package/dist-cjs/lib/ui/hooks/useTranslation/defaultTranslation.js.map +2 -2
- package/dist-cjs/lib/ui/version.js +3 -3
- package/dist-cjs/lib/ui/version.js.map +1 -1
- package/dist-cjs/lib/utils/embeds/embeds.js +4 -4
- package/dist-cjs/lib/utils/embeds/embeds.js.map +2 -2
- package/dist-cjs/lib/utils/test-helpers.js +2 -2
- package/dist-cjs/lib/utils/test-helpers.js.map +2 -2
- package/dist-cjs/lib/utils/text/richText.js +3 -1
- package/dist-cjs/lib/utils/text/richText.js.map +2 -2
- package/dist-esm/index.d.mts +110 -23
- package/dist-esm/index.mjs +5 -3
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawImage.mjs +0 -1
- package/dist-esm/lib/TldrawImage.mjs.map +2 -2
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs +2 -1
- package/dist-esm/lib/bindings/arrow/ArrowBindingUtil.mjs.map +2 -2
- package/dist-esm/lib/defaultEmbedDefinitions.mjs +3 -2
- package/dist-esm/lib/defaultEmbedDefinitions.mjs.map +2 -2
- package/dist-esm/lib/defaultOverlayUtils.mjs +11 -11
- package/dist-esm/lib/defaultOverlayUtils.mjs.map +2 -2
- package/dist-esm/lib/overlays/SelectionForegroundOverlayUtil.mjs +77 -65
- package/dist-esm/lib/overlays/SelectionForegroundOverlayUtil.mjs.map +2 -2
- package/dist-esm/lib/overlays/ShapeHandleOverlayUtil.mjs +1 -1
- package/dist-esm/lib/overlays/ShapeHandleOverlayUtil.mjs.map +2 -2
- package/dist-esm/lib/overlays/ShapeIndicatorOverlayUtil.mjs +87 -0
- package/dist-esm/lib/overlays/ShapeIndicatorOverlayUtil.mjs.map +7 -0
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +9 -1
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs +15 -3
- package/dist-esm/lib/shapes/bookmark/BookmarkShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs +54 -6
- package/dist-esm/lib/shapes/bookmark/bookmarks.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs +3 -1
- package/dist-esm/lib/shapes/draw/DrawShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/getPath.mjs +1 -1
- package/dist-esm/lib/shapes/draw/getPath.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +46 -47
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs +2 -1
- package/dist-esm/lib/shapes/embed/EmbedShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs +23 -18
- package/dist-esm/lib/shapes/frame/FrameShapeTool.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs +2 -1
- package/dist-esm/lib/shapes/geo/GeoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +4 -0
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs +12 -7
- package/dist-esm/lib/shapes/highlight/HighlightShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs +3 -11
- package/dist-esm/lib/shapes/image/ImageShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +6 -1
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +32 -42
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs +1 -1
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +29 -6
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs +3 -2
- package/dist-esm/lib/shapes/shared/PlainTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs +4 -3
- package/dist-esm/lib/shapes/shared/RichTextLabel.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/defaultStyleDefs.mjs +17 -3
- package/dist-esm/lib/shapes/shared/defaultStyleDefs.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/freehand/core.mjs +404 -0
- package/dist-esm/lib/shapes/shared/freehand/core.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/fmt.mjs +86 -0
- package/dist-esm/lib/shapes/shared/freehand/fmt.mjs.map +7 -0
- package/dist-esm/lib/shapes/shared/freehand/getStroke.mjs +7 -7
- package/dist-esm/lib/shapes/shared/freehand/getStroke.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/freehand/getStrokeOutlinePoints.mjs +332 -86
- package/dist-esm/lib/shapes/shared/freehand/getStrokeOutlinePoints.mjs.map +3 -3
- package/dist-esm/lib/shapes/shared/freehand/getStrokePoints.mjs +31 -96
- package/dist-esm/lib/shapes/shared/freehand/getStrokePoints.mjs.map +3 -3
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs +55 -19
- package/dist-esm/lib/shapes/shared/freehand/svg.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/freehand/svgInk.mjs +214 -99
- package/dist-esm/lib/shapes/shared/freehand/svgInk.mjs.map +3 -3
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs +6 -2
- package/dist-esm/lib/shapes/shared/interpolate-props.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +4 -0
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/HandTool.mjs +16 -6
- package/dist-esm/lib/tools/HandTool/HandTool.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs +10 -1
- package/dist-esm/lib/tools/HandTool/childStates/Dragging.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs +64 -0
- package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs.map +7 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +12 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +4 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +108 -46
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/ui/TldrawUi.mjs +4 -3
- package/dist-esm/lib/ui/TldrawUi.mjs.map +2 -2
- package/dist-esm/lib/ui/components/A11y.mjs +2 -0
- package/dist-esm/lib/ui/components/A11y.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +21 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenuContent.mjs +0 -6
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/DefaultFollowingIndicator.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Dialogs.mjs +19 -39
- package/dist-esm/lib/ui/components/Dialogs.mjs.map +2 -2
- package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs +20 -5
- package/dist-esm/lib/ui/components/HelperButtons/BackToContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs +12 -2
- package/dist-esm/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +47 -70
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs +25 -46
- package/dist-esm/lib/ui/components/Minimap/MinimapManager.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/DefaultPeopleMenuAvatar.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/DefaultPeopleMenuContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/DefaultPeopleMenuFacePile.mjs.map +2 -2
- package/dist-esm/lib/ui/components/SharePanel/DefaultPeopleMenuItem.mjs +1 -1
- package/dist-esm/lib/ui/components/SharePanel/DefaultPeopleMenuItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs +1 -0
- package/dist-esm/lib/ui/components/StylePanel/StylePanelButtonPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/menu-items.mjs +7 -0
- package/dist-esm/lib/ui/components/menu-items.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiDropdownMenu.mjs +2 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiDropdownMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs +14 -3
- package/dist-esm/lib/ui/components/primitives/TldrawUiIcon.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs +2 -0
- package/dist-esm/lib/ui/components/primitives/TldrawUiInput.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs +2 -0
- package/dist-esm/lib/ui/components/primitives/TldrawUiPopover.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs +0 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuSubmenu.mjs +1 -2
- package/dist-esm/lib/ui/components/primitives/menus/TldrawUiMenuSubmenu.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +71 -1
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/context/asset-urls.mjs +5 -8
- package/dist-esm/lib/ui/context/asset-urls.mjs.map +2 -2
- package/dist-esm/lib/ui/context/events.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs +13 -0
- package/dist-esm/lib/ui/hooks/useKeyboardShortcuts.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTools.mjs +1 -1
- package/dist-esm/lib/ui/hooks/useTools.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs +2 -0
- package/dist-esm/lib/ui/hooks/useTranslation/defaultTranslation.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/dist-esm/lib/utils/embeds/embeds.mjs +4 -4
- package/dist-esm/lib/utils/embeds/embeds.mjs.map +2 -2
- package/dist-esm/lib/utils/test-helpers.mjs +2 -2
- package/dist-esm/lib/utils/test-helpers.mjs.map +2 -2
- package/dist-esm/lib/utils/text/richText.mjs +3 -1
- package/dist-esm/lib/utils/text/richText.mjs.map +2 -2
- package/package.json +11 -6
- package/src/index.ts +6 -1
- package/src/lib/TldrawImage.tsx +2 -2
- package/src/lib/bindings/arrow/ArrowBindingUtil.ts +5 -1
- package/src/lib/defaultEmbedDefinitions.ts +28 -6
- package/src/lib/defaultOverlayUtils.ts +11 -11
- package/src/lib/overlays/SelectionForegroundOverlayUtil.ts +91 -72
- package/src/lib/overlays/ShapeHandleOverlayUtil.ts +3 -1
- package/src/lib/overlays/ShapeIndicatorOverlayUtil.ts +133 -0
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +11 -1
- package/src/lib/shapes/bookmark/BookmarkShapeUtil.tsx +16 -3
- package/src/lib/shapes/bookmark/bookmarks.ts +105 -15
- package/src/lib/shapes/draw/DrawShapeUtil.tsx +7 -5
- package/src/lib/shapes/draw/getPath.ts +1 -1
- package/src/lib/shapes/draw/toolStates/Drawing.ts +55 -48
- package/src/lib/shapes/embed/EmbedShapeUtil.tsx +14 -4
- package/src/lib/shapes/frame/FrameShapeTool.ts +35 -24
- package/src/lib/shapes/geo/GeoShapeUtil.test.tsx +46 -0
- package/src/lib/shapes/geo/GeoShapeUtil.tsx +2 -1
- package/src/lib/shapes/geo/toolStates/Pointing.ts +5 -0
- package/src/lib/shapes/highlight/HighlightShapeUtil.tsx +14 -11
- package/src/lib/shapes/image/ImageShapeUtil.tsx +7 -11
- package/src/lib/shapes/line/LineShapeTool.test.ts +41 -0
- package/src/lib/shapes/line/toolStates/Pointing.ts +12 -2
- package/src/lib/shapes/note/NoteShapeUtil.tsx +36 -51
- package/src/lib/shapes/note/noteCloning.test.ts +5 -5
- package/src/lib/shapes/note/noteHelpers.ts +1 -1
- package/src/lib/shapes/note/toolStates/Pointing.ts +40 -7
- package/src/lib/shapes/shared/PlainTextLabel.tsx +3 -3
- package/src/lib/shapes/shared/RichTextLabel.tsx +4 -3
- package/src/lib/shapes/shared/defaultStyleDefs.tsx +25 -3
- package/src/lib/shapes/shared/freehand/core.ts +547 -0
- package/src/lib/shapes/shared/freehand/fmt.ts +106 -0
- package/src/lib/shapes/shared/freehand/getStroke.ts +7 -7
- package/src/lib/shapes/shared/freehand/getStrokeOutlinePoints.ts +451 -139
- package/src/lib/shapes/shared/freehand/getStrokePoints.ts +33 -153
- package/src/lib/shapes/shared/freehand/svg.ts +72 -23
- package/src/lib/shapes/shared/freehand/svgInk.ts +281 -136
- package/src/lib/shapes/shared/freehand/types.ts +0 -1
- package/src/lib/shapes/shared/interpolate-props.ts +6 -2
- package/src/lib/shapes/text/toolStates/Pointing.ts +5 -0
- package/src/lib/tools/HandTool/HandTool.ts +19 -6
- package/src/lib/tools/HandTool/childStates/Dragging.ts +17 -1
- package/src/lib/tools/HandTool/childStates/OneFingerZooming.ts +79 -0
- package/src/lib/tools/SelectTool/childStates/Idle.ts +16 -2
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +8 -0
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +137 -49
- package/src/lib/ui/TldrawUi.tsx +3 -3
- package/src/lib/ui/components/A11y.tsx +2 -0
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +32 -2
- package/src/lib/ui/components/ContextMenu/DefaultContextMenuContent.tsx +5 -6
- package/src/lib/ui/components/DefaultFollowingIndicator.tsx +2 -2
- package/src/lib/ui/components/Dialogs.tsx +20 -23
- package/src/lib/ui/components/HelperButtons/BackToContent.tsx +32 -4
- package/src/lib/ui/components/KeyboardShortcutsDialog/DefaultKeyboardShortcutsDialogContent.tsx +10 -0
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +60 -74
- package/src/lib/ui/components/Minimap/MinimapManager.ts +35 -57
- package/src/lib/ui/components/SharePanel/DefaultPeopleMenuAvatar.tsx +2 -2
- package/src/lib/ui/components/SharePanel/DefaultPeopleMenuContent.tsx +2 -1
- package/src/lib/ui/components/SharePanel/DefaultPeopleMenuFacePile.tsx +2 -1
- package/src/lib/ui/components/SharePanel/DefaultPeopleMenuItem.tsx +3 -3
- package/src/lib/ui/components/StylePanel/StylePanelButtonPicker.tsx +5 -0
- package/src/lib/ui/components/menu-items.tsx +9 -0
- package/src/lib/ui/components/primitives/TldrawUiDropdownMenu.tsx +3 -1
- package/src/lib/ui/components/primitives/TldrawUiIcon.tsx +15 -3
- package/src/lib/ui/components/primitives/TldrawUiInput.tsx +4 -0
- package/src/lib/ui/components/primitives/TldrawUiPopover.tsx +7 -0
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuCheckboxItem.tsx +0 -2
- package/src/lib/ui/components/primitives/menus/TldrawUiMenuSubmenu.tsx +0 -1
- package/src/lib/ui/context/actions.tsx +88 -1
- package/src/lib/ui/context/asset-urls.tsx +9 -8
- package/src/lib/ui/context/events.tsx +2 -0
- package/src/lib/ui/hooks/useKeyboardShortcuts.ts +45 -7
- package/src/lib/ui/hooks/useTools.tsx +7 -1
- package/src/lib/ui/hooks/useTranslation/TLUiTranslationKey.ts +2 -0
- package/src/lib/ui/hooks/useTranslation/defaultTranslation.ts +2 -0
- package/src/lib/ui/version.ts +3 -3
- package/src/lib/ui.css +20 -9
- package/src/lib/utils/embeds/embeds.test.ts +14 -12
- package/src/lib/utils/embeds/embeds.ts +10 -4
- package/src/lib/utils/test-helpers.ts +3 -3
- package/src/lib/utils/text/richText.test.ts +36 -0
- package/src/lib/utils/text/richText.ts +9 -1
- package/src/test/HandTool.test.ts +93 -0
- package/src/test/ImageShapeUtil.test.ts +88 -0
- package/src/test/SelectTool.test.ts +102 -1
- package/src/test/__snapshots__/drawing.test.ts.snap +2 -1
- package/src/test/attribution.test.ts +40 -29
- package/src/test/bookmark-shapes.test.ts +256 -28
- package/src/test/commands/__snapshots__/getSvgString.test.ts.snap +2 -2
- package/src/test/commands/clipboardCallbacks.test.ts +3 -1
- package/src/test/commands/getSvgString.test.ts +30 -0
- package/src/test/commands/penmode.test.ts +97 -1
- package/src/test/commands/setCamera.test.ts +12 -0
- package/src/test/dragFromToolbar.test.ts +67 -0
- package/src/test/drawing.test.ts +48 -7
- package/src/test/frames.test.ts +72 -0
- package/src/test/freehand/corpus/presets.ts +71 -0
- package/src/test/freehand/corpus/real.ts +370 -0
- package/src/test/freehand/corpus/strokes.ts +50 -0
- package/src/test/freehand/svg.test.ts +20 -0
- package/src/test/freehand/wellformed.test.ts +30 -0
- package/src/test/long-press-create.test.ts +102 -0
- package/src/test/overlays/CollaboratorBrushOverlayUtil.test.ts +4 -4
- package/src/test/overlays/CollaboratorCursorOverlayUtil.test.ts +18 -18
- package/src/test/overlays/CollaboratorHintOverlayUtil.test.ts +7 -7
- package/src/test/overlays/CollaboratorScribbleOverlayUtil.test.ts +3 -3
- package/src/test/overlays/OverlayManager.test.ts +1 -1
- package/src/test/overlays/SelectionForegroundOverlayUtil.test.ts +58 -0
- package/src/test/overlays/ShapeHandleOverlayUtil.test.ts +2 -2
- package/src/test/overlays/ShapeIndicatorOverlayUtil.test.ts +36 -0
- package/src/test/resizing.test.ts +250 -0
- package/src/test/right-click-context-menu.test.ts +90 -0
- package/src/test/rightClickPanning.test.ts +11 -0
- package/src/test/selection-omnibus.test.ts +15 -2
- package/src/test/spatialIndex.test.ts +132 -0
- package/src/test/translating.test.ts +0 -6
- package/src/test/ui/ContextMenu.test.tsx +146 -3
- package/src/test/ui/Dialogs.test.tsx +256 -0
- package/src/test/ui/copyHoveredStyles.test.tsx +154 -0
- package/src/test/ui/keyboardShortcuts.test.tsx +266 -0
- package/tldraw.css +35 -12
- package/dist-cjs/lib/shapes/shared/freehand/setStrokePointRadii.js +0 -100
- package/dist-cjs/lib/shapes/shared/freehand/setStrokePointRadii.js.map +0 -7
- package/dist-esm/lib/shapes/shared/freehand/setStrokePointRadii.mjs +0 -80
- package/dist-esm/lib/shapes/shared/freehand/setStrokePointRadii.mjs.map +0 -7
- package/src/lib/shapes/shared/freehand/setStrokePointRadii.ts +0 -127
|
@@ -22,106 +22,30 @@ __export(getStrokePoints_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(getStrokePoints_exports);
|
|
24
24
|
var import_editor = require("@tldraw/editor");
|
|
25
|
-
|
|
25
|
+
var import_core = require("./core");
|
|
26
26
|
function getStrokePoints(rawInputPoints, options = {}) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
point: import_editor.Vec.From(rawInputPoints[0]),
|
|
43
|
-
input: import_editor.Vec.From(rawInputPoints[0]),
|
|
44
|
-
pressure: simulatePressure ? 0.5 : 0.15,
|
|
45
|
-
vector: new import_editor.Vec(1, 1),
|
|
46
|
-
distance: 0,
|
|
47
|
-
runningLength: 0,
|
|
48
|
-
radius: 1
|
|
49
|
-
}
|
|
50
|
-
];
|
|
51
|
-
let pt = pts[1];
|
|
52
|
-
while (pt) {
|
|
53
|
-
if (import_editor.Vec.Dist2(pt, pts[0]) > (size / 3) ** 2) break;
|
|
54
|
-
pts[0].z = Math.max(pts[0].z, pt.z);
|
|
55
|
-
pts.splice(1, 1);
|
|
56
|
-
pt = pts[1];
|
|
57
|
-
}
|
|
58
|
-
const last = pts.pop();
|
|
59
|
-
pt = pts[pts.length - 1];
|
|
60
|
-
while (pt) {
|
|
61
|
-
if (import_editor.Vec.Dist2(pt, last) > (size / 3) ** 2) break;
|
|
62
|
-
pts.pop();
|
|
63
|
-
pt = pts[pts.length - 1];
|
|
64
|
-
pointsRemovedFromNearEnd++;
|
|
65
|
-
}
|
|
66
|
-
pts.push(last);
|
|
67
|
-
const isComplete = options.last || !options.simulatePressure || pts.length > 1 && import_editor.Vec.Dist2(pts[pts.length - 1], pts[pts.length - 2]) < size ** 2 || pointsRemovedFromNearEnd > 0;
|
|
68
|
-
if (pts.length === 2 && options.simulatePressure) {
|
|
69
|
-
const last2 = pts[1];
|
|
70
|
-
pts = pts.slice(0, -1);
|
|
71
|
-
for (let i = 1; i < 5; i++) {
|
|
72
|
-
const next = import_editor.Vec.Lrp(pts[0], last2, i / 4);
|
|
73
|
-
next.z = (pts[0].z + (last2.z - pts[0].z)) * i / 4;
|
|
74
|
-
pts.push(next);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const strokePoints = [
|
|
78
|
-
{
|
|
79
|
-
point: pts[0],
|
|
80
|
-
input: pts[0],
|
|
81
|
-
pressure: simulatePressure ? 0.5 : pts[0].z,
|
|
82
|
-
vector: new import_editor.Vec(1, 1),
|
|
83
|
-
distance: 0,
|
|
84
|
-
runningLength: 0,
|
|
85
|
-
radius: 1
|
|
86
|
-
}
|
|
87
|
-
];
|
|
88
|
-
let totalLength = 0;
|
|
89
|
-
let prev = strokePoints[0];
|
|
90
|
-
let point, distance;
|
|
91
|
-
if (isComplete && streamline > 0) {
|
|
92
|
-
pts.push(pts[pts.length - 1].clone());
|
|
93
|
-
}
|
|
94
|
-
for (let i = 1, n = pts.length; i < n; i++) {
|
|
95
|
-
point = !t || options.last && i === n - 1 ? pts[i].clone() : pts[i].clone().lrp(prev.point, 1 - t);
|
|
96
|
-
if (prev.point.equals(point)) continue;
|
|
97
|
-
distance = import_editor.Vec.Dist(point, prev.point);
|
|
98
|
-
totalLength += distance;
|
|
99
|
-
if (i < 4 && totalLength < size) {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
prev = {
|
|
103
|
-
input: pts[i],
|
|
104
|
-
// The adjusted point
|
|
27
|
+
(0, import_core.ingest)(rawInputPoints, options);
|
|
28
|
+
const n = import_core.pointCount;
|
|
29
|
+
const ptX = import_core.pointX;
|
|
30
|
+
const ptY = import_core.pointY;
|
|
31
|
+
const inX = import_core.inputX;
|
|
32
|
+
const inY = import_core.inputY;
|
|
33
|
+
const inZ = import_core.inputZ;
|
|
34
|
+
const press = import_core.pressures;
|
|
35
|
+
const dists = import_core.distances;
|
|
36
|
+
const runs = import_core.runningLengths;
|
|
37
|
+
const strokePoints = new Array(n);
|
|
38
|
+
for (let i = 0; i < n; i++) {
|
|
39
|
+
const input = new import_editor.Vec(inX[i], inY[i], inZ[i]);
|
|
40
|
+
const point = i === 0 ? input : new import_editor.Vec(ptX[i], ptY[i], inZ[i]);
|
|
41
|
+
strokePoints[i] = {
|
|
105
42
|
point,
|
|
106
|
-
|
|
107
|
-
pressure:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// The distance between the current point and the previous point
|
|
111
|
-
distance,
|
|
112
|
-
// The total distance so far
|
|
113
|
-
runningLength: totalLength,
|
|
114
|
-
// The stroke point's radius
|
|
43
|
+
input,
|
|
44
|
+
pressure: press[i],
|
|
45
|
+
distance: dists[i],
|
|
46
|
+
runningLength: runs[i],
|
|
115
47
|
radius: 1
|
|
116
48
|
};
|
|
117
|
-
strokePoints.push(prev);
|
|
118
|
-
}
|
|
119
|
-
if (strokePoints[1]?.vector) {
|
|
120
|
-
strokePoints[0].vector = strokePoints[1].vector.clone();
|
|
121
|
-
}
|
|
122
|
-
if (totalLength < 1) {
|
|
123
|
-
const maxPressureAmongPoints = Math.max(0.5, ...strokePoints.map((s) => s.pressure));
|
|
124
|
-
strokePoints.forEach((s) => s.pressure = maxPressureAmongPoints);
|
|
125
49
|
}
|
|
126
50
|
return strokePoints;
|
|
127
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/shapes/shared/freehand/getStrokePoints.ts"],
|
|
4
|
-
"sourcesContent": ["import { Vec, VecLike } from '@tldraw/editor'\nimport type { StrokeOptions, StrokePoint } from './types'\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { Vec, VecLike } from '@tldraw/editor'\nimport {\n\tdistances,\n\tingest,\n\tinputX,\n\tinputY,\n\tinputZ,\n\tpointCount,\n\tpointX,\n\tpointY,\n\tpressures,\n\trunningLengths,\n} from './core'\nimport type { StrokeOptions, StrokePoint } from './types'\n\n/**\n * ## getStrokePoints\n *\n * Get an array of points as objects with an adjusted point, pressure, vector, distance, and\n * runningLength.\n *\n * @param points - An array of points (as `[x, y, pressure]` or `{x, y, pressure}`). Pressure is\n * optional in both cases.\n * @param options - An object with options.\n * @public\n */\nexport function getStrokePoints(\n\trawInputPoints: VecLike[],\n\toptions: StrokeOptions = {}\n): StrokePoint[] {\n\tingest(rawInputPoints, options)\n\n\tconst n = pointCount\n\tconst ptX = pointX\n\tconst ptY = pointY\n\tconst inX = inputX\n\tconst inY = inputY\n\tconst inZ = inputZ\n\tconst press = pressures\n\tconst dists = distances\n\tconst runs = runningLengths\n\tconst strokePoints: StrokePoint[] = new Array(n)\n\tfor (let i = 0; i < n; i++) {\n\t\tconst input = new Vec(inX[i], inY[i], inZ[i])\n\t\t// The first point needs no adjustment, so its point and input are the same vector.\n\t\tconst point = i === 0 ? input : new Vec(ptX[i], ptY[i], inZ[i])\n\t\tstrokePoints[i] = {\n\t\t\tpoint,\n\t\t\tinput,\n\t\t\tpressure: press[i],\n\t\t\tdistance: dists[i],\n\t\t\trunningLength: runs[i],\n\t\t\tradius: 1,\n\t\t}\n\t}\n\treturn strokePoints\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6B;AAC7B,kBAWO;AAcA,SAAS,gBACf,gBACA,UAAyB,CAAC,GACV;AAChB,0BAAO,gBAAgB,OAAO;AAE9B,QAAM,IAAI;AACV,QAAM,MAAM;AACZ,QAAM,MAAM;AACZ,QAAM,MAAM;AACZ,QAAM,MAAM;AACZ,QAAM,MAAM;AACZ,QAAM,QAAQ;AACd,QAAM,QAAQ;AACd,QAAM,OAAO;AACb,QAAM,eAA8B,IAAI,MAAM,CAAC;AAC/C,WAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC3B,UAAM,QAAQ,IAAI,kBAAI,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAE5C,UAAM,QAAQ,MAAM,IAAI,QAAQ,IAAI,kBAAI,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9D,iBAAa,CAAC,IAAI;AAAA,MACjB;AAAA,MACA;AAAA,MACA,UAAU,MAAM,CAAC;AAAA,MACjB,UAAU,MAAM,CAAC;AAAA,MACjB,eAAe,KAAK,CAAC;AAAA,MACrB,QAAQ;AAAA,IACT;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -21,36 +21,72 @@ __export(svg_exports, {
|
|
|
21
21
|
getSvgPathFromStrokePoints: () => getSvgPathFromStrokePoints
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(svg_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_fmt = require("./fmt");
|
|
25
25
|
function getSvgPathFromStrokePoints(points, closed = false) {
|
|
26
26
|
const len = points.length;
|
|
27
27
|
if (len < 2) {
|
|
28
28
|
return "";
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
let b = points[1].point;
|
|
30
|
+
(0, import_fmt.resetPath)();
|
|
32
31
|
if (len === 2) {
|
|
33
|
-
|
|
32
|
+
const a = points[0].point;
|
|
33
|
+
const b = points[1].point;
|
|
34
|
+
const ax = (0, import_fmt.toCenti)(a.x);
|
|
35
|
+
const ay = (0, import_fmt.toCenti)(a.y);
|
|
36
|
+
(0, import_fmt.writeStr)("M");
|
|
37
|
+
(0, import_fmt.writeCPair)(ax, ay);
|
|
38
|
+
(0, import_fmt.writeStr)("l");
|
|
39
|
+
(0, import_fmt.writeCPair)((0, import_fmt.toCenti)(b.x) - ax, (0, import_fmt.toCenti)(b.y) - ay);
|
|
40
|
+
return (0, import_fmt.finishPath)();
|
|
41
|
+
}
|
|
42
|
+
const first = points[0].point;
|
|
43
|
+
const second = points[1].point;
|
|
44
|
+
const third = points[2].point;
|
|
45
|
+
const secondX = (0, import_fmt.toCenti)(second.x);
|
|
46
|
+
const secondY = (0, import_fmt.toCenti)(second.y);
|
|
47
|
+
const m01x = Math.round((first.x + second.x) * 50);
|
|
48
|
+
const m01y = Math.round((first.y + second.y) * 50);
|
|
49
|
+
const m12x = Math.round((second.x + third.x) * 50);
|
|
50
|
+
const m12y = Math.round((second.y + third.y) * 50);
|
|
51
|
+
let cx = m12x;
|
|
52
|
+
let cy = m12y;
|
|
53
|
+
if (closed) {
|
|
54
|
+
(0, import_fmt.writeStr)("M");
|
|
55
|
+
(0, import_fmt.writeCPair)(m01x, m01y);
|
|
56
|
+
(0, import_fmt.writeStr)("q");
|
|
57
|
+
(0, import_fmt.writeCPair)(secondX - m01x, secondY - m01y);
|
|
58
|
+
(0, import_fmt.writeCPair)(m12x - m01x, m12y - m01y);
|
|
59
|
+
(0, import_fmt.writeStr)("t");
|
|
60
|
+
} else {
|
|
61
|
+
const firstX = (0, import_fmt.toCenti)(first.x);
|
|
62
|
+
const firstY = (0, import_fmt.toCenti)(first.y);
|
|
63
|
+
(0, import_fmt.writeStr)("M");
|
|
64
|
+
(0, import_fmt.writeCPair)(firstX, firstY);
|
|
65
|
+
(0, import_fmt.writeStr)("q");
|
|
66
|
+
(0, import_fmt.writeCPair)(secondX - firstX, secondY - firstY);
|
|
67
|
+
(0, import_fmt.writeCPair)(m12x - firstX, m12y - firstY);
|
|
68
|
+
if (len > 3) (0, import_fmt.writeStr)("t");
|
|
34
69
|
}
|
|
35
|
-
let result = "";
|
|
36
70
|
for (let i = 2, max = len - 1; i < max; i++) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
71
|
+
const p = points[i].point;
|
|
72
|
+
const q = points[i + 1].point;
|
|
73
|
+
const mx = Math.round((p.x + q.x) * 50);
|
|
74
|
+
const my = Math.round((p.y + q.y) * 50);
|
|
75
|
+
(0, import_fmt.writeCPair)(mx - cx, my - cy);
|
|
76
|
+
cx = mx;
|
|
77
|
+
cy = my;
|
|
40
78
|
}
|
|
79
|
+
const last = points[len - 1].point;
|
|
41
80
|
if (closed) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
points[1].point
|
|
48
|
-
)}Z`;
|
|
81
|
+
const mLastX = Math.round((last.x + first.x) * 50);
|
|
82
|
+
const mLastY = Math.round((last.y + first.y) * 50);
|
|
83
|
+
(0, import_fmt.writeCPair)(mLastX - cx, mLastY - cy);
|
|
84
|
+
(0, import_fmt.writeCPair)(m01x - mLastX, m01y - mLastY);
|
|
85
|
+
(0, import_fmt.writeStr)("Z");
|
|
49
86
|
} else {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
points[2].point
|
|
53
|
-
)}${points.length > 3 ? "T" : ""}${result}L${(0, import_editor.precise)(points[len - 1].point)}`;
|
|
87
|
+
(0, import_fmt.writeStr)("l");
|
|
88
|
+
(0, import_fmt.writeCPair)((0, import_fmt.toCenti)(last.x) - cx, (0, import_fmt.toCenti)(last.y) - cy);
|
|
54
89
|
}
|
|
90
|
+
return (0, import_fmt.finishPath)();
|
|
55
91
|
}
|
|
56
92
|
//# sourceMappingURL=svg.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/shapes/shared/freehand/svg.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["import { finishPath, resetPath, toCenti, writeCPair, writeStr } from './fmt'\nimport { StrokePoint } from './types'\n\n/**\n * Turn an array of stroke points into a path of quadratic curves.\n *\n * The path uses relative commands with coordinates rounded to hundredths of a pixel, which\n * renders identically to the absolute 4-decimal form but is much smaller and faster to build.\n *\n * @param points - The stroke points returned from perfect-freehand\n * @param closed - Whether the shape is closed\n *\n * @public\n */\nexport function getSvgPathFromStrokePoints(points: StrokePoint[], closed = false): string {\n\tconst len = points.length\n\n\tif (len < 2) {\n\t\treturn ''\n\t}\n\n\tresetPath()\n\n\tif (len === 2) {\n\t\tconst a = points[0].point\n\t\tconst b = points[1].point\n\t\tconst ax = toCenti(a.x)\n\t\tconst ay = toCenti(a.y)\n\t\twriteStr('M')\n\t\twriteCPair(ax, ay)\n\t\twriteStr('l')\n\t\twriteCPair(toCenti(b.x) - ax, toCenti(b.y) - ay)\n\t\treturn finishPath()\n\t}\n\n\tconst first = points[0].point\n\tconst second = points[1].point\n\tconst third = points[2].point\n\n\tconst secondX = toCenti(second.x)\n\tconst secondY = toCenti(second.y)\n\t// midpoint of the first and second points\n\tconst m01x = Math.round((first.x + second.x) * 50)\n\tconst m01y = Math.round((first.y + second.y) * 50)\n\t// midpoint of the second and third points\n\tconst m12x = Math.round((second.x + third.x) * 50)\n\tconst m12y = Math.round((second.y + third.y) * 50)\n\n\t// Current position in integer hundredths\n\tlet cx = m12x\n\tlet cy = m12y\n\n\tif (closed) {\n\t\t// If closed, start at the first midpoint and draw a curve through the second point\n\t\twriteStr('M')\n\t\twriteCPair(m01x, m01y)\n\t\twriteStr('q')\n\t\twriteCPair(secondX - m01x, secondY - m01y)\n\t\twriteCPair(m12x - m01x, m12y - m01y)\n\t\twriteStr('t')\n\t} else {\n\t\t// If not closed, draw a curve starting at the first point and\n\t\t// ending at the midpoint of the second and third points.\n\t\tconst firstX = toCenti(first.x)\n\t\tconst firstY = toCenti(first.y)\n\t\twriteStr('M')\n\t\twriteCPair(firstX, firstY)\n\t\twriteStr('q')\n\t\twriteCPair(secondX - firstX, secondY - firstY)\n\t\twriteCPair(m12x - firstX, m12y - firstY)\n\t\tif (len > 3) writeStr('t')\n\t}\n\n\t// Continue the smooth quadratic chain through the midpoints of the remaining points\n\tfor (let i = 2, max = len - 1; i < max; i++) {\n\t\tconst p = points[i].point\n\t\tconst q = points[i + 1].point\n\t\tconst mx = Math.round((p.x + q.x) * 50)\n\t\tconst my = Math.round((p.y + q.y) * 50)\n\t\twriteCPair(mx - cx, my - cy)\n\t\tcx = mx\n\t\tcy = my\n\t}\n\n\tconst last = points[len - 1].point\n\n\tif (closed) {\n\t\t// Draw a curve from the last-first midpoint back to the first-second midpoint\n\t\tconst mLastX = Math.round((last.x + first.x) * 50)\n\t\tconst mLastY = Math.round((last.y + first.y) * 50)\n\t\twriteCPair(mLastX - cx, mLastY - cy)\n\t\twriteCPair(m01x - mLastX, m01y - mLastY)\n\t\twriteStr('Z')\n\t} else {\n\t\t// Complete the curve with a line segment to the last point.\n\t\twriteStr('l')\n\t\twriteCPair(toCenti(last.x) - cx, toCenti(last.y) - cy)\n\t}\n\n\treturn finishPath()\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAqE;AAc9D,SAAS,2BAA2B,QAAuB,SAAS,OAAe;AACzF,QAAM,MAAM,OAAO;AAEnB,MAAI,MAAM,GAAG;AACZ,WAAO;AAAA,EACR;AAEA,4BAAU;AAEV,MAAI,QAAQ,GAAG;AACd,UAAM,IAAI,OAAO,CAAC,EAAE;AACpB,UAAM,IAAI,OAAO,CAAC,EAAE;AACpB,UAAM,SAAK,oBAAQ,EAAE,CAAC;AACtB,UAAM,SAAK,oBAAQ,EAAE,CAAC;AACtB,6BAAS,GAAG;AACZ,+BAAW,IAAI,EAAE;AACjB,6BAAS,GAAG;AACZ,mCAAW,oBAAQ,EAAE,CAAC,IAAI,QAAI,oBAAQ,EAAE,CAAC,IAAI,EAAE;AAC/C,eAAO,uBAAW;AAAA,EACnB;AAEA,QAAM,QAAQ,OAAO,CAAC,EAAE;AACxB,QAAM,SAAS,OAAO,CAAC,EAAE;AACzB,QAAM,QAAQ,OAAO,CAAC,EAAE;AAExB,QAAM,cAAU,oBAAQ,OAAO,CAAC;AAChC,QAAM,cAAU,oBAAQ,OAAO,CAAC;AAEhC,QAAM,OAAO,KAAK,OAAO,MAAM,IAAI,OAAO,KAAK,EAAE;AACjD,QAAM,OAAO,KAAK,OAAO,MAAM,IAAI,OAAO,KAAK,EAAE;AAEjD,QAAM,OAAO,KAAK,OAAO,OAAO,IAAI,MAAM,KAAK,EAAE;AACjD,QAAM,OAAO,KAAK,OAAO,OAAO,IAAI,MAAM,KAAK,EAAE;AAGjD,MAAI,KAAK;AACT,MAAI,KAAK;AAET,MAAI,QAAQ;AAEX,6BAAS,GAAG;AACZ,+BAAW,MAAM,IAAI;AACrB,6BAAS,GAAG;AACZ,+BAAW,UAAU,MAAM,UAAU,IAAI;AACzC,+BAAW,OAAO,MAAM,OAAO,IAAI;AACnC,6BAAS,GAAG;AAAA,EACb,OAAO;AAGN,UAAM,aAAS,oBAAQ,MAAM,CAAC;AAC9B,UAAM,aAAS,oBAAQ,MAAM,CAAC;AAC9B,6BAAS,GAAG;AACZ,+BAAW,QAAQ,MAAM;AACzB,6BAAS,GAAG;AACZ,+BAAW,UAAU,QAAQ,UAAU,MAAM;AAC7C,+BAAW,OAAO,QAAQ,OAAO,MAAM;AACvC,QAAI,MAAM,EAAG,0BAAS,GAAG;AAAA,EAC1B;AAGA,WAAS,IAAI,GAAG,MAAM,MAAM,GAAG,IAAI,KAAK,KAAK;AAC5C,UAAM,IAAI,OAAO,CAAC,EAAE;AACpB,UAAM,IAAI,OAAO,IAAI,CAAC,EAAE;AACxB,UAAM,KAAK,KAAK,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;AACtC,UAAM,KAAK,KAAK,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;AACtC,+BAAW,KAAK,IAAI,KAAK,EAAE;AAC3B,SAAK;AACL,SAAK;AAAA,EACN;AAEA,QAAM,OAAO,OAAO,MAAM,CAAC,EAAE;AAE7B,MAAI,QAAQ;AAEX,UAAM,SAAS,KAAK,OAAO,KAAK,IAAI,MAAM,KAAK,EAAE;AACjD,UAAM,SAAS,KAAK,OAAO,KAAK,IAAI,MAAM,KAAK,EAAE;AACjD,+BAAW,SAAS,IAAI,SAAS,EAAE;AACnC,+BAAW,OAAO,QAAQ,OAAO,MAAM;AACvC,6BAAS,GAAG;AAAA,EACb,OAAO;AAEN,6BAAS,GAAG;AACZ,mCAAW,oBAAQ,KAAK,CAAC,IAAI,QAAI,oBAAQ,KAAK,CAAC,IAAI,EAAE;AAAA,EACtD;AAEA,aAAO,uBAAW;AACnB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -22,9 +22,9 @@ __export(svgInk_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(svgInk_exports);
|
|
24
24
|
var import_editor = require("@tldraw/editor");
|
|
25
|
+
var import_core = require("./core");
|
|
26
|
+
var import_fmt = require("./fmt");
|
|
25
27
|
var import_getStrokeOutlinePoints = require("./getStrokeOutlinePoints");
|
|
26
|
-
var import_getStrokePoints = require("./getStrokePoints");
|
|
27
|
-
var import_setStrokePointRadii = require("./setStrokePointRadii");
|
|
28
28
|
function svgInk(rawInputPoints, options = {}) {
|
|
29
29
|
const { start = {}, end = {} } = options;
|
|
30
30
|
const { cap: capStart = true } = start;
|
|
@@ -32,128 +32,220 @@ function svgInk(rawInputPoints, options = {}) {
|
|
|
32
32
|
(0, import_editor.assert)(!start.taper && !end.taper, "cap taper not supported here");
|
|
33
33
|
(0, import_editor.assert)(!start.easing && !end.easing, "cap easing not supported here");
|
|
34
34
|
(0, import_editor.assert)(capStart && capEnd, "cap must be true");
|
|
35
|
-
|
|
36
|
-
(0,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
svg += renderPartition(partition, options);
|
|
41
|
-
}
|
|
42
|
-
return svg;
|
|
35
|
+
(0, import_core.ingest)(rawInputPoints, options);
|
|
36
|
+
(0, import_core.computeRadii)(options);
|
|
37
|
+
(0, import_fmt.resetPath)();
|
|
38
|
+
partitionAtElbows(options);
|
|
39
|
+
return (0, import_fmt.finishPath)();
|
|
43
40
|
}
|
|
44
|
-
function partitionAtElbows(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
function partitionAtElbows(options) {
|
|
42
|
+
const n = import_core.pointCount;
|
|
43
|
+
if (n === 0) return;
|
|
44
|
+
if (n <= 2) {
|
|
45
|
+
(0, import_core.loadSrcFromPipeline)();
|
|
46
|
+
renderPartition(options, false, 0, 0);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const ptX = import_core.pointX;
|
|
50
|
+
const ptY = import_core.pointY;
|
|
51
|
+
const rads = import_core.radii;
|
|
52
|
+
let a = 0;
|
|
53
|
+
let aElbow = false;
|
|
54
|
+
let hasAnchor = false;
|
|
55
|
+
let anchorX = 0;
|
|
56
|
+
let anchorY = 0;
|
|
57
|
+
let dx = ptX[1] - ptX[0];
|
|
58
|
+
let dy = ptY[1] - ptY[0];
|
|
59
|
+
let len = Math.sqrt(dx * dx + dy * dy);
|
|
60
|
+
let prevVx = dx / len;
|
|
61
|
+
let prevVy = dy / len;
|
|
62
|
+
for (let i = 1; i < n - 1; i++) {
|
|
63
|
+
dx = ptX[i + 1] - ptX[i];
|
|
64
|
+
dy = ptY[i + 1] - ptY[i];
|
|
65
|
+
len = Math.sqrt(dx * dx + dy * dy);
|
|
66
|
+
const nextVx = dx / len;
|
|
67
|
+
const nextVy = dy / len;
|
|
68
|
+
const dpr = prevVx * nextVx + prevVy * nextVy;
|
|
69
|
+
prevVx = nextVx;
|
|
70
|
+
prevVy = nextVy;
|
|
59
71
|
if (dpr < -0.8) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
currentPartition = [elbowPoint];
|
|
72
|
+
finishPartition(a, aElbow, i, true, false, hasAnchor, anchorX, anchorY, options);
|
|
73
|
+
a = i;
|
|
74
|
+
aElbow = true;
|
|
75
|
+
hasAnchor = true;
|
|
76
|
+
anchorX = ptX[i];
|
|
77
|
+
anchorY = ptY[i];
|
|
67
78
|
continue;
|
|
68
79
|
}
|
|
69
|
-
currentPartition.push(thisPoint);
|
|
70
80
|
if (dpr > 0.7) {
|
|
71
81
|
continue;
|
|
72
82
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
const pdx = ptX[i] - ptX[i - 1];
|
|
84
|
+
const pdy = ptY[i] - ptY[i - 1];
|
|
85
|
+
const ndx = ptX[i + 1] - ptX[i];
|
|
86
|
+
const ndy = ptY[i + 1] - ptY[i];
|
|
87
|
+
const meanRadius = (rads[i - 1] + rads[i] + rads[i + 1]) / 3;
|
|
88
|
+
if ((pdx * pdx + pdy * pdy + ndx * ndx + ndy * ndy) / (meanRadius * meanRadius) < 1.5) {
|
|
89
|
+
finishPartition(a, aElbow, i, false, true, hasAnchor, anchorX, anchorY, options);
|
|
90
|
+
a = i;
|
|
91
|
+
aElbow = false;
|
|
92
|
+
hasAnchor = false;
|
|
77
93
|
continue;
|
|
78
94
|
}
|
|
79
95
|
}
|
|
80
|
-
|
|
81
|
-
result.push(cleanUpPartition(currentPartition));
|
|
82
|
-
return result;
|
|
96
|
+
finishPartition(a, aElbow, n - 1, false, false, hasAnchor, anchorX, anchorY, options);
|
|
83
97
|
}
|
|
84
|
-
function
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
function finishPartition(a, aElbow, b, bElbow, bDup, hasAnchor, anchorX, anchorY, options) {
|
|
99
|
+
const ptX = import_core.pointX;
|
|
100
|
+
const ptY = import_core.pointY;
|
|
101
|
+
const rads = import_core.radii;
|
|
102
|
+
const len = b - a + 1 + (bDup ? 1 : 0);
|
|
103
|
+
let s = 0;
|
|
104
|
+
let e = 0;
|
|
105
|
+
const startX = aElbow ? import_core.inputX[a] : ptX[a];
|
|
106
|
+
const startY = aElbow ? import_core.inputY[a] : ptY[a];
|
|
107
|
+
const startRadius = rads[a];
|
|
108
|
+
while (len - s > 2) {
|
|
109
|
+
const i = a + 1 + s;
|
|
110
|
+
const dx = startX - ptX[i];
|
|
111
|
+
const dy = startY - ptY[i];
|
|
112
|
+
if (dx * dx + dy * dy < ((startRadius + rads[i]) / 2 * 0.5) ** 2) {
|
|
113
|
+
hasAnchor = true;
|
|
114
|
+
anchorX = ptX[i];
|
|
115
|
+
anchorY = ptY[i];
|
|
116
|
+
s++;
|
|
91
117
|
} else {
|
|
92
118
|
break;
|
|
93
119
|
}
|
|
94
120
|
}
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
const endX = bElbow ? import_core.inputX[b] : ptX[b];
|
|
122
|
+
const endY = bElbow ? import_core.inputY[b] : ptY[b];
|
|
123
|
+
const endRadius = rads[b];
|
|
124
|
+
while (len - s - e > 2) {
|
|
125
|
+
const i = bDup ? b - e : b - 1 - e;
|
|
126
|
+
const dx = endX - ptX[i];
|
|
127
|
+
const dy = endY - ptY[i];
|
|
128
|
+
if (dx * dx + dy * dy < ((endRadius + rads[i]) / 2 * 0.5) ** 2) {
|
|
129
|
+
e++;
|
|
101
130
|
} else {
|
|
102
131
|
break;
|
|
103
132
|
}
|
|
104
133
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
134
|
+
const innerStart = a + 1 + s;
|
|
135
|
+
const innerEnd = bDup ? b - e : b - 1 - e;
|
|
136
|
+
(0, import_core.loadSrcPartition)(a, aElbow, innerStart, innerEnd, b, bElbow, bDup && e === 0);
|
|
137
|
+
renderPartition(options, hasAnchor, anchorX, anchorY);
|
|
138
|
+
}
|
|
139
|
+
function writeCirclePath(cx, cy, r) {
|
|
140
|
+
const ncx = (0, import_fmt.toCenti)(cx);
|
|
141
|
+
const ncy = (0, import_fmt.toCenti)(cy);
|
|
142
|
+
const nr = (0, import_fmt.toCenti)(r);
|
|
143
|
+
(0, import_fmt.writeStr)("M ");
|
|
144
|
+
(0, import_fmt.writeC)(ncx);
|
|
145
|
+
(0, import_fmt.writeStr)(" ");
|
|
146
|
+
(0, import_fmt.writeC)(ncy);
|
|
147
|
+
(0, import_fmt.writeStr)(" m -");
|
|
148
|
+
(0, import_fmt.writeC)(nr);
|
|
149
|
+
(0, import_fmt.writeStr)(", 0 a ");
|
|
150
|
+
(0, import_fmt.writeC)(nr);
|
|
151
|
+
(0, import_fmt.writeStr)(",");
|
|
152
|
+
(0, import_fmt.writeC)(nr);
|
|
153
|
+
(0, import_fmt.writeStr)(" 0 1,1 ");
|
|
154
|
+
(0, import_fmt.writeC)(nr * 2);
|
|
155
|
+
(0, import_fmt.writeStr)(",0 a ");
|
|
156
|
+
(0, import_fmt.writeC)(nr);
|
|
157
|
+
(0, import_fmt.writeStr)(",");
|
|
158
|
+
(0, import_fmt.writeC)(nr);
|
|
159
|
+
(0, import_fmt.writeStr)(" 0 1,1 -");
|
|
160
|
+
(0, import_fmt.writeC)(nr * 2);
|
|
161
|
+
(0, import_fmt.writeStr)(",0");
|
|
119
162
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
163
|
+
function writeCapArc(nr, dx, dy) {
|
|
164
|
+
(0, import_fmt.writeStr)("a");
|
|
165
|
+
(0, import_fmt.writeC)(nr);
|
|
166
|
+
(0, import_fmt.writeStr)(",");
|
|
167
|
+
(0, import_fmt.writeC)(nr);
|
|
168
|
+
(0, import_fmt.writeStr)(" 0 0 1 ");
|
|
169
|
+
(0, import_fmt.writeCPair)(dx, dy);
|
|
122
170
|
}
|
|
123
|
-
function renderPartition(
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
|
|
171
|
+
function renderPartition(options, hasAnchor, anchorX, anchorY) {
|
|
172
|
+
const n = import_core.srcCount;
|
|
173
|
+
if (n === 0) return;
|
|
174
|
+
if (n === 1) {
|
|
175
|
+
writeCirclePath(import_core.srcX[0], import_core.srcY[0], import_core.srcRadius[0]);
|
|
176
|
+
return;
|
|
127
177
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
178
|
+
(0, import_getStrokeOutlinePoints.buildTracks)(options, hasAnchor, anchorX, anchorY);
|
|
179
|
+
const lxs = import_getStrokeOutlinePoints.trackLeftX;
|
|
180
|
+
const lys = import_getStrokeOutlinePoints.trackLeftY;
|
|
181
|
+
const rxs = import_getStrokeOutlinePoints.trackRightX;
|
|
182
|
+
const rys = import_getStrokeOutlinePoints.trackRightY;
|
|
183
|
+
let cx = (0, import_fmt.toCenti)(lxs[0]);
|
|
184
|
+
let cy = (0, import_fmt.toCenti)(lys[0]);
|
|
185
|
+
(0, import_fmt.writeStr)("M");
|
|
186
|
+
(0, import_fmt.writeCPair)(cx, cy);
|
|
187
|
+
(0, import_fmt.writeStr)("t");
|
|
188
|
+
let prevX = lxs[0];
|
|
189
|
+
let prevY = lys[0];
|
|
190
|
+
for (let i = 1; i < import_getStrokeOutlinePoints.trackLeftCount; i++) {
|
|
191
|
+
const ptX = lxs[i];
|
|
192
|
+
const ptY = lys[i];
|
|
193
|
+
const mx = Math.round((prevX + ptX) * 50);
|
|
194
|
+
const my = Math.round((prevY + ptY) * 50);
|
|
195
|
+
(0, import_fmt.writeCPair)(mx - cx, my - cy);
|
|
196
|
+
cx = mx;
|
|
197
|
+
cy = my;
|
|
198
|
+
prevX = ptX;
|
|
199
|
+
prevY = ptY;
|
|
133
200
|
}
|
|
134
201
|
{
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
202
|
+
const pointX2 = import_core.srcX[n - 1];
|
|
203
|
+
const pointY2 = import_core.srcY[n - 1];
|
|
204
|
+
const radius = import_core.srcRadius[n - 1];
|
|
205
|
+
const vdx = import_core.srcX[n - 2] - pointX2;
|
|
206
|
+
const vdy = import_core.srcY[n - 2] - pointY2;
|
|
207
|
+
const vlen = Math.sqrt(vdx * vdx + vdy * vdy);
|
|
208
|
+
const dx = -vdy / vlen * radius;
|
|
209
|
+
const dy = vdx / vlen * radius;
|
|
210
|
+
const asx = (0, import_fmt.toCenti)(pointX2 + dx);
|
|
211
|
+
const asy = (0, import_fmt.toCenti)(pointY2 + dy);
|
|
212
|
+
const aex = (0, import_fmt.toCenti)(pointX2 - dx);
|
|
213
|
+
const aey = (0, import_fmt.toCenti)(pointY2 - dy);
|
|
214
|
+
(0, import_fmt.writeCPair)(asx - cx, asy - cy);
|
|
215
|
+
writeCapArc((0, import_fmt.toCenti)(radius), aex - asx, aey - asy);
|
|
216
|
+
(0, import_fmt.writeStr)("t");
|
|
217
|
+
cx = aex;
|
|
218
|
+
cy = aey;
|
|
143
219
|
}
|
|
144
|
-
|
|
145
|
-
|
|
220
|
+
prevX = rxs[import_getStrokeOutlinePoints.trackRightCount - 1];
|
|
221
|
+
prevY = rys[import_getStrokeOutlinePoints.trackRightCount - 1];
|
|
222
|
+
for (let i = import_getStrokeOutlinePoints.trackRightCount - 2; i >= 0; i--) {
|
|
223
|
+
const ptX = rxs[i];
|
|
224
|
+
const ptY = rys[i];
|
|
225
|
+
const mx = Math.round((prevX + ptX) * 50);
|
|
226
|
+
const my = Math.round((prevY + ptY) * 50);
|
|
227
|
+
(0, import_fmt.writeCPair)(mx - cx, my - cy);
|
|
228
|
+
cx = mx;
|
|
229
|
+
cy = my;
|
|
230
|
+
prevX = ptX;
|
|
231
|
+
prevY = ptY;
|
|
146
232
|
}
|
|
147
233
|
{
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
234
|
+
const pointX2 = import_core.srcX[0];
|
|
235
|
+
const pointY2 = import_core.srcY[0];
|
|
236
|
+
const radius = import_core.srcRadius[0];
|
|
237
|
+
const vdx = pointX2 - import_core.srcX[1];
|
|
238
|
+
const vdy = pointY2 - import_core.srcY[1];
|
|
239
|
+
const vlen = Math.sqrt(vdx * vdx + vdy * vdy);
|
|
240
|
+
const dx = vdy / vlen * radius;
|
|
241
|
+
const dy = -vdx / vlen * radius;
|
|
242
|
+
const asx = (0, import_fmt.toCenti)(pointX2 + dx);
|
|
243
|
+
const asy = (0, import_fmt.toCenti)(pointY2 + dy);
|
|
244
|
+
const aex = (0, import_fmt.toCenti)(pointX2 - dx);
|
|
245
|
+
const aey = (0, import_fmt.toCenti)(pointY2 - dy);
|
|
246
|
+
(0, import_fmt.writeCPair)(asx - cx, asy - cy);
|
|
247
|
+
writeCapArc((0, import_fmt.toCenti)(radius), aex - asx, aey - asy);
|
|
248
|
+
(0, import_fmt.writeStr)("Z");
|
|
156
249
|
}
|
|
157
|
-
return svg;
|
|
158
250
|
}
|
|
159
251
|
//# sourceMappingURL=svgInk.js.map
|