tldraw 5.4.0-next.ebc95cf01337 → 5.4.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 +2826 -3226
- package/RELEASE_NOTES.md +190 -2
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/defaultExternalContentHandlers.js +30 -14
- package/dist-cjs/lib/defaultExternalContentHandlers.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/curved-arrow.js +2 -2
- package/dist-cjs/lib/shapes/arrow/curved-arrow.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js +2 -2
- package/dist-cjs/lib/shapes/arrow/elbow/getElbowArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/getArrowInfo.js +1 -1
- package/dist-cjs/lib/shapes/arrow/getArrowInfo.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/straight-arrow.js +2 -2
- package/dist-cjs/lib/shapes/arrow/straight-arrow.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js +2 -3
- package/dist-cjs/lib/shapes/arrow/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js +7 -5
- package/dist-cjs/lib/shapes/arrow/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js +8 -6
- package/dist-cjs/lib/shapes/draw/toolStates/Drawing.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/getGeoShapePath.js +3 -1
- package/dist-cjs/lib/shapes/geo/getGeoShapePath.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js +2 -3
- package/dist-cjs/lib/shapes/geo/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js +1 -1
- package/dist-cjs/lib/shapes/geo/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js +2 -6
- package/dist-cjs/lib/shapes/line/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js +4 -4
- package/dist-cjs/lib/shapes/note/NoteShapeUtil.js.map +2 -2
- package/dist-cjs/lib/shapes/note/noteHelpers.js +6 -5
- package/dist-cjs/lib/shapes/note/noteHelpers.js.map +2 -2
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js +1 -1
- package/dist-cjs/lib/shapes/note/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/shared/crop.js +1 -1
- package/dist-cjs/lib/shapes/shared/crop.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js +1 -1
- package/dist-cjs/lib/shapes/text/toolStates/Idle.js.map +2 -2
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js +1 -0
- package/dist-cjs/lib/shapes/text/toolStates/Pointing.js.map +2 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js +3 -2
- package/dist-cjs/lib/shapes/video/VideoShapeUtil.js.map +2 -2
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js +2 -0
- package/dist-cjs/lib/tools/EraserTool/childStates/Erasing.js.map +2 -2
- package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js +6 -0
- package/dist-cjs/lib/tools/HandTool/childStates/OneFingerZooming.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/SelectTool.js +3 -0
- package/dist-cjs/lib/tools/SelectTool/SelectTool.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Brushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/Crop/Crop.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js +1 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/DraggingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js +6 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/Idle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingArrowLabel.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js +3 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingCanvas.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js +1 -0
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingHandle.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js +1 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/PointingShape.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js +22 -30
- package/dist-cjs/lib/tools/SelectTool/childStates/Resizing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js +1 -3
- package/dist-cjs/lib/tools/SelectTool/childStates/ScribbleBrushing.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js +4 -1
- package/dist-cjs/lib/tools/SelectTool/childStates/Translating.js.map +2 -2
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js +10 -0
- package/dist-cjs/lib/tools/SelectTool/selectHelpers.js.map +2 -2
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js +1 -8
- package/dist-cjs/lib/ui/components/ActionsMenu/DefaultActionsMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js +6 -1
- package/dist-cjs/lib/ui/components/ContextMenu/DefaultContextMenu.js.map +2 -2
- package/dist-cjs/lib/ui/components/Dialogs.js +8 -0
- package/dist-cjs/lib/ui/components/Dialogs.js.map +2 -2
- package/dist-cjs/lib/ui/components/EditLinkDialog.js +5 -5
- package/dist-cjs/lib/ui/components/EditLinkDialog.js.map +2 -2
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js +4 -20
- package/dist-cjs/lib/ui/components/Minimap/DefaultMinimap.js.map +2 -2
- package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js +2 -0
- package/dist-cjs/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js +1 -0
- package/dist-cjs/lib/ui/components/Toolbar/AltTextEditor.js.map +2 -2
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js +10 -8
- package/dist-cjs/lib/ui/components/Toolbar/DefaultImageToolbarContent.js.map +2 -2
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js +20 -1
- package/dist-cjs/lib/ui/components/primitives/TldrawUiSlider.js.map +2 -2
- package/dist-cjs/lib/ui/context/actions.js +8 -7
- package/dist-cjs/lib/ui/context/actions.js.map +2 -2
- package/dist-cjs/lib/ui/hooks/useCommentingEnabled.js +1 -1
- package/dist-cjs/lib/ui/hooks/useCommentingEnabled.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-esm/index.mjs +1 -1
- package/dist-esm/lib/defaultExternalContentHandlers.mjs +30 -14
- package/dist-esm/lib/defaultExternalContentHandlers.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/curved-arrow.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/curved-arrow.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/elbow/getElbowArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/getArrowInfo.mjs +1 -1
- package/dist-esm/lib/shapes/arrow/getArrowInfo.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/straight-arrow.mjs +2 -2
- package/dist-esm/lib/shapes/arrow/straight-arrow.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs +3 -4
- package/dist-esm/lib/shapes/arrow/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs +7 -5
- package/dist-esm/lib/shapes/arrow/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs +8 -6
- package/dist-esm/lib/shapes/draw/toolStates/Drawing.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/getGeoShapePath.mjs +3 -1
- package/dist-esm/lib/shapes/geo/getGeoShapePath.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs +3 -4
- package/dist-esm/lib/shapes/geo/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs +1 -1
- package/dist-esm/lib/shapes/geo/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs +2 -7
- package/dist-esm/lib/shapes/line/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs +4 -4
- package/dist-esm/lib/shapes/note/NoteShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/noteHelpers.mjs +6 -5
- package/dist-esm/lib/shapes/note/noteHelpers.mjs.map +2 -2
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs +1 -1
- package/dist-esm/lib/shapes/note/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/shared/crop.mjs +1 -1
- package/dist-esm/lib/shapes/shared/crop.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs +1 -0
- package/dist-esm/lib/shapes/text/toolStates/Pointing.mjs.map +2 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs +3 -2
- package/dist-esm/lib/shapes/video/VideoShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs +2 -0
- package/dist-esm/lib/tools/EraserTool/childStates/Erasing.mjs.map +2 -2
- package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs +6 -0
- package/dist-esm/lib/tools/HandTool/childStates/OneFingerZooming.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/SelectTool.mjs +3 -0
- package/dist-esm/lib/tools/SelectTool/SelectTool.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs +1 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Brushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs +1 -0
- package/dist-esm/lib/tools/SelectTool/childStates/Crop/Crop.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs +1 -3
- package/dist-esm/lib/tools/SelectTool/childStates/DraggingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs +6 -3
- package/dist-esm/lib/tools/SelectTool/childStates/Idle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingArrowLabel.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs +3 -0
- package/dist-esm/lib/tools/SelectTool/childStates/PointingCanvas.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs +5 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingHandle.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs +1 -1
- package/dist-esm/lib/tools/SelectTool/childStates/PointingShape.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs +22 -31
- package/dist-esm/lib/tools/SelectTool/childStates/Resizing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs +1 -3
- package/dist-esm/lib/tools/SelectTool/childStates/ScribbleBrushing.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs +4 -1
- package/dist-esm/lib/tools/SelectTool/childStates/Translating.mjs.map +2 -2
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs +10 -0
- package/dist-esm/lib/tools/SelectTool/selectHelpers.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs +1 -8
- package/dist-esm/lib/ui/components/ActionsMenu/DefaultActionsMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs +7 -2
- package/dist-esm/lib/ui/components/ContextMenu/DefaultContextMenu.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Dialogs.mjs +9 -1
- package/dist-esm/lib/ui/components/Dialogs.mjs.map +2 -2
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs +5 -5
- package/dist-esm/lib/ui/components/EditLinkDialog.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs +5 -22
- package/dist-esm/lib/ui/components/Minimap/DefaultMinimap.mjs.map +2 -2
- package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs +2 -0
- package/dist-esm/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs +1 -0
- package/dist-esm/lib/ui/components/Toolbar/AltTextEditor.mjs.map +2 -2
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs +10 -8
- package/dist-esm/lib/ui/components/Toolbar/DefaultImageToolbarContent.mjs.map +2 -2
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs +20 -1
- package/dist-esm/lib/ui/components/primitives/TldrawUiSlider.mjs.map +2 -2
- package/dist-esm/lib/ui/context/actions.mjs +8 -7
- package/dist-esm/lib/ui/context/actions.mjs.map +2 -2
- package/dist-esm/lib/ui/hooks/useCommentingEnabled.mjs +2 -2
- package/dist-esm/lib/ui/hooks/useCommentingEnabled.mjs.map +2 -2
- package/dist-esm/lib/ui/version.mjs +3 -3
- package/dist-esm/lib/ui/version.mjs.map +1 -1
- package/package.json +12 -6
- package/src/lib/defaultExternalContentHandlers.test.ts +43 -0
- package/src/lib/defaultExternalContentHandlers.ts +38 -16
- package/src/lib/shapes/arrow/ArrowShapeTool.test.ts +17 -0
- package/src/lib/shapes/arrow/curved-arrow.ts +2 -2
- package/src/lib/shapes/arrow/elbow/getElbowArrowInfo.tsx +5 -3
- package/src/lib/shapes/arrow/getArrowInfo.ts +2 -1
- package/src/lib/shapes/arrow/straight-arrow.ts +2 -2
- package/src/lib/shapes/arrow/toolStates/Idle.tsx +3 -4
- package/src/lib/shapes/arrow/toolStates/Pointing.tsx +10 -6
- package/src/lib/shapes/draw/DrawShapeTool.test.ts +19 -0
- package/src/lib/shapes/draw/toolStates/Drawing.ts +12 -6
- package/src/lib/shapes/frame/FrameShapeTool.test.ts +17 -0
- package/src/lib/shapes/geo/GeoShapeTool.test.ts +28 -0
- package/src/lib/shapes/geo/getGeoShapePath.ts +3 -1
- package/src/lib/shapes/geo/toolStates/Idle.ts +3 -4
- package/src/lib/shapes/geo/toolStates/Pointing.ts +2 -1
- package/src/lib/shapes/line/LineShapeTool.test.ts +30 -1
- package/src/lib/shapes/line/toolStates/Pointing.ts +6 -7
- package/src/lib/shapes/note/NoteShapeTool.test.ts +45 -0
- package/src/lib/shapes/note/NoteShapeUtil.tsx +7 -4
- package/src/lib/shapes/note/noteHelpers.ts +18 -8
- package/src/lib/shapes/note/toolStates/Pointing.ts +2 -1
- package/src/lib/shapes/shared/crop.ts +7 -1
- package/src/lib/shapes/text/TextShapeTool.test.ts +33 -0
- package/src/lib/shapes/text/toolStates/Idle.ts +2 -2
- package/src/lib/shapes/text/toolStates/Pointing.ts +3 -0
- package/src/lib/shapes/video/VideoShapeUtil.tsx +4 -2
- package/src/lib/tools/EraserTool/childStates/Erasing.ts +5 -0
- package/src/lib/tools/HandTool/childStates/OneFingerZooming.ts +10 -0
- package/src/lib/tools/SelectTool/SelectTool.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/Brushing.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/Crop/Crop.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/DraggingHandle.tsx +3 -4
- package/src/lib/tools/SelectTool/childStates/Idle.ts +10 -3
- package/src/lib/tools/SelectTool/childStates/PointingArrowLabel.ts +1 -1
- package/src/lib/tools/SelectTool/childStates/PointingCanvas.ts +4 -0
- package/src/lib/tools/SelectTool/childStates/PointingHandle.ts +6 -1
- package/src/lib/tools/SelectTool/childStates/PointingShape.ts +4 -1
- package/src/lib/tools/SelectTool/childStates/Resizing.ts +30 -33
- package/src/lib/tools/SelectTool/childStates/ScribbleBrushing.ts +3 -3
- package/src/lib/tools/SelectTool/childStates/Translating.ts +6 -0
- package/src/lib/tools/SelectTool/selectHelpers.ts +21 -0
- package/src/lib/ui/components/ActionsMenu/DefaultActionsMenu.tsx +3 -9
- package/src/lib/ui/components/ContextMenu/DefaultContextMenu.tsx +8 -2
- package/src/lib/ui/components/Dialogs.tsx +17 -1
- package/src/lib/ui/components/EditLinkDialog.tsx +8 -7
- package/src/lib/ui/components/Minimap/DefaultMinimap.tsx +5 -23
- package/src/lib/ui/components/StylePanel/StylePanelDoubleDropdownPicker.tsx +2 -0
- package/src/lib/ui/components/Toolbar/AltTextEditor.tsx +1 -0
- package/src/lib/ui/components/Toolbar/DefaultImageToolbarContent.tsx +13 -8
- package/src/lib/ui/components/primitives/TldrawUiSlider.test.tsx +92 -0
- package/src/lib/ui/components/primitives/TldrawUiSlider.tsx +25 -1
- package/src/lib/ui/context/actions.tsx +25 -7
- package/src/lib/ui/hooks/useCommentingEnabled.ts +5 -3
- package/src/lib/ui/version.ts +3 -3
- package/src/test/ClickManager.test.ts +18 -0
- package/src/test/Editor.test.tsx +3 -0
- package/src/test/EraserTool.test.ts +18 -2
- package/src/test/HandTool.test.ts +21 -0
- package/src/test/LaserTool.test.ts +46 -0
- package/src/test/ScribbleManager.test.ts +19 -0
- package/src/test/SelectTool.test.ts +110 -0
- package/src/test/TldrawEditor.test.tsx +18 -0
- package/src/test/VideoShapeUtil.test.tsx +126 -0
- package/src/test/actions-menu-readonly.test.tsx +37 -0
- package/src/test/commands/__snapshots__/packShapes.test.ts.snap +6 -6
- package/src/test/commands/lockShapes.test.ts +11 -0
- package/src/test/commands/packShapes.test.ts +20 -0
- package/src/test/commands/putContent.test.ts +35 -1
- package/src/test/commands/setCamera.test.ts +69 -0
- package/src/test/commands/stackShapes.test.ts +12 -0
- package/src/test/commands/updateViewportPageBounds.test.ts +8 -0
- package/src/test/cropping.test.ts +162 -0
- package/src/test/customSnapping.test.tsx +32 -0
- package/src/test/defaultHandleExternalFileContent.test.ts +86 -0
- package/src/test/drawing.test.ts +60 -1
- package/src/test/duplicate.test.ts +22 -0
- package/src/test/frames.test.ts +51 -0
- package/src/test/getShapeAtPoint.test.ts +44 -1
- package/src/test/handleDeepLink.test.tsx +15 -0
- package/src/test/minimap-wheel.test.tsx +48 -0
- package/src/test/resizing.test.ts +46 -0
- package/src/test/selection-omnibus.test.ts +50 -0
- package/src/test/spacebarPanning.test.ts +58 -0
- package/src/test/translating.test.ts +42 -0
- package/src/test/ui/AltTextEditor.test.tsx +51 -0
- package/src/test/ui/ContextMenu.test.tsx +61 -2
- package/src/test/ui/EditLinkDialog.test.tsx +77 -0
- package/src/test/ui/ImageToolbar.test.tsx +58 -0
- package/src/test/ui/StylePanel.test.tsx +33 -2
- package/src/test/ui/keyboardShortcuts.test.tsx +27 -0
- package/src/test/ui/presenceActivity.test.tsx +44 -0
- package/src/test/ui/unlockAll.test.tsx +55 -0
- package/src/test/ui-outside-editor.test.tsx +74 -0
- package/src/test/viewport-following.test.ts +29 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/shapes/arrow/toolStates/Pointing.tsx"],
|
|
4
|
-
"sourcesContent": ["import { StateNode, TLArrowShape, createShapeId, maybeSnapToGrid } from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../ArrowShapeUtil'\nimport { clearArrowTargetState, updateArrowTargetState } from '../arrowTargetState'\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\tshape?: TLArrowShape\n\n\tisPrecise = false\n\tisPreciseTimerId: number | null = null\n\n\tmarkId = ''\n\n\toverride onEnter(info: { isPrecise?: boolean }) {\n\t\tthis.markId = ''\n\t\tthis.isPrecise = !!info.isPrecise\n\n\t\tconst targetState = updateArrowTargetState({\n\t\t\teditor: this.editor,\n\t\t\tpointInPageSpace: this.editor.inputs.getCurrentPagePoint(),\n\t\t\tarrow: undefined,\n\t\t\tisPrecise: this.isPrecise,\n\t\t\tcurrentBinding: undefined,\n\t\t\toppositeBinding: undefined,\n\t\t})\n\n\t\tif (!targetState) {\n\t\t\tthis.createArrowShape()\n\t\t\tif (!this.shape) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.startPreciseTimeout()\n\t}\n\n\toverride onExit() {\n\t\tthis.shape = undefined\n\t\tclearArrowTargetState(this.editor)\n\t\tthis.clearPreciseTimeout()\n\t}\n\n\toverride onPointerMove() {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tif (!this.shape) {\n\t\t\t\tthis.createArrowShape()\n\t\t\t}\n\n\t\t\tif (!this.shape) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.updateArrowShapeEndHandle()\n\n\t\t\tthis.editor.setCurrentTool('select.dragging_handle', {\n\t\t\t\tshape
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAwE;AAExE,8BAA8D;AAEvD,MAAM,iBAAiB,wBAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAErB;AAAA,EAEA,YAAY;AAAA,EACZ,mBAAkC;AAAA,EAElC,SAAS;AAAA,EAEA,QAAQ,MAA+B;AAC/C,SAAK,SAAS;AACd,SAAK,YAAY,CAAC,CAAC,KAAK;AAExB,UAAM,kBAAc,gDAAuB;AAAA,MAC1C,QAAQ,KAAK;AAAA,MACb,kBAAkB,KAAK,OAAO,OAAO,oBAAoB;AAAA,MACzD,OAAO;AAAA,MACP,WAAW,KAAK;AAAA,MAChB,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IAClB,CAAC;AAED,QAAI,CAAC,aAAa;AACjB,WAAK,iBAAiB;AACtB,UAAI,CAAC,KAAK,OAAO;AAChB,aAAK,OAAO;AACZ;AAAA,MACD;AAAA,IACD;AAEA,SAAK,oBAAoB;AAAA,EAC1B;AAAA,EAES,SAAS;
|
|
4
|
+
"sourcesContent": ["import { StateNode, TLArrowShape, createShapeId, maybeSnapToGrid } from '@tldraw/editor'\nimport { ArrowShapeUtil } from '../ArrowShapeUtil'\nimport { clearArrowTargetState, updateArrowTargetState } from '../arrowTargetState'\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\tshape?: TLArrowShape\n\n\tisPrecise = false\n\tisPreciseTimerId: number | null = null\n\n\tmarkId = ''\n\n\toverride onEnter(info: { isPrecise?: boolean }) {\n\t\tthis.markId = ''\n\t\tthis.isPrecise = !!info.isPrecise\n\n\t\tconst targetState = updateArrowTargetState({\n\t\t\teditor: this.editor,\n\t\t\tpointInPageSpace: this.editor.inputs.getCurrentPagePoint(),\n\t\t\tarrow: undefined,\n\t\t\tisPrecise: this.isPrecise,\n\t\t\tcurrentBinding: undefined,\n\t\t\toppositeBinding: undefined,\n\t\t})\n\n\t\tif (!targetState) {\n\t\t\tthis.createArrowShape()\n\t\t\tif (!this.shape) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tthis.startPreciseTimeout()\n\t}\n\n\toverride onExit() {\n\t\t// The press already created the arrow, so leaving without a drag (pointer up, cancel, or a\n\t\t// tool switch) would otherwise strand a zero-length stub on the canvas\n\t\tif (this.shape) {\n\t\t\tthis.editor.bailToMark(this.markId)\n\t\t\tthis.shape = undefined\n\t\t}\n\t\tclearArrowTargetState(this.editor)\n\t\tthis.clearPreciseTimeout()\n\t}\n\n\toverride onPointerMove() {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tif (!this.shape) {\n\t\t\t\tthis.createArrowShape()\n\t\t\t}\n\n\t\t\tif (!this.shape) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.updateArrowShapeEndHandle()\n\n\t\t\t// Hand the arrow off before exiting so onExit does not bail it away\n\t\t\tconst shape = this.shape\n\t\t\tthis.shape = undefined\n\t\t\tthis.editor.setCurrentTool('select.dragging_handle', {\n\t\t\t\tshape,\n\t\t\t\thandle: { id: 'end', type: 'vertex', index: 'a3', x: 0, y: 0 },\n\t\t\t\tisCreating: true,\n\t\t\t\tcreatingMarkId: this.markId || undefined,\n\t\t\t\tonInteractionEnd: 'arrow',\n\t\t\t})\n\t\t}\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.cancel()\n\t}\n\n\toverride onLongPress() {\n\t\t// On a touch (coarse pointer) long-press, cancel the pending shape so it leaves nothing behind.\n\t\tif (this.editor.getInstanceState().isCoarsePointer) this.cancel()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tcancel() {\n\t\tthis.parent.transition('idle')\n\t}\n\n\tcreateArrowShape() {\n\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\n\t\tconst id = createShapeId()\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint(`creating_arrow:${id}`)\n\t\tconst newPoint = maybeSnapToGrid(originPagePoint, this.editor)\n\t\tthis.editor.createShape({\n\t\t\tid,\n\t\t\ttype: 'arrow',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\tscale: this.editor.getResizeScaleFactor(),\n\t\t\t},\n\t\t})\n\n\t\tconst shape = this.editor.getShape<TLArrowShape>(id)\n\t\tif (!shape) return\n\n\t\tconst handles = this.editor.getShapeHandles(shape)\n\t\tif (!handles) throw Error(`expected handles for arrow`)\n\n\t\tconst util = this.editor.getShapeUtil<TLArrowShape>('arrow')\n\t\tconst initial = this.shape\n\t\tconst startHandle = handles.find((h) => h.id === 'start')!\n\t\tconst change = util.onHandleDrag?.(shape, {\n\t\t\thandle: { ...startHandle, x: 0, y: 0 },\n\t\t\tisPrecise: true,\n\t\t\tisCreatingShape: true,\n\t\t\tinitial: initial,\n\t\t})\n\n\t\tif (change) {\n\t\t\tthis.editor.updateShapes([change])\n\t\t}\n\n\t\t// Cache the current shape after those changes\n\t\tthis.shape = this.editor.getShape(id)\n\t\tthis.editor.select(id)\n\t}\n\n\tupdateArrowShapeEndHandle() {\n\t\tconst shape = this.shape\n\t\tif (!shape) throw Error(`expected shape`)\n\n\t\tconst handles = this.editor.getShapeHandles(shape)\n\t\tif (!handles) throw Error(`expected handles for arrow`)\n\n\t\t// start update\n\t\t{\n\t\t\tconst util = this.editor.getShapeUtil<TLArrowShape>('arrow')\n\t\t\tconst initial = this.shape\n\t\t\tconst startHandle = handles.find((h) => h.id === 'start')!\n\t\t\tconst change = util.onHandleDrag?.(shape, {\n\t\t\t\thandle: { ...startHandle, x: 0, y: 0 },\n\t\t\t\tisPrecise: this.isPrecise,\n\t\t\t\tisCreatingShape: true,\n\t\t\t\tinitial: initial,\n\t\t\t})\n\n\t\t\tif (change) {\n\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t}\n\t\t}\n\n\t\t// end update\n\t\t{\n\t\t\tconst util = this.editor.getShapeUtil<TLArrowShape>('arrow')\n\t\t\tconst initial = this.shape\n\t\t\tconst point = this.editor.getPointInShapeSpace(\n\t\t\t\tshape,\n\t\t\t\tthis.editor.inputs.getCurrentPagePoint()\n\t\t\t)\n\t\t\tconst endHandle = handles.find((h) => h.id === 'end')!\n\t\t\tconst change = util.onHandleDrag?.(this.editor.getShape(shape)!, {\n\t\t\t\thandle: { ...endHandle, x: point.x, y: point.y },\n\t\t\t\tisPrecise: this.isPrecise,\n\t\t\t\tisCreatingShape: true,\n\t\t\t\tinitial: initial,\n\t\t\t})\n\n\t\t\tif (change) {\n\t\t\t\tthis.editor.updateShapes([change])\n\t\t\t}\n\t\t}\n\n\t\t// Cache the current shape after those changes\n\t\tthis.shape = this.editor.getShape(shape.id)\n\t}\n\n\tprivate startPreciseTimeout() {\n\t\tconst arrowUtil = this.editor.getShapeUtil<ArrowShapeUtil>('arrow')\n\n\t\tthis.isPreciseTimerId = this.editor.timers.setTimeout(() => {\n\t\t\tif (!this.getIsActive()) return\n\t\t\tthis.isPrecise = true\n\t\t}, arrowUtil.options.pointingPreciseTimeout)\n\t}\n\n\tprivate clearPreciseTimeout() {\n\t\tif (this.isPreciseTimerId !== null) {\n\t\t\tclearTimeout(this.isPreciseTimerId)\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAwE;AAExE,8BAA8D;AAEvD,MAAM,iBAAiB,wBAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAErB;AAAA,EAEA,YAAY;AAAA,EACZ,mBAAkC;AAAA,EAElC,SAAS;AAAA,EAEA,QAAQ,MAA+B;AAC/C,SAAK,SAAS;AACd,SAAK,YAAY,CAAC,CAAC,KAAK;AAExB,UAAM,kBAAc,gDAAuB;AAAA,MAC1C,QAAQ,KAAK;AAAA,MACb,kBAAkB,KAAK,OAAO,OAAO,oBAAoB;AAAA,MACzD,OAAO;AAAA,MACP,WAAW,KAAK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
|
"names": []
|
|
7
7
|
}
|
|
@@ -159,7 +159,7 @@ class Drawing extends import_editor.StateNode {
|
|
|
159
159
|
this.lastRecordedPoint = originPagePoint.clone();
|
|
160
160
|
if (this.initialShape) {
|
|
161
161
|
const shape2 = this.editor.getShape(this.initialShape.id);
|
|
162
|
-
if (shape2 && this.segmentMode === "straight") {
|
|
162
|
+
if (shape2 && this.segmentMode === "straight" && this.editor.isShapeInPage(shape2)) {
|
|
163
163
|
this.didJustShiftClickToExtendPreviousShapeLine = true;
|
|
164
164
|
const prevSegment = (0, import_editor.last)(shape2.props.segments);
|
|
165
165
|
if (!prevSegment) throw Error("Expected a previous segment!");
|
|
@@ -244,7 +244,8 @@ class Drawing extends import_editor.StateNode {
|
|
|
244
244
|
if (pagePointWhereNextSegmentChanged === null) {
|
|
245
245
|
throw Error("We should have a point where the segment changed");
|
|
246
246
|
}
|
|
247
|
-
const
|
|
247
|
+
const zoom = this.editor.getZoomLevel();
|
|
248
|
+
const hasMovedFarEnough = import_editor.Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) * zoom * zoom > this.editor.options.dragDistanceSquared;
|
|
248
249
|
if (hasMovedFarEnough) {
|
|
249
250
|
this.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged.clone();
|
|
250
251
|
this.pagePointWhereNextSegmentChanged = null;
|
|
@@ -287,7 +288,8 @@ class Drawing extends import_editor.StateNode {
|
|
|
287
288
|
if (pagePointWhereNextSegmentChanged === null) {
|
|
288
289
|
throw Error("We should have a point where the segment changed");
|
|
289
290
|
}
|
|
290
|
-
const
|
|
291
|
+
const zoom = this.editor.getZoomLevel();
|
|
292
|
+
const hasMovedFarEnough = import_editor.Vec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) * zoom * zoom > this.editor.options.dragDistanceSquared;
|
|
291
293
|
if (hasMovedFarEnough) {
|
|
292
294
|
this.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged.clone();
|
|
293
295
|
this.pagePointWhereNextSegmentChanged = null;
|
|
@@ -487,7 +489,7 @@ class Drawing extends import_editor.StateNode {
|
|
|
487
489
|
const props = this.editor.getShape(id).props;
|
|
488
490
|
if (!this.editor.canCreateShapes([newShapeId])) return this.cancel();
|
|
489
491
|
const currentPagePoint2 = inputs.getCurrentPagePoint();
|
|
490
|
-
const initialPoint = new import_editor.Vec(0, 0, this.isPenOrStylus ? +(z * 1.25).toFixed() : 0.5);
|
|
492
|
+
const initialPoint = new import_editor.Vec(0, 0, this.isPenOrStylus ? +(z * 1.25).toFixed(2) : 0.5);
|
|
491
493
|
this.currentSegmentPoints = [initialPoint];
|
|
492
494
|
this.editor.createShape({
|
|
493
495
|
id: newShapeId,
|
|
@@ -518,10 +520,10 @@ class Drawing extends import_editor.StateNode {
|
|
|
518
520
|
for (let j = 0; j < segments.length; j++) {
|
|
519
521
|
const points = import_editor.b64Vecs.decodePoints(segments[j].path, segments[j].dim);
|
|
520
522
|
for (let i = 0; i < points.length - 1; i++) {
|
|
521
|
-
length += import_editor.Vec.
|
|
523
|
+
length += import_editor.Vec.Dist(points[i], points[i + 1]);
|
|
522
524
|
}
|
|
523
525
|
}
|
|
524
|
-
return
|
|
526
|
+
return length;
|
|
525
527
|
}
|
|
526
528
|
onPointerUp() {
|
|
527
529
|
this.complete();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/shapes/draw/toolStates/Drawing.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLDefaultSizeStyle,\n\tTLDrawShape,\n\tTLDrawShapeSegment,\n\tTLHighlightShape,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShapePartial,\n\tDIM_2D,\n\tVec,\n\tVecModel,\n\tb64Vecs,\n\tcreateShapeId,\n\tlast,\n\tsnapAngle,\n\tstructuredClone,\n\ttoFixed,\n\tuniqueId,\n} from '@tldraw/editor'\nimport { HighlightShapeUtil } from '../../highlight/HighlightShapeUtil'\nimport { STROKE_SIZES } from '../../shared/default-shape-constants'\nimport { getDisplayValues } from '../../shared/getDisplayValues'\nimport { DrawShapeUtil } from '../DrawShapeUtil'\n\ntype DrawableShape = TLDrawShape | TLHighlightShape\n\nexport class Drawing extends StateNode {\n\tstatic override id = 'drawing'\n\tstatic override trackPerformance = true\n\n\tinfo = {} as TLPointerEventInfo\n\n\tinitialShape?: DrawableShape\n\n\toverride shapeType = this.parent.id === 'highlight' ? ('highlight' as const) : ('draw' as const)\n\n\tutil = this.editor.getShapeUtil(this.shapeType) as DrawShapeUtil | HighlightShapeUtil\n\n\tisPen = false\n\tisPenOrStylus = false\n\n\t// Encoding dimension for segments created during this stroke. `2` drops the\n\t// constant pressure value (non-pressure devices), `undefined` keeps full 3D.\n\t// Decided once in startShape from the input device \u2014 see the note there.\n\tsegmentDim: 2 | undefined = undefined\n\n\tsegmentMode = 'free' as 'free' | 'straight' | 'starting_straight' | 'starting_free'\n\n\tdidJustShiftClickToExtendPreviousShapeLine = false\n\n\tpagePointWhereCurrentSegmentChanged = {} as Vec\n\n\tpagePointWhereNextSegmentChanged = null as Vec | null\n\n\tlastRecordedPoint = {} as Vec\n\tmergeNextPoint = false\n\tcurrentLineLength = 0\n\tzoomOnEnter = 1\n\n\t// Cache for current segment's points to avoid repeated b64 decode/encode\n\tcurrentSegmentPoints: Vec[] = []\n\n\tmarkId = null as null | string\n\n\toverride onEnter(info: TLPointerEventInfo) {\n\t\tthis.markId = null\n\t\tthis.info = info\n\t\tthis.lastRecordedPoint = this.editor.inputs.getCurrentPagePoint().clone()\n\t\tthis.zoomOnEnter = this.editor.getZoomLevel()\n\t\tthis.startShape()\n\t}\n\n\toverride onPointerMove() {\n\t\tconst { inputs } = this.editor\n\t\tconst isPen = inputs.getIsPen()\n\n\t\tif (this.isPen && !isPen) {\n\t\t\t// The user made a palm gesture before starting a pen gesture;\n\t\t\t// ideally we'd start the new shape here but we could also just bail\n\t\t\t// as the next interaction will work correctly\n\t\t\tif (this.markId) {\n\t\t\t\tthis.editor.bailToMark(this.markId)\n\t\t\t\tthis.startShape()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (this.isPenOrStylus) {\n\t\t\t// Don't update the shape if we haven't moved far enough from the last time we recorded a point\n\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\t\t\tif (Vec.Dist(currentPagePoint, this.lastRecordedPoint) >= 1 / this.zoomOnEnter) {\n\t\t\t\tthis.lastRecordedPoint = currentPagePoint.clone()\n\t\t\t\tthis.mergeNextPoint = false\n\t\t\t} else {\n\t\t\t\tthis.mergeNextPoint = true\n\t\t\t}\n\t\t} else {\n\t\t\tthis.mergeNextPoint = false\n\t\t}\n\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Shift') {\n\t\t\tswitch (this.segmentMode) {\n\t\t\t\tcase 'free': {\n\t\t\t\t\t// We've just entered straight mode, go to straight mode\n\t\t\t\t\tthis.segmentMode = 'starting_straight'\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'starting_free': {\n\t\t\t\t\tthis.segmentMode = 'starting_straight'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Shift') {\n\t\t\tthis.editor.snaps.clearIndicators()\n\n\t\t\tswitch (this.segmentMode) {\n\t\t\t\tcase 'straight': {\n\t\t\t\t\t// We've just exited straight mode, go back to free mode\n\t\t\t\t\tthis.segmentMode = 'starting_free'\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'starting_straight': {\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\t\t\t\t\tthis.segmentMode = 'free'\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.snaps.clearIndicators()\n\t\tthis.pagePointWhereCurrentSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t}\n\n\tcanClose() {\n\t\treturn this.shapeType !== 'highlight'\n\t}\n\n\tgetIsClosed(\n\t\tsegments: TLDrawShapeSegment[],\n\t\tsize: TLDefaultSizeStyle,\n\t\tscale: number,\n\t\tstrokeWidth?: number\n\t) {\n\t\tif (!this.canClose()) return false\n\n\t\tif (strokeWidth === undefined) {\n\t\t\tconst theme = this.editor.getCurrentTheme()\n\t\t\tstrokeWidth = theme.strokeWidth * STROKE_SIZES[size]\n\t\t}\n\t\tconst firstPoint = b64Vecs.decodeFirstPoint(segments[0].path, segments[0].dim)\n\t\tconst lastSegment = segments[segments.length - 1]\n\t\tconst lastPoint = b64Vecs.decodeLastPoint(lastSegment.path, lastSegment.dim)\n\n\t\tconst isDynamicResizingEnabled = this.editor.user.getIsDynamicResizeMode()\n\n\t\tconst threshold = isDynamicResizingEnabled // when dynamic resizing is enabled scale is 1/zoom, so the threshold should not scale directly with zoom at all\n\t\t\t? (strokeWidth + 2) * scale // +2 keeps tiny strokes from being too hard to close\n\t\t\t: // 6 is a base floor, 2 is stroke influence, 0.8 tempers width growth\n\t\t\t\t6 +\n\t\t\t\t2 * Math.sqrt(strokeWidth * 0.8) +\n\t\t\t\t// 100 is low-zoom boost, 0.18 is the zoom knee, 3 controls falloff steepness\n\t\t\t\t100 / (1 + Math.pow(this.zoomOnEnter / 0.18, 3))\n\n\t\treturn (\n\t\t\tfirstPoint !== null &&\n\t\t\tlastPoint !== null &&\n\t\t\tfirstPoint !== lastPoint &&\n\t\t\tthis.currentLineLength > strokeWidth * 4 * scale &&\n\t\t\tVec.DistMin(firstPoint, lastPoint, threshold)\n\t\t)\n\t}\n\n\t/**\n\t * Build a segment from points, encoding `path` at this stroke's `segmentDim` and\n\t * attaching `dim: 2` only when z was dropped. 3D segments omit `dim` so they\n\t * serialize byte-identically to pre-#8879 data.\n\t */\n\tprivate makeSegment(type: TLDrawShapeSegment['type'], points: VecModel[]): TLDrawShapeSegment {\n\t\tconst path = b64Vecs.encodePoints(points, this.segmentDim)\n\t\treturn this.segmentDim === DIM_2D ? { type, path, dim: DIM_2D } : { type, path }\n\t}\n\n\tprivate startShape() {\n\t\tconst inputs = this.editor.inputs\n\t\tconst originPagePoint = inputs.getOriginPagePoint()\n\t\tconst isPen = inputs.getIsPen()\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('draw start')\n\n\t\t// If the pressure is weird, then it's probably a stylus reporting as a mouse\n\t\t// We treat pen/stylus inputs differently in the drawing tool, so we need to\n\t\t// have our own value for this. The inputs.isPen is only if the input is a regular\n\t\t// pen, like an iPad pen, which needs to trigger \"pen mode\" in order to avoid\n\t\t// accidental palm touches. We don't have to worry about that with styluses though.\n\t\tconst { z = 0.5 } = this.info.point\n\n\t\tthis.isPen = isPen\n\t\t// if z === 0 on the initial point, treat this pen as a mouse because it's likely a broken pen\n\t\t// or a broken OS.\n\t\tthis.isPenOrStylus = (isPen && z !== 0) || (z > 0 && z < 0.5) || (z > 0.5 && z < 1)\n\n\t\t// Decide the encoding dimension once, here, from the input device \u2014 not by\n\t\t// scanning point data (content-driven). Device-driven keeps the encoded bytes\n\t\t// deterministic and is O(1) at stroke start. Non-pressure devices report a\n\t\t// constant z (0 / 0.5 / 1) that we normalize to 0.5 and omit entirely (2D);\n\t\t// pen/stylus input keeps the full 3D encoding.\n\t\tthis.segmentDim = this.isPenOrStylus ? undefined : DIM_2D\n\n\t\tconst pressure = this.isPenOrStylus ? z * 1.25 : 0.5\n\n\t\tthis.segmentMode = this.editor.inputs.getShiftKey() ? 'straight' : 'free'\n\n\t\tthis.didJustShiftClickToExtendPreviousShapeLine = false\n\n\t\tthis.lastRecordedPoint = originPagePoint.clone()\n\n\t\tif (this.initialShape) {\n\t\t\tconst shape = this.editor.getShape<DrawableShape>(this.initialShape.id)\n\n\t\t\tif (shape && this.segmentMode === 'straight') {\n\t\t\t\t// Connect dots\n\n\t\t\t\tthis.didJustShiftClickToExtendPreviousShapeLine = true\n\n\t\t\t\tconst prevSegment = last(shape.props.segments)\n\t\t\t\tif (!prevSegment) throw Error('Expected a previous segment!')\n\t\t\t\tconst prevPoint = b64Vecs.decodeLastPoint(prevSegment.path, prevSegment.dim)\n\t\t\t\tif (!prevPoint) throw Error('Expected a previous point!')\n\n\t\t\t\tconst { x, y } = this.editor.getPointInShapeSpace(shape, originPagePoint).toFixed()\n\n\t\t\t\tconst newSegment = this.makeSegment(this.segmentMode, [\n\t\t\t\t\t{ x: prevPoint.x, y: prevPoint.y, z: +pressure.toFixed(2) },\n\t\t\t\t\t{ x, y, z: +pressure.toFixed(2) },\n\t\t\t\t])\n\n\t\t\t\t// Convert prevPoint to page space\n\t\t\t\tconst prevPointPageSpace = Mat.applyToPoint(\n\t\t\t\t\tthis.editor.getShapePageTransform(shape.id)!,\n\t\t\t\t\tprevPoint\n\t\t\t\t)\n\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = prevPointPageSpace\n\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\t\t\t\tconst segments = [...shape.props.segments, newSegment]\n\n\t\t\t\tconst dvStrokeWidth = (getDisplayValues(this.util as any, shape) as { strokeWidth: number })\n\t\t\t\t\t.strokeWidth\n\t\t\t\tif (this.currentLineLength < dvStrokeWidth * 4) {\n\t\t\t\t\tthis.currentLineLength = this.getLineLength(segments)\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tshape.props.size,\n\t\t\t\t\t\tshape.props.scale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Create a new shape\n\n\t\tthis.pagePointWhereCurrentSegmentChanged = originPagePoint.clone()\n\t\tconst id = createShapeId()\n\n\t\t// Initialize the segment points cache\n\t\tconst initialPoint = new Vec(0, 0, +pressure.toFixed(2))\n\t\tthis.currentSegmentPoints = [initialPoint]\n\n\t\t// Allow this to trigger the max shapes reached alert\n\t\tthis.editor.createShape({\n\t\t\tid,\n\t\t\ttype: this.shapeType,\n\t\t\tx: originPagePoint.x,\n\t\t\ty: originPagePoint.y,\n\t\t\tprops: {\n\t\t\t\tisPen: this.isPenOrStylus,\n\t\t\t\tscale: this.editor.getResizeScaleFactor(),\n\t\t\t\tsegments: [this.makeSegment(this.segmentMode, [initialPoint])],\n\t\t\t},\n\t\t})\n\t\tconst shape = this.editor.getShape<DrawableShape>(id)\n\t\tif (!shape) {\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\t\tthis.currentLineLength = 0\n\t\tthis.initialShape = this.editor.getShape<DrawableShape>(id)\n\t}\n\n\tprivate updateDrawingShape() {\n\t\tconst { initialShape } = this\n\t\tconst { inputs } = this.editor\n\n\t\tif (!initialShape) return\n\n\t\tconst {\n\t\t\tid,\n\t\t\tprops: { size, scale },\n\t\t} = initialShape\n\n\t\tconst shape = this.editor.getShape<DrawableShape>(id)!\n\n\t\tif (!shape) return\n\n\t\tconst { segments } = shape.props\n\n\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\t\tconst { x, y, z } = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed()\n\t\tconst pressure = this.isPenOrStylus ? +(currentPagePoint.z! * 1.25).toFixed(2) : 0.5\n\t\tconst newPoint = { x, y, z: pressure }\n\n\t\tswitch (this.segmentMode) {\n\t\t\tcase 'starting_straight': {\n\t\t\t\tconst { pagePointWhereNextSegmentChanged } = this\n\n\t\t\t\tif (pagePointWhereNextSegmentChanged === null) {\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\t\t\t\t}\n\n\t\t\t\tconst hasMovedFarEnough =\n\t\t\t\t\tVec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) >\n\t\t\t\t\tthis.editor.options.dragDistanceSquared\n\n\t\t\t\t// Find the distance from where the pointer was when shift was released and\n\t\t\t\t// where it is now; if it's far enough away, then update the page point where\n\t\t\t\t// the current segment changed (to match the pagepoint where next segment changed)\n\t\t\t\t// and set the pagepoint where next segment changed to null.\n\t\t\t\tif (hasMovedFarEnough) {\n\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged!.clone()\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\n\t\t\t\t\t// Set the new mode\n\t\t\t\t\tthis.segmentMode = 'straight'\n\n\t\t\t\t\tconst prevSegment = last(segments)\n\t\t\t\t\tif (!prevSegment) throw Error('Expected a previous segment!')\n\n\t\t\t\t\tconst prevLastPoint = b64Vecs.decodeLastPoint(prevSegment.path, prevSegment.dim)\n\t\t\t\t\tif (!prevLastPoint) throw Error('Expected a previous last point!')\n\n\t\t\t\t\tlet newSegment: TLDrawShapeSegment\n\n\t\t\t\t\tconst newLastPoint = this.editor\n\t\t\t\t\t\t.getPointInShapeSpace(shape, this.pagePointWhereCurrentSegmentChanged)\n\t\t\t\t\t\t.toFixed()\n\t\t\t\t\t\t.toJson()\n\n\t\t\t\t\tif (prevSegment.type === 'straight') {\n\t\t\t\t\t\tthis.currentLineLength += Vec.Dist(prevLastPoint, newLastPoint)\n\n\t\t\t\t\t\tnewSegment = this.makeSegment('straight', [prevLastPoint, newLastPoint])\n\n\t\t\t\t\t\tconst transform = this.editor.getShapePageTransform(shape)!\n\n\t\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = Mat.applyToPoint(transform, prevLastPoint)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewSegment = this.makeSegment('straight', [newLastPoint, newPoint])\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tsegments: [...segments, newSegment],\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\t\tsegments,\n\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\tscale\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.editor.updateShapes([shapePartial])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'starting_free': {\n\t\t\t\tconst { pagePointWhereNextSegmentChanged } = this\n\n\t\t\t\tif (pagePointWhereNextSegmentChanged === null) {\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\t\t\t\t}\n\n\t\t\t\tconst hasMovedFarEnough =\n\t\t\t\t\tVec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) >\n\t\t\t\t\tthis.editor.options.dragDistanceSquared\n\n\t\t\t\t// Find the distance from where the pointer was when shift was released and\n\t\t\t\t// where it is now; if it's far enough away, then update the page point where\n\t\t\t\t// the current segment changed (to match the pagepoint where next segment changed)\n\t\t\t\t// and set the pagepoint where next segment changed to null.\n\t\t\t\tif (hasMovedFarEnough) {\n\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged!.clone()\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\n\t\t\t\t\t// Set the new mode\n\t\t\t\t\tthis.segmentMode = 'free'\n\n\t\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\t\tconst prevStraightSegment = newSegments[newSegments.length - 1]\n\t\t\t\t\tconst prevPoint = b64Vecs.decodeLastPoint(\n\t\t\t\t\t\tprevStraightSegment.path,\n\t\t\t\t\t\tprevStraightSegment.dim\n\t\t\t\t\t)\n\n\t\t\t\t\tif (!prevPoint) {\n\t\t\t\t\t\tthrow Error('No previous point!')\n\t\t\t\t\t}\n\n\t\t\t\t\t// Create the new free segment and interpolate the points between where the last line\n\t\t\t\t\t// ended and where the pointer is now\n\t\t\t\t\tconst interpolatedPoints = Vec.PointsBetween(prevPoint, newPoint, 6).map(\n\t\t\t\t\t\t(p) => new Vec(toFixed(p.x), toFixed(p.y), toFixed(p.z))\n\t\t\t\t\t)\n\t\t\t\t\t// Initialize cache for the new free segment\n\t\t\t\t\tthis.currentSegmentPoints = interpolatedPoints\n\n\t\t\t\t\tconst newFreeSegment = this.makeSegment('free', interpolatedPoints)\n\n\t\t\t\t\tconst finalSegments = [...newSegments, newFreeSegment]\n\n\t\t\t\t\tconst dvStrokeWidth = (\n\t\t\t\t\t\tgetDisplayValues(this.util as any, shape) as { strokeWidth: number }\n\t\t\t\t\t).strokeWidth\n\t\t\t\t\tif (this.currentLineLength < dvStrokeWidth * 4) {\n\t\t\t\t\t\tthis.currentLineLength = this.getLineLength(finalSegments)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tsegments: finalSegments,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\t\tfinalSegments,\n\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\tscale\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.editor.updateShapes([shapePartial])\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'straight': {\n\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\tconst newSegment = newSegments[newSegments.length - 1]\n\n\t\t\t\tconst { pagePointWhereCurrentSegmentChanged } = this\n\t\t\t\tconst inputs = this.editor.inputs\n\t\t\t\tconst ctrlKey = inputs.getCtrlKey()\n\t\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\n\t\t\t\tif (!pagePointWhereCurrentSegmentChanged)\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\n\t\t\t\tlet pagePoint: VecModel\n\t\t\t\tlet shouldSnapToAngle = false\n\n\t\t\t\tif (this.didJustShiftClickToExtendPreviousShapeLine) {\n\t\t\t\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\t\t\t\t// If we've just shift clicked to extend a line, only snap once we've started dragging\n\t\t\t\t\t\tshouldSnapToAngle = !ctrlKey\n\t\t\t\t\t\tthis.didJustShiftClickToExtendPreviousShapeLine = false\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// noop\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// If we're not shift clicking to extend a line, but we're holding shift, then we should snap\n\t\t\t\t\tshouldSnapToAngle = !ctrlKey // don't snap angle while snapping line\n\t\t\t\t}\n\n\t\t\t\tlet newPoint = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed().toJson()\n\t\t\t\tlet didSnap = false\n\t\t\t\tlet snapSegment: TLDrawShapeSegment | undefined = undefined\n\n\t\t\t\tconst shouldSnap = this.editor.user.getIsSnapMode() ? !ctrlKey : ctrlKey\n\n\t\t\t\tif (shouldSnap) {\n\t\t\t\t\tif (newSegments.length > 2) {\n\t\t\t\t\t\tlet nearestPoint: VecModel | undefined = undefined\n\t\t\t\t\t\tlet minDistance = 8 / this.zoomOnEnter\n\n\t\t\t\t\t\t// Don't try to snap to the last two segments\n\t\t\t\t\t\tfor (let i = 0, n = segments.length - 2; i < n; i++) {\n\t\t\t\t\t\t\tconst segment = segments[i]\n\t\t\t\t\t\t\tif (!segment) break\n\t\t\t\t\t\t\tif (segment.type === 'free') continue\n\n\t\t\t\t\t\t\tconst first = b64Vecs.decodeFirstPoint(segment.path, segment.dim)\n\t\t\t\t\t\t\tconst lastPoint = b64Vecs.decodeLastPoint(segment.path, segment.dim)\n\t\t\t\t\t\t\tif (!(first && lastPoint)) continue\n\n\t\t\t\t\t\t\t// Snap to the nearest point on the segment, if it's closer than the previous snapped point\n\t\t\t\t\t\t\tconst nearestPointOnSegment = Vec.NearestPointOnLineSegment(\n\t\t\t\t\t\t\t\tfirst,\n\t\t\t\t\t\t\t\tlastPoint,\n\t\t\t\t\t\t\t\tnewPoint\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tif (Vec.DistMin(nearestPointOnSegment, newPoint, minDistance)) {\n\t\t\t\t\t\t\t\tnearestPoint = nearestPointOnSegment.toFixed().toJson()\n\t\t\t\t\t\t\t\tminDistance = Vec.Dist(nearestPointOnSegment, newPoint)\n\t\t\t\t\t\t\t\tsnapSegment = segment\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (nearestPoint) {\n\t\t\t\t\t\t\tdidSnap = true\n\t\t\t\t\t\t\tnewPoint = nearestPoint\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (didSnap && snapSegment) {\n\t\t\t\t\tconst transform = this.editor.getShapePageTransform(shape)!\n\t\t\t\t\tconst first = b64Vecs.decodeFirstPoint(snapSegment.path, snapSegment.dim)\n\t\t\t\t\tconst lastPoint = b64Vecs.decodeLastPoint(snapSegment.path, snapSegment.dim)\n\t\t\t\t\tif (!first || !lastPoint) throw Error('Expected a last point!')\n\n\t\t\t\t\tconst A = Mat.applyToPoint(transform, first)\n\n\t\t\t\t\tconst B = Mat.applyToPoint(transform, lastPoint)\n\n\t\t\t\t\tconst snappedPoint = Mat.applyToPoint(transform, newPoint)\n\n\t\t\t\t\tthis.editor.snaps.setIndicators([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: uniqueId(),\n\t\t\t\t\t\t\ttype: 'points',\n\t\t\t\t\t\t\tpoints: [A, snappedPoint, B],\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t} else {\n\t\t\t\t\tthis.editor.snaps.clearIndicators()\n\n\t\t\t\t\tif (shouldSnapToAngle) {\n\t\t\t\t\t\t// Snap line angle to nearest 15 degrees\n\t\t\t\t\t\tconst currentAngle = Vec.Angle(pagePointWhereCurrentSegmentChanged, currentPagePoint)\n\t\t\t\t\t\tconst snappedAngle = snapAngle(currentAngle, 24)\n\t\t\t\t\t\tconst angleDiff = snappedAngle - currentAngle\n\n\t\t\t\t\t\tpagePoint = Vec.RotWith(\n\t\t\t\t\t\t\tcurrentPagePoint,\n\t\t\t\t\t\t\tpagePointWhereCurrentSegmentChanged,\n\t\t\t\t\t\t\tangleDiff\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpagePoint = currentPagePoint.clone()\n\t\t\t\t\t}\n\n\t\t\t\t\tnewPoint = this.editor.getPointInShapeSpace(shape, pagePoint).toFixed().toJson()\n\t\t\t\t}\n\n\t\t\t\t// If the previous segment is a one point free shape and is the first segment of the line,\n\t\t\t\t// then the user just did a click-and-immediately-press-shift to create a new straight line\n\t\t\t\t// without continuing the previous line. In this case, we want to remove the previous segment.\n\n\t\t\t\tthis.currentLineLength +=\n\t\t\t\t\tnewSegments.length && b64Vecs.decodeFirstPoint(newSegment.path, newSegment.dim)\n\t\t\t\t\t\t? Vec.Dist(\n\t\t\t\t\t\t\t\tb64Vecs.decodeFirstPoint(newSegment.path, newSegment.dim)!,\n\t\t\t\t\t\t\t\tVec.From(newPoint)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: 0\n\n\t\t\t\tnewSegments[newSegments.length - 1] = {\n\t\t\t\t\t...newSegment,\n\t\t\t\t\ttype: 'straight',\n\t\t\t\t\tpath: b64Vecs.encodePoints(\n\t\t\t\t\t\t[b64Vecs.decodeFirstPoint(newSegment.path, newSegment.dim)!, Vec.From(newPoint)],\n\t\t\t\t\t\tnewSegment.dim\n\t\t\t\t\t),\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments: newSegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'free': {\n\t\t\t\t// Use cached points instead of decoding from b64 on every update\n\t\t\t\tconst cachedPoints = this.currentSegmentPoints\n\n\t\t\t\tif (cachedPoints.length && this.mergeNextPoint) {\n\t\t\t\t\tconst lastPoint = cachedPoints[cachedPoints.length - 1]\n\t\t\t\t\tlastPoint.x = newPoint.x\n\t\t\t\t\tlastPoint.y = newPoint.y\n\t\t\t\t\tlastPoint.z = lastPoint.z ? Math.max(lastPoint.z, newPoint.z) : newPoint.z\n\t\t\t\t\t// Note: we could recompute the line length here, but it's not really necessary\n\t\t\t\t\t// this.currentLineLength = this.getLineLength(newSegments)\n\t\t\t\t} else {\n\t\t\t\t\tthis.currentLineLength += cachedPoints.length\n\t\t\t\t\t\t? Vec.Dist(cachedPoints[cachedPoints.length - 1], newPoint)\n\t\t\t\t\t\t: 0\n\t\t\t\t\tcachedPoints.push(new Vec(newPoint.x, newPoint.y, newPoint.z))\n\t\t\t\t}\n\n\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\tconst newSegment = newSegments[newSegments.length - 1]\n\t\t\t\tnewSegments[newSegments.length - 1] = {\n\t\t\t\t\t...newSegment,\n\t\t\t\t\tpath: b64Vecs.encodePoints(cachedPoints, newSegment.dim),\n\t\t\t\t}\n\n\t\t\t\tconst dvStrokeWidth = (getDisplayValues(this.util as any, shape) as { strokeWidth: number })\n\t\t\t\t\t.strokeWidth\n\t\t\t\tif (this.currentLineLength < dvStrokeWidth * 4) {\n\t\t\t\t\tthis.currentLineLength = this.getLineLength(newSegments)\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments: newSegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tnewSegments,\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\t// Set a maximum length for the lines array; after 200 points, complete the line.\n\t\t\t\tif (cachedPoints.length > this.util.options.maxPointsPerShape) {\n\t\t\t\t\tthis.editor.updateShapes([{ id, type: this.shapeType, props: { isComplete: true } }])\n\n\t\t\t\t\tconst newShapeId = createShapeId()\n\n\t\t\t\t\tconst props = this.editor.getShape<DrawableShape>(id)!.props\n\n\t\t\t\t\tif (!this.editor.canCreateShapes([newShapeId])) return this.cancel()\n\t\t\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\n\t\t\t\t\t// Reset cache for the new shape's segment\n\t\t\t\t\tconst initialPoint = new Vec(0, 0, this.isPenOrStylus ? +(z! * 1.25).toFixed() : 0.5)\n\t\t\t\t\tthis.currentSegmentPoints = [initialPoint]\n\n\t\t\t\t\tthis.editor.createShape({\n\t\t\t\t\t\tid: newShapeId,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tx: toFixed(currentPagePoint.x),\n\t\t\t\t\t\ty: toFixed(currentPagePoint.y),\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tisPen: this.isPenOrStylus,\n\t\t\t\t\t\t\tscale: props.scale,\n\t\t\t\t\t\t\tsegments: [this.makeSegment('free', [initialPoint])],\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\n\t\t\t\t\tconst shape = this.editor.getShape<DrawableShape>(newShapeId)\n\n\t\t\t\t\tif (!shape) {\n\t\t\t\t\t\t// This would only happen if the page is full and no more shapes can be created. The bug would manifest as a crash when we try to clone the shape.\n\t\t\t\t\t\t// todo: handle this type of thing better\n\t\t\t\t\t\treturn this.cancel()\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.initialShape = structuredClone(shape)\n\t\t\t\t\tthis.mergeNextPoint = false\n\t\t\t\t\tthis.lastRecordedPoint = currentPagePoint.clone()\n\t\t\t\t\tthis.currentLineLength = 0\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getLineLength(segments: TLDrawShapeSegment[]) {\n\t\tlet length = 0\n\n\t\tfor (let j = 0; j < segments.length; j++) {\n\t\t\tconst points = b64Vecs.decodePoints(segments[j].path, segments[j].dim)\n\t\t\tfor (let i = 0; i < points.length - 1; i++) {\n\t\t\t\tlength += Vec.Dist2(points[i], points[i + 1])\n\t\t\t}\n\t\t}\n\n\t\treturn Math.sqrt(length)\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.markId) {\n\t\t\tthis.editor.bailToMark(this.markId)\n\t\t}\n\t\tthis.cancel()\n\t}\n\n\tcomplete() {\n\t\tconst { initialShape } = this\n\t\tif (!initialShape) return\n\t\tthis.editor.updateShapes([\n\t\t\t{ id: initialShape.id, type: initialShape.type, props: { isComplete: true } },\n\t\t])\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tcancel() {\n\t\tthis.parent.transition('idle', this.info)\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAoBO;AAEP,qCAA6B;AAC7B,8BAAiC;AAK1B,MAAM,gBAAgB,wBAAU;AAAA,EACtC,OAAgB,KAAK;AAAA,EACrB,OAAgB,mBAAmB;AAAA,EAEnC,OAAO,CAAC;AAAA,EAER;AAAA,EAES,YAAY,KAAK,OAAO,OAAO,cAAe,cAAyB;AAAA,EAEhF,OAAO,KAAK,OAAO,aAAa,KAAK,SAAS;AAAA,EAE9C,QAAQ;AAAA,EACR,gBAAgB;AAAA;AAAA;AAAA;AAAA,EAKhB,aAA4B;AAAA,EAE5B,cAAc;AAAA,EAEd,6CAA6C;AAAA,EAE7C,sCAAsC,CAAC;AAAA,EAEvC,mCAAmC;AAAA,EAEnC,oBAAoB,CAAC;AAAA,EACrB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,cAAc;AAAA;AAAA,EAGd,uBAA8B,CAAC;AAAA,EAE/B,SAAS;AAAA,EAEA,QAAQ,MAA0B;AAC1C,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,oBAAoB,KAAK,OAAO,OAAO,oBAAoB,EAAE,MAAM;AACxE,SAAK,cAAc,KAAK,OAAO,aAAa;AAC5C,SAAK,WAAW;AAAA,EACjB;AAAA,EAES,gBAAgB;AACxB,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,UAAM,QAAQ,OAAO,SAAS;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AA,EACb;AAAA,EAES,aAAa;AACrB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC;AAAA,IACD;AAEA,QAAI,KAAK,QAAQ;AAChB,WAAK,OAAO,WAAW,KAAK,MAAM;AAAA,IACnC;AACA,SAAK,OAAO;AAAA,EACb;AAAA,EAEA,WAAW;AACV,UAAM,EAAE,aAAa,IAAI;AACzB,QAAI,CAAC,aAAc;AACnB,SAAK,OAAO,aAAa;AAAA,MACxB,EAAE,IAAI,aAAa,IAAI,MAAM,aAAa,MAAM,OAAO,EAAE,YAAY,KAAK,EAAE;AAAA,IAC7E,CAAC;AAED,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEA,SAAS;AACR,SAAK,OAAO,WAAW,QAAQ,KAAK,IAAI;AAAA,EACzC;AACD;",
|
|
4
|
+
"sourcesContent": ["import {\n\tMat,\n\tStateNode,\n\tTLDefaultSizeStyle,\n\tTLDrawShape,\n\tTLDrawShapeSegment,\n\tTLHighlightShape,\n\tTLKeyboardEventInfo,\n\tTLPointerEventInfo,\n\tTLShapePartial,\n\tDIM_2D,\n\tVec,\n\tVecModel,\n\tb64Vecs,\n\tcreateShapeId,\n\tlast,\n\tsnapAngle,\n\tstructuredClone,\n\ttoFixed,\n\tuniqueId,\n} from '@tldraw/editor'\nimport { HighlightShapeUtil } from '../../highlight/HighlightShapeUtil'\nimport { STROKE_SIZES } from '../../shared/default-shape-constants'\nimport { getDisplayValues } from '../../shared/getDisplayValues'\nimport { DrawShapeUtil } from '../DrawShapeUtil'\n\ntype DrawableShape = TLDrawShape | TLHighlightShape\n\nexport class Drawing extends StateNode {\n\tstatic override id = 'drawing'\n\tstatic override trackPerformance = true\n\n\tinfo = {} as TLPointerEventInfo\n\n\tinitialShape?: DrawableShape\n\n\toverride shapeType = this.parent.id === 'highlight' ? ('highlight' as const) : ('draw' as const)\n\n\tutil = this.editor.getShapeUtil(this.shapeType) as DrawShapeUtil | HighlightShapeUtil\n\n\tisPen = false\n\tisPenOrStylus = false\n\n\t// Encoding dimension for segments created during this stroke. `2` drops the\n\t// constant pressure value (non-pressure devices), `undefined` keeps full 3D.\n\t// Decided once in startShape from the input device \u2014 see the note there.\n\tsegmentDim: 2 | undefined = undefined\n\n\tsegmentMode = 'free' as 'free' | 'straight' | 'starting_straight' | 'starting_free'\n\n\tdidJustShiftClickToExtendPreviousShapeLine = false\n\n\tpagePointWhereCurrentSegmentChanged = {} as Vec\n\n\tpagePointWhereNextSegmentChanged = null as Vec | null\n\n\tlastRecordedPoint = {} as Vec\n\tmergeNextPoint = false\n\tcurrentLineLength = 0\n\tzoomOnEnter = 1\n\n\t// Cache for current segment's points to avoid repeated b64 decode/encode\n\tcurrentSegmentPoints: Vec[] = []\n\n\tmarkId = null as null | string\n\n\toverride onEnter(info: TLPointerEventInfo) {\n\t\tthis.markId = null\n\t\tthis.info = info\n\t\tthis.lastRecordedPoint = this.editor.inputs.getCurrentPagePoint().clone()\n\t\tthis.zoomOnEnter = this.editor.getZoomLevel()\n\t\tthis.startShape()\n\t}\n\n\toverride onPointerMove() {\n\t\tconst { inputs } = this.editor\n\t\tconst isPen = inputs.getIsPen()\n\n\t\tif (this.isPen && !isPen) {\n\t\t\t// The user made a palm gesture before starting a pen gesture;\n\t\t\t// ideally we'd start the new shape here but we could also just bail\n\t\t\t// as the next interaction will work correctly\n\t\t\tif (this.markId) {\n\t\t\t\tthis.editor.bailToMark(this.markId)\n\t\t\t\tthis.startShape()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (this.isPenOrStylus) {\n\t\t\t// Don't update the shape if we haven't moved far enough from the last time we recorded a point\n\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\t\t\tif (Vec.Dist(currentPagePoint, this.lastRecordedPoint) >= 1 / this.zoomOnEnter) {\n\t\t\t\tthis.lastRecordedPoint = currentPagePoint.clone()\n\t\t\t\tthis.mergeNextPoint = false\n\t\t\t} else {\n\t\t\t\tthis.mergeNextPoint = true\n\t\t\t}\n\t\t} else {\n\t\t\tthis.mergeNextPoint = false\n\t\t}\n\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onKeyDown(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Shift') {\n\t\t\tswitch (this.segmentMode) {\n\t\t\t\tcase 'free': {\n\t\t\t\t\t// We've just entered straight mode, go to straight mode\n\t\t\t\t\tthis.segmentMode = 'starting_straight'\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'starting_free': {\n\t\t\t\t\tthis.segmentMode = 'starting_straight'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tif (info.key === 'Shift') {\n\t\t\tthis.editor.snaps.clearIndicators()\n\n\t\t\tswitch (this.segmentMode) {\n\t\t\t\tcase 'straight': {\n\t\t\t\t\t// We've just exited straight mode, go back to free mode\n\t\t\t\t\tthis.segmentMode = 'starting_free'\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tcase 'starting_straight': {\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\t\t\t\t\tthis.segmentMode = 'free'\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.updateDrawingShape()\n\t}\n\n\toverride onExit() {\n\t\tthis.editor.snaps.clearIndicators()\n\t\tthis.pagePointWhereCurrentSegmentChanged = this.editor.inputs.getCurrentPagePoint().clone()\n\t}\n\n\tcanClose() {\n\t\treturn this.shapeType !== 'highlight'\n\t}\n\n\tgetIsClosed(\n\t\tsegments: TLDrawShapeSegment[],\n\t\tsize: TLDefaultSizeStyle,\n\t\tscale: number,\n\t\tstrokeWidth?: number\n\t) {\n\t\tif (!this.canClose()) return false\n\n\t\tif (strokeWidth === undefined) {\n\t\t\tconst theme = this.editor.getCurrentTheme()\n\t\t\tstrokeWidth = theme.strokeWidth * STROKE_SIZES[size]\n\t\t}\n\t\tconst firstPoint = b64Vecs.decodeFirstPoint(segments[0].path, segments[0].dim)\n\t\tconst lastSegment = segments[segments.length - 1]\n\t\tconst lastPoint = b64Vecs.decodeLastPoint(lastSegment.path, lastSegment.dim)\n\n\t\tconst isDynamicResizingEnabled = this.editor.user.getIsDynamicResizeMode()\n\n\t\tconst threshold = isDynamicResizingEnabled // when dynamic resizing is enabled scale is 1/zoom, so the threshold should not scale directly with zoom at all\n\t\t\t? (strokeWidth + 2) * scale // +2 keeps tiny strokes from being too hard to close\n\t\t\t: // 6 is a base floor, 2 is stroke influence, 0.8 tempers width growth\n\t\t\t\t6 +\n\t\t\t\t2 * Math.sqrt(strokeWidth * 0.8) +\n\t\t\t\t// 100 is low-zoom boost, 0.18 is the zoom knee, 3 controls falloff steepness\n\t\t\t\t100 / (1 + Math.pow(this.zoomOnEnter / 0.18, 3))\n\n\t\treturn (\n\t\t\tfirstPoint !== null &&\n\t\t\tlastPoint !== null &&\n\t\t\tfirstPoint !== lastPoint &&\n\t\t\tthis.currentLineLength > strokeWidth * 4 * scale &&\n\t\t\tVec.DistMin(firstPoint, lastPoint, threshold)\n\t\t)\n\t}\n\n\t/**\n\t * Build a segment from points, encoding `path` at this stroke's `segmentDim` and\n\t * attaching `dim: 2` only when z was dropped. 3D segments omit `dim` so they\n\t * serialize byte-identically to pre-#8879 data.\n\t */\n\tprivate makeSegment(type: TLDrawShapeSegment['type'], points: VecModel[]): TLDrawShapeSegment {\n\t\tconst path = b64Vecs.encodePoints(points, this.segmentDim)\n\t\treturn this.segmentDim === DIM_2D ? { type, path, dim: DIM_2D } : { type, path }\n\t}\n\n\tprivate startShape() {\n\t\tconst inputs = this.editor.inputs\n\t\tconst originPagePoint = inputs.getOriginPagePoint()\n\t\tconst isPen = inputs.getIsPen()\n\n\t\tthis.markId = this.editor.markHistoryStoppingPoint('draw start')\n\n\t\t// If the pressure is weird, then it's probably a stylus reporting as a mouse\n\t\t// We treat pen/stylus inputs differently in the drawing tool, so we need to\n\t\t// have our own value for this. The inputs.isPen is only if the input is a regular\n\t\t// pen, like an iPad pen, which needs to trigger \"pen mode\" in order to avoid\n\t\t// accidental palm touches. We don't have to worry about that with styluses though.\n\t\tconst { z = 0.5 } = this.info.point\n\n\t\tthis.isPen = isPen\n\t\t// if z === 0 on the initial point, treat this pen as a mouse because it's likely a broken pen\n\t\t// or a broken OS.\n\t\tthis.isPenOrStylus = (isPen && z !== 0) || (z > 0 && z < 0.5) || (z > 0.5 && z < 1)\n\n\t\t// Decide the encoding dimension once, here, from the input device \u2014 not by\n\t\t// scanning point data (content-driven). Device-driven keeps the encoded bytes\n\t\t// deterministic and is O(1) at stroke start. Non-pressure devices report a\n\t\t// constant z (0 / 0.5 / 1) that we normalize to 0.5 and omit entirely (2D);\n\t\t// pen/stylus input keeps the full 3D encoding.\n\t\tthis.segmentDim = this.isPenOrStylus ? undefined : DIM_2D\n\n\t\tconst pressure = this.isPenOrStylus ? z * 1.25 : 0.5\n\n\t\tthis.segmentMode = this.editor.inputs.getShiftKey() ? 'straight' : 'free'\n\n\t\tthis.didJustShiftClickToExtendPreviousShapeLine = false\n\n\t\tthis.lastRecordedPoint = originPagePoint.clone()\n\n\t\tif (this.initialShape) {\n\t\t\tconst shape = this.editor.getShape<DrawableShape>(this.initialShape.id)\n\n\t\t\t// The remembered shape survives a page change; extending it from another\n\t\t\t// page would silently append a segment to content the user can't see (#10400)\n\t\t\tif (shape && this.segmentMode === 'straight' && this.editor.isShapeInPage(shape)) {\n\t\t\t\t// Connect dots\n\n\t\t\t\tthis.didJustShiftClickToExtendPreviousShapeLine = true\n\n\t\t\t\tconst prevSegment = last(shape.props.segments)\n\t\t\t\tif (!prevSegment) throw Error('Expected a previous segment!')\n\t\t\t\tconst prevPoint = b64Vecs.decodeLastPoint(prevSegment.path, prevSegment.dim)\n\t\t\t\tif (!prevPoint) throw Error('Expected a previous point!')\n\n\t\t\t\tconst { x, y } = this.editor.getPointInShapeSpace(shape, originPagePoint).toFixed()\n\n\t\t\t\tconst newSegment = this.makeSegment(this.segmentMode, [\n\t\t\t\t\t{ x: prevPoint.x, y: prevPoint.y, z: +pressure.toFixed(2) },\n\t\t\t\t\t{ x, y, z: +pressure.toFixed(2) },\n\t\t\t\t])\n\n\t\t\t\t// Convert prevPoint to page space\n\t\t\t\tconst prevPointPageSpace = Mat.applyToPoint(\n\t\t\t\t\tthis.editor.getShapePageTransform(shape.id)!,\n\t\t\t\t\tprevPoint\n\t\t\t\t)\n\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = prevPointPageSpace\n\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\t\t\t\tconst segments = [...shape.props.segments, newSegment]\n\n\t\t\t\tconst dvStrokeWidth = (getDisplayValues(this.util as any, shape) as { strokeWidth: number })\n\t\t\t\t\t.strokeWidth\n\t\t\t\tif (this.currentLineLength < dvStrokeWidth * 4) {\n\t\t\t\t\tthis.currentLineLength = this.getLineLength(segments)\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid: shape.id,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tshape.props.size,\n\t\t\t\t\t\tshape.props.scale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Create a new shape\n\n\t\tthis.pagePointWhereCurrentSegmentChanged = originPagePoint.clone()\n\t\tconst id = createShapeId()\n\n\t\t// Initialize the segment points cache\n\t\tconst initialPoint = new Vec(0, 0, +pressure.toFixed(2))\n\t\tthis.currentSegmentPoints = [initialPoint]\n\n\t\t// Allow this to trigger the max shapes reached alert\n\t\tthis.editor.createShape({\n\t\t\tid,\n\t\t\ttype: this.shapeType,\n\t\t\tx: originPagePoint.x,\n\t\t\ty: originPagePoint.y,\n\t\t\tprops: {\n\t\t\t\tisPen: this.isPenOrStylus,\n\t\t\t\tscale: this.editor.getResizeScaleFactor(),\n\t\t\t\tsegments: [this.makeSegment(this.segmentMode, [initialPoint])],\n\t\t\t},\n\t\t})\n\t\tconst shape = this.editor.getShape<DrawableShape>(id)\n\t\tif (!shape) {\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\t\tthis.currentLineLength = 0\n\t\tthis.initialShape = this.editor.getShape<DrawableShape>(id)\n\t}\n\n\tprivate updateDrawingShape() {\n\t\tconst { initialShape } = this\n\t\tconst { inputs } = this.editor\n\n\t\tif (!initialShape) return\n\n\t\tconst {\n\t\t\tid,\n\t\t\tprops: { size, scale },\n\t\t} = initialShape\n\n\t\tconst shape = this.editor.getShape<DrawableShape>(id)!\n\n\t\tif (!shape) return\n\n\t\tconst { segments } = shape.props\n\n\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\t\tconst { x, y, z } = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed()\n\t\tconst pressure = this.isPenOrStylus ? +(currentPagePoint.z! * 1.25).toFixed(2) : 0.5\n\t\tconst newPoint = { x, y, z: pressure }\n\n\t\tswitch (this.segmentMode) {\n\t\t\tcase 'starting_straight': {\n\t\t\t\tconst { pagePointWhereNextSegmentChanged } = this\n\n\t\t\t\tif (pagePointWhereNextSegmentChanged === null) {\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\t\t\t\t}\n\n\t\t\t\t// page-space distance against a screen-space threshold, so scale by the zoom\n\t\t\t\tconst zoom = this.editor.getZoomLevel()\n\t\t\t\tconst hasMovedFarEnough =\n\t\t\t\t\tVec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) * zoom * zoom >\n\t\t\t\t\tthis.editor.options.dragDistanceSquared\n\n\t\t\t\t// Find the distance from where the pointer was when shift was released and\n\t\t\t\t// where it is now; if it's far enough away, then update the page point where\n\t\t\t\t// the current segment changed (to match the pagepoint where next segment changed)\n\t\t\t\t// and set the pagepoint where next segment changed to null.\n\t\t\t\tif (hasMovedFarEnough) {\n\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged!.clone()\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\n\t\t\t\t\t// Set the new mode\n\t\t\t\t\tthis.segmentMode = 'straight'\n\n\t\t\t\t\tconst prevSegment = last(segments)\n\t\t\t\t\tif (!prevSegment) throw Error('Expected a previous segment!')\n\n\t\t\t\t\tconst prevLastPoint = b64Vecs.decodeLastPoint(prevSegment.path, prevSegment.dim)\n\t\t\t\t\tif (!prevLastPoint) throw Error('Expected a previous last point!')\n\n\t\t\t\t\tlet newSegment: TLDrawShapeSegment\n\n\t\t\t\t\tconst newLastPoint = this.editor\n\t\t\t\t\t\t.getPointInShapeSpace(shape, this.pagePointWhereCurrentSegmentChanged)\n\t\t\t\t\t\t.toFixed()\n\t\t\t\t\t\t.toJson()\n\n\t\t\t\t\tif (prevSegment.type === 'straight') {\n\t\t\t\t\t\tthis.currentLineLength += Vec.Dist(prevLastPoint, newLastPoint)\n\n\t\t\t\t\t\tnewSegment = this.makeSegment('straight', [prevLastPoint, newLastPoint])\n\n\t\t\t\t\t\tconst transform = this.editor.getShapePageTransform(shape)!\n\n\t\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = Mat.applyToPoint(transform, prevLastPoint)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewSegment = this.makeSegment('straight', [newLastPoint, newPoint])\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tsegments: [...segments, newSegment],\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\t\tsegments,\n\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\tscale\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.editor.updateShapes([shapePartial])\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'starting_free': {\n\t\t\t\tconst { pagePointWhereNextSegmentChanged } = this\n\n\t\t\t\tif (pagePointWhereNextSegmentChanged === null) {\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\t\t\t\t}\n\n\t\t\t\t// page-space distance against a screen-space threshold, so scale by the zoom\n\t\t\t\tconst zoom = this.editor.getZoomLevel()\n\t\t\t\tconst hasMovedFarEnough =\n\t\t\t\t\tVec.Dist2(pagePointWhereNextSegmentChanged, inputs.getCurrentPagePoint()) * zoom * zoom >\n\t\t\t\t\tthis.editor.options.dragDistanceSquared\n\n\t\t\t\t// Find the distance from where the pointer was when shift was released and\n\t\t\t\t// where it is now; if it's far enough away, then update the page point where\n\t\t\t\t// the current segment changed (to match the pagepoint where next segment changed)\n\t\t\t\t// and set the pagepoint where next segment changed to null.\n\t\t\t\tif (hasMovedFarEnough) {\n\t\t\t\t\tthis.pagePointWhereCurrentSegmentChanged = this.pagePointWhereNextSegmentChanged!.clone()\n\t\t\t\t\tthis.pagePointWhereNextSegmentChanged = null\n\n\t\t\t\t\t// Set the new mode\n\t\t\t\t\tthis.segmentMode = 'free'\n\n\t\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\t\tconst prevStraightSegment = newSegments[newSegments.length - 1]\n\t\t\t\t\tconst prevPoint = b64Vecs.decodeLastPoint(\n\t\t\t\t\t\tprevStraightSegment.path,\n\t\t\t\t\t\tprevStraightSegment.dim\n\t\t\t\t\t)\n\n\t\t\t\t\tif (!prevPoint) {\n\t\t\t\t\t\tthrow Error('No previous point!')\n\t\t\t\t\t}\n\n\t\t\t\t\t// Create the new free segment and interpolate the points between where the last line\n\t\t\t\t\t// ended and where the pointer is now\n\t\t\t\t\tconst interpolatedPoints = Vec.PointsBetween(prevPoint, newPoint, 6).map(\n\t\t\t\t\t\t(p) => new Vec(toFixed(p.x), toFixed(p.y), toFixed(p.z))\n\t\t\t\t\t)\n\t\t\t\t\t// Initialize cache for the new free segment\n\t\t\t\t\tthis.currentSegmentPoints = interpolatedPoints\n\n\t\t\t\t\tconst newFreeSegment = this.makeSegment('free', interpolatedPoints)\n\n\t\t\t\t\tconst finalSegments = [...newSegments, newFreeSegment]\n\n\t\t\t\t\tconst dvStrokeWidth = (\n\t\t\t\t\t\tgetDisplayValues(this.util as any, shape) as { strokeWidth: number }\n\t\t\t\t\t).strokeWidth\n\t\t\t\t\tif (this.currentLineLength < dvStrokeWidth * 4) {\n\t\t\t\t\t\tthis.currentLineLength = this.getLineLength(finalSegments)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tsegments: finalSegments,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\t\tfinalSegments,\n\t\t\t\t\t\t\tsize,\n\t\t\t\t\t\t\tscale\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.editor.updateShapes([shapePartial])\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'straight': {\n\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\tconst newSegment = newSegments[newSegments.length - 1]\n\n\t\t\t\tconst { pagePointWhereCurrentSegmentChanged } = this\n\t\t\t\tconst inputs = this.editor.inputs\n\t\t\t\tconst ctrlKey = inputs.getCtrlKey()\n\t\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\n\t\t\t\tif (!pagePointWhereCurrentSegmentChanged)\n\t\t\t\t\tthrow Error('We should have a point where the segment changed')\n\n\t\t\t\tlet pagePoint: VecModel\n\t\t\t\tlet shouldSnapToAngle = false\n\n\t\t\t\tif (this.didJustShiftClickToExtendPreviousShapeLine) {\n\t\t\t\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\t\t\t\t// If we've just shift clicked to extend a line, only snap once we've started dragging\n\t\t\t\t\t\tshouldSnapToAngle = !ctrlKey\n\t\t\t\t\t\tthis.didJustShiftClickToExtendPreviousShapeLine = false\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// noop\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// If we're not shift clicking to extend a line, but we're holding shift, then we should snap\n\t\t\t\t\tshouldSnapToAngle = !ctrlKey // don't snap angle while snapping line\n\t\t\t\t}\n\n\t\t\t\tlet newPoint = this.editor.getPointInShapeSpace(shape, currentPagePoint).toFixed().toJson()\n\t\t\t\tlet didSnap = false\n\t\t\t\tlet snapSegment: TLDrawShapeSegment | undefined = undefined\n\n\t\t\t\tconst shouldSnap = this.editor.user.getIsSnapMode() ? !ctrlKey : ctrlKey\n\n\t\t\t\tif (shouldSnap) {\n\t\t\t\t\tif (newSegments.length > 2) {\n\t\t\t\t\t\tlet nearestPoint: VecModel | undefined = undefined\n\t\t\t\t\t\tlet minDistance = 8 / this.zoomOnEnter\n\n\t\t\t\t\t\t// Don't try to snap to the last two segments\n\t\t\t\t\t\tfor (let i = 0, n = segments.length - 2; i < n; i++) {\n\t\t\t\t\t\t\tconst segment = segments[i]\n\t\t\t\t\t\t\tif (!segment) break\n\t\t\t\t\t\t\tif (segment.type === 'free') continue\n\n\t\t\t\t\t\t\tconst first = b64Vecs.decodeFirstPoint(segment.path, segment.dim)\n\t\t\t\t\t\t\tconst lastPoint = b64Vecs.decodeLastPoint(segment.path, segment.dim)\n\t\t\t\t\t\t\tif (!(first && lastPoint)) continue\n\n\t\t\t\t\t\t\t// Snap to the nearest point on the segment, if it's closer than the previous snapped point\n\t\t\t\t\t\t\tconst nearestPointOnSegment = Vec.NearestPointOnLineSegment(\n\t\t\t\t\t\t\t\tfirst,\n\t\t\t\t\t\t\t\tlastPoint,\n\t\t\t\t\t\t\t\tnewPoint\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tif (Vec.DistMin(nearestPointOnSegment, newPoint, minDistance)) {\n\t\t\t\t\t\t\t\tnearestPoint = nearestPointOnSegment.toFixed().toJson()\n\t\t\t\t\t\t\t\tminDistance = Vec.Dist(nearestPointOnSegment, newPoint)\n\t\t\t\t\t\t\t\tsnapSegment = segment\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (nearestPoint) {\n\t\t\t\t\t\t\tdidSnap = true\n\t\t\t\t\t\t\tnewPoint = nearestPoint\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (didSnap && snapSegment) {\n\t\t\t\t\tconst transform = this.editor.getShapePageTransform(shape)!\n\t\t\t\t\tconst first = b64Vecs.decodeFirstPoint(snapSegment.path, snapSegment.dim)\n\t\t\t\t\tconst lastPoint = b64Vecs.decodeLastPoint(snapSegment.path, snapSegment.dim)\n\t\t\t\t\tif (!first || !lastPoint) throw Error('Expected a last point!')\n\n\t\t\t\t\tconst A = Mat.applyToPoint(transform, first)\n\n\t\t\t\t\tconst B = Mat.applyToPoint(transform, lastPoint)\n\n\t\t\t\t\tconst snappedPoint = Mat.applyToPoint(transform, newPoint)\n\n\t\t\t\t\tthis.editor.snaps.setIndicators([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: uniqueId(),\n\t\t\t\t\t\t\ttype: 'points',\n\t\t\t\t\t\t\tpoints: [A, snappedPoint, B],\n\t\t\t\t\t\t},\n\t\t\t\t\t])\n\t\t\t\t} else {\n\t\t\t\t\tthis.editor.snaps.clearIndicators()\n\n\t\t\t\t\tif (shouldSnapToAngle) {\n\t\t\t\t\t\t// Snap line angle to nearest 15 degrees\n\t\t\t\t\t\tconst currentAngle = Vec.Angle(pagePointWhereCurrentSegmentChanged, currentPagePoint)\n\t\t\t\t\t\tconst snappedAngle = snapAngle(currentAngle, 24)\n\t\t\t\t\t\tconst angleDiff = snappedAngle - currentAngle\n\n\t\t\t\t\t\tpagePoint = Vec.RotWith(\n\t\t\t\t\t\t\tcurrentPagePoint,\n\t\t\t\t\t\t\tpagePointWhereCurrentSegmentChanged,\n\t\t\t\t\t\t\tangleDiff\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpagePoint = currentPagePoint.clone()\n\t\t\t\t\t}\n\n\t\t\t\t\tnewPoint = this.editor.getPointInShapeSpace(shape, pagePoint).toFixed().toJson()\n\t\t\t\t}\n\n\t\t\t\t// If the previous segment is a one point free shape and is the first segment of the line,\n\t\t\t\t// then the user just did a click-and-immediately-press-shift to create a new straight line\n\t\t\t\t// without continuing the previous line. In this case, we want to remove the previous segment.\n\n\t\t\t\tthis.currentLineLength +=\n\t\t\t\t\tnewSegments.length && b64Vecs.decodeFirstPoint(newSegment.path, newSegment.dim)\n\t\t\t\t\t\t? Vec.Dist(\n\t\t\t\t\t\t\t\tb64Vecs.decodeFirstPoint(newSegment.path, newSegment.dim)!,\n\t\t\t\t\t\t\t\tVec.From(newPoint)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: 0\n\n\t\t\t\tnewSegments[newSegments.length - 1] = {\n\t\t\t\t\t...newSegment,\n\t\t\t\t\ttype: 'straight',\n\t\t\t\t\tpath: b64Vecs.encodePoints(\n\t\t\t\t\t\t[b64Vecs.decodeFirstPoint(newSegment.path, newSegment.dim)!, Vec.From(newPoint)],\n\t\t\t\t\t\tnewSegment.dim\n\t\t\t\t\t),\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments: newSegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tsegments,\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'free': {\n\t\t\t\t// Use cached points instead of decoding from b64 on every update\n\t\t\t\tconst cachedPoints = this.currentSegmentPoints\n\n\t\t\t\tif (cachedPoints.length && this.mergeNextPoint) {\n\t\t\t\t\tconst lastPoint = cachedPoints[cachedPoints.length - 1]\n\t\t\t\t\tlastPoint.x = newPoint.x\n\t\t\t\t\tlastPoint.y = newPoint.y\n\t\t\t\t\tlastPoint.z = lastPoint.z ? Math.max(lastPoint.z, newPoint.z) : newPoint.z\n\t\t\t\t\t// Note: we could recompute the line length here, but it's not really necessary\n\t\t\t\t\t// this.currentLineLength = this.getLineLength(newSegments)\n\t\t\t\t} else {\n\t\t\t\t\tthis.currentLineLength += cachedPoints.length\n\t\t\t\t\t\t? Vec.Dist(cachedPoints[cachedPoints.length - 1], newPoint)\n\t\t\t\t\t\t: 0\n\t\t\t\t\tcachedPoints.push(new Vec(newPoint.x, newPoint.y, newPoint.z))\n\t\t\t\t}\n\n\t\t\t\tconst newSegments = segments.slice()\n\t\t\t\tconst newSegment = newSegments[newSegments.length - 1]\n\t\t\t\tnewSegments[newSegments.length - 1] = {\n\t\t\t\t\t...newSegment,\n\t\t\t\t\tpath: b64Vecs.encodePoints(cachedPoints, newSegment.dim),\n\t\t\t\t}\n\n\t\t\t\tconst dvStrokeWidth = (getDisplayValues(this.util as any, shape) as { strokeWidth: number })\n\t\t\t\t\t.strokeWidth\n\t\t\t\tif (this.currentLineLength < dvStrokeWidth * 4) {\n\t\t\t\t\tthis.currentLineLength = this.getLineLength(newSegments)\n\t\t\t\t}\n\n\t\t\t\tconst shapePartial: TLShapePartial<DrawableShape> = {\n\t\t\t\t\tid,\n\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tsegments: newSegments,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif (this.canClose()) {\n\t\t\t\t\t;(shapePartial as TLShapePartial<TLDrawShape>).props!.isClosed = this.getIsClosed(\n\t\t\t\t\t\tnewSegments,\n\t\t\t\t\t\tsize,\n\t\t\t\t\t\tscale\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tthis.editor.updateShapes([shapePartial])\n\n\t\t\t\t// Set a maximum length for the lines array; after 200 points, complete the line.\n\t\t\t\tif (cachedPoints.length > this.util.options.maxPointsPerShape) {\n\t\t\t\t\tthis.editor.updateShapes([{ id, type: this.shapeType, props: { isComplete: true } }])\n\n\t\t\t\t\tconst newShapeId = createShapeId()\n\n\t\t\t\t\tconst props = this.editor.getShape<DrawableShape>(id)!.props\n\n\t\t\t\t\tif (!this.editor.canCreateShapes([newShapeId])) return this.cancel()\n\t\t\t\t\tconst currentPagePoint = inputs.getCurrentPagePoint()\n\n\t\t\t\t\t// Reset cache for the new shape's segment\n\t\t\t\t\tconst initialPoint = new Vec(0, 0, this.isPenOrStylus ? +(z! * 1.25).toFixed(2) : 0.5)\n\t\t\t\t\tthis.currentSegmentPoints = [initialPoint]\n\n\t\t\t\t\tthis.editor.createShape({\n\t\t\t\t\t\tid: newShapeId,\n\t\t\t\t\t\ttype: this.shapeType,\n\t\t\t\t\t\tx: toFixed(currentPagePoint.x),\n\t\t\t\t\t\ty: toFixed(currentPagePoint.y),\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tisPen: this.isPenOrStylus,\n\t\t\t\t\t\t\tscale: props.scale,\n\t\t\t\t\t\t\tsegments: [this.makeSegment('free', [initialPoint])],\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\n\t\t\t\t\tconst shape = this.editor.getShape<DrawableShape>(newShapeId)\n\n\t\t\t\t\tif (!shape) {\n\t\t\t\t\t\t// This would only happen if the page is full and no more shapes can be created. The bug would manifest as a crash when we try to clone the shape.\n\t\t\t\t\t\t// todo: handle this type of thing better\n\t\t\t\t\t\treturn this.cancel()\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.initialShape = structuredClone(shape)\n\t\t\t\t\tthis.mergeNextPoint = false\n\t\t\t\t\tthis.lastRecordedPoint = currentPagePoint.clone()\n\t\t\t\t\tthis.currentLineLength = 0\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getLineLength(segments: TLDrawShapeSegment[]) {\n\t\tlet length = 0\n\n\t\tfor (let j = 0; j < segments.length; j++) {\n\t\t\tconst points = b64Vecs.decodePoints(segments[j].path, segments[j].dim)\n\t\t\tfor (let i = 0; i < points.length - 1; i++) {\n\t\t\t\tlength += Vec.Dist(points[i], points[i + 1])\n\t\t\t}\n\t\t}\n\n\t\treturn length\n\t}\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.complete()\n\t}\n\n\toverride onInterrupt() {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.markId) {\n\t\t\tthis.editor.bailToMark(this.markId)\n\t\t}\n\t\tthis.cancel()\n\t}\n\n\tcomplete() {\n\t\tconst { initialShape } = this\n\t\tif (!initialShape) return\n\t\tthis.editor.updateShapes([\n\t\t\t{ id: initialShape.id, type: initialShape.type, props: { isComplete: true } },\n\t\t])\n\n\t\tthis.parent.transition('idle')\n\t}\n\n\tcancel() {\n\t\tthis.parent.transition('idle', this.info)\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAoBO;AAEP,qCAA6B;AAC7B,8BAAiC;AAK1B,MAAM,gBAAgB,wBAAU;AAAA,EACtC,OAAgB,KAAK;AAAA,EACrB,OAAgB,mBAAmB;AAAA,EAEnC,OAAO,CAAC;AAAA,EAER;AAAA,EAES,YAAY,KAAK,OAAO,OAAO,cAAe,cAAyB;AAAA,EAEhF,OAAO,KAAK,OAAO,aAAa,KAAK,SAAS;AAAA,EAE9C,QAAQ;AAAA,EACR,gBAAgB;AAAA;AAAA;AAAA;AAAA,EAKhB,aAA4B;AAAA,EAE5B,cAAc;AAAA,EAEd,6CAA6C;AAAA,EAE7C,sCAAsC,CAAC;AAAA,EAEvC,mCAAmC;AAAA,EAEnC,oBAAoB,CAAC;AAAA,EACrB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,cAAc;AAAA;AAAA,EAGd,uBAA8B,CAAC;AAAA,EAE/B,SAAS;AAAA,EAEA,QAAQ,MAA0B;AAC1C,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,oBAAoB,KAAK,OAAO,OAAO,oBAAoB,EAAE,MAAM;AACxE,SAAK,cAAc,KAAK,OAAO,aAAa;AAC5C,SAAK,WAAW;AAAA,EACjB;AAAA,EAES,gBAAgB;AACxB,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,UAAM,QAAQ,OAAO,SAAS;AAE9B,QAAI,KAAK,SAAS,CAAC,OAAO;AAIzB,UAAI,KAAK,QAAQ;AAChB,aAAK,OAAO,WAAW,KAAK,MAAM;AAClC,aAAK,WAAW;AAChB;AAAA,MACD;AAAA,IACD;AAE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,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AACtB,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC;AAAA,IACD;AAEA,QAAI,KAAK,QAAQ;AAChB,WAAK,OAAO,WAAW,KAAK,MAAM;AAAA,IACnC;AACA,SAAK,OAAO;AAAA,EACb;AAAA,EAEA,WAAW;AACV,UAAM,EAAE,aAAa,IAAI;AACzB,QAAI,CAAC,aAAc;AACnB,SAAK,OAAO,aAAa;AAAA,MACxB,EAAE,IAAI,aAAa,IAAI,MAAM,aAAa,MAAM,OAAO,EAAE,YAAY,KAAK,EAAE;AAAA,IAC7E,CAAC;AAED,SAAK,OAAO,WAAW,MAAM;AAAA,EAC9B;AAAA,EAEA,SAAS;AACR,SAAK,OAAO,WAAW,QAAQ,KAAK,IAAI;AAAA,EACzC;AACD;",
|
|
6
6
|
"names": ["shape", "inputs", "currentPagePoint", "newPoint"]
|
|
7
7
|
}
|
|
@@ -272,7 +272,9 @@ function getXBoxPath(w, h, sw, dash, isFilled) {
|
|
|
272
272
|
const inset = dash === "draw" ? 0.62 : 0;
|
|
273
273
|
path.moveTo((0, import_editor.clamp)(sw * inset, 0, w), (0, import_editor.clamp)(sw * inset, 0, h), {
|
|
274
274
|
geometry: { isInternal: true, isFilled: false }
|
|
275
|
-
}).lineTo((0, import_editor.clamp)(w - sw * inset, 0, w), (0, import_editor.clamp)(h - sw * inset, 0, h)).moveTo((0, import_editor.clamp)(w - sw * inset, 0, w), (0, import_editor.clamp)(sw * inset, 0, h)
|
|
275
|
+
}).lineTo((0, import_editor.clamp)(w - sw * inset, 0, w), (0, import_editor.clamp)(h - sw * inset, 0, h)).moveTo((0, import_editor.clamp)(w - sw * inset, 0, w), (0, import_editor.clamp)(sw * inset, 0, h), {
|
|
276
|
+
geometry: { isInternal: true, isFilled: false }
|
|
277
|
+
}).lineTo((0, import_editor.clamp)(sw * inset, 0, w), (0, import_editor.clamp)(h - sw * inset, 0, h));
|
|
276
278
|
return path;
|
|
277
279
|
}
|
|
278
280
|
function getStadiumPath(w, h, isFilled) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/shapes/geo/getGeoShapePath.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tcenterOfCircleFromThreePoints,\n\tclamp,\n\tgetPointOnCircle,\n\tgetPolygonVertices,\n\tHALF_PI,\n\tPI,\n\tPI2,\n\trng,\n\tTLDefaultDashStyle,\n\tTLDefaultSizeStyle,\n\tTLGeoShape,\n\tVec,\n\tVecModel,\n\tWeakCache,\n} from '@tldraw/editor'\nimport { getFlipMatrix } from '../shared/flip'\nimport { PathBuilder } from '../shared/PathBuilder'\n\n/**\n * Defines the behavior for a geo shape type. Every built-in geo type is\n * registered through this same interface (see {@link defaultGeoTypeDefinitions}),\n * and consumers can register additional types via\n * {@link @tldraw/tldraw#GeoShapeUtil.configure | GeoShapeUtil.configure()}.\n *\n * @public\n */\nexport interface GeoTypeDefinition {\n\t/**\n\t * Generate the path geometry for this geo type.\n\t *\n\t * @param w - The width of the shape (already clamped to min 1)\n\t * @param h - The height of the shape (already clamped to min 1, includes growY)\n\t * @param shape - The full geo shape record, for access to props like id, dash, fill, etc.\n\t * @param strokeWidth - The scaled stroke width (strokeWidth * scale)\n\t */\n\tgetPath(w: number, h: number, shape: TLGeoShape, strokeWidth: number): PathBuilder\n\t/** Snap behavior: 'polygon' snaps to vertices + center, 'blobby' snaps to center only. */\n\tsnapType: 'polygon' | 'blobby'\n\t/** Default creation size when clicking (not dragging). Defaults to 200x200. */\n\tdefaultSize?: { w: number; h: number }\n\t/** Icon name for the style panel geo picker. */\n\ticon: string\n\t/**\n\t * Optional double-click handler. Return an object with partial props to update the shape,\n\t * or void to do nothing.\n\t */\n\tonDoubleClick?(shape: TLGeoShape): { props: Partial<TLGeoShape['props']> } | void\n}\n\n/**\n * Built-in geo type definitions keyed by their `geo` prop value. Every default\n * geo type (rectangle, ellipse, cloud, etc.) is registered here. The same\n * registry powers path generation, handle snapping, the style panel picker,\n * and creation defaults \u2014 so custom types added through\n * {@link @tldraw/tldraw#GeoShapeUtil.configure | GeoShapeUtil.configure()} get\n * the same treatment as the built-ins.\n *\n * The key order here defines the visual order of items in the geo style panel\n * picker.\n *\n * @public\n */\nexport const defaultGeoTypeDefinitions = {\n\trectangle: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-rectangle',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, 0)\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\tellipse: {\n\t\tsnapType: 'blobby',\n\t\ticon: 'geo-ellipse',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst cx = w / 2\n\t\t\tconst cy = h / 2\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, cy, { geometry: { isFilled } })\n\t\t\t\t.arcTo(cx, cy, false, true, 0, w, cy)\n\t\t\t\t.arcTo(cx, cy, false, true, 0, 0, cy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\ttriangle: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-triangle',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst cx = w / 2\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(cx, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\tdiamond: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-diamond',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst cx = w / 2\n\t\t\tconst cy = h / 2\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(cx, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, cy)\n\t\t\t\t.lineTo(cx, h)\n\t\t\t\t.lineTo(0, cy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\tstar: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-star',\n\t\tdefaultSize: { w: 200, h: 190 },\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn getStarPath(w, h, isFilled)\n\t\t},\n\t},\n\tpentagon: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-pentagon',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn PathBuilder.lineThroughPoints(getPolygonVertices(w, h, 5), {\n\t\t\t\tgeometry: { isFilled },\n\t\t\t}).close()\n\t\t},\n\t},\n\thexagon: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-hexagon',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn PathBuilder.lineThroughPoints(getPolygonVertices(w, h, 6), {\n\t\t\t\tgeometry: { isFilled },\n\t\t\t}).close()\n\t\t},\n\t},\n\toctagon: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-octagon',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn PathBuilder.lineThroughPoints(getPolygonVertices(w, h, 8), {\n\t\t\t\tgeometry: { isFilled },\n\t\t\t}).close()\n\t\t},\n\t},\n\trhombus: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-rhombus',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst offset = Math.min(w * 0.38, h * 0.38)\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(offset, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, 0)\n\t\t\t\t.lineTo(w - offset, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'rhombus-2': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-rhombus-2',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst offset = Math.min(w * 0.38, h * 0.38)\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w - offset, 0)\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(offset, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\toval: {\n\t\tsnapType: 'blobby',\n\t\ticon: 'geo-oval',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn getStadiumPath(w, h, isFilled)\n\t\t},\n\t},\n\ttrapezoid: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-trapezoid',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst offset = Math.min(w * 0.38, h * 0.38)\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(offset, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w - offset, 0)\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'arrow-left': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-arrow-left',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst ox = Math.min(w, h) * 0.38\n\t\t\tconst oy = h * 0.16\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(ox, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(ox, oy)\n\t\t\t\t.lineTo(w, oy)\n\t\t\t\t.lineTo(w, h - oy)\n\t\t\t\t.lineTo(ox, h - oy)\n\t\t\t\t.lineTo(ox, h)\n\t\t\t\t.lineTo(0, h / 2)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'arrow-up': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-arrow-up',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst ox = w * 0.16\n\t\t\tconst oy = Math.min(w, h) * 0.38\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(w / 2, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, oy)\n\t\t\t\t.lineTo(w - ox, oy)\n\t\t\t\t.lineTo(w - ox, h)\n\t\t\t\t.lineTo(ox, h)\n\t\t\t\t.lineTo(ox, oy)\n\t\t\t\t.lineTo(0, oy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'arrow-down': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-arrow-down',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst ox = w * 0.16\n\t\t\tconst oy = Math.min(w, h) * 0.38\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(ox, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w - ox, 0)\n\t\t\t\t.lineTo(w - ox, h - oy)\n\t\t\t\t.lineTo(w, h - oy)\n\t\t\t\t.lineTo(w / 2, h)\n\t\t\t\t.lineTo(0, h - oy)\n\t\t\t\t.lineTo(ox, h - oy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'arrow-right': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-arrow-right',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst ox = Math.min(w, h) * 0.38\n\t\t\tconst oy = h * 0.16\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, oy, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w - ox, oy)\n\t\t\t\t.lineTo(w - ox, 0)\n\t\t\t\t.lineTo(w, h / 2)\n\t\t\t\t.lineTo(w - ox, h)\n\t\t\t\t.lineTo(w - ox, h - oy)\n\t\t\t\t.lineTo(0, h - oy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\tcloud: {\n\t\tsnapType: 'blobby',\n\t\ticon: 'geo-cloud',\n\t\tdefaultSize: { w: 300, h: 180 },\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn getCloudPath(w, h, shape.id, shape.props.size, shape.props.scale, isFilled)\n\t\t},\n\t},\n\t'x-box': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-x-box',\n\t\tgetPath(w, h, shape, strokeWidth) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn getXBoxPath(w, h, strokeWidth, shape.props.dash, isFilled)\n\t\t},\n\t},\n\t'check-box': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-check-box',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst size = Math.min(w, h) * 0.82\n\t\t\tconst ox = (w - size) / 2\n\t\t\tconst oy = (h - size) / 2\n\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, 0)\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t\t\t.moveTo(clamp(ox + size * 0.25, 0, w), clamp(oy + size * 0.52, 0, h), {\n\t\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\t\toffset: 0,\n\t\t\t\t})\n\t\t\t\t.lineTo(clamp(ox + size * 0.45, 0, w), clamp(oy + size * 0.82, 0, h))\n\t\t\t\t.lineTo(clamp(ox + size * 0.82, 0, w), clamp(oy + size * 0.22, 0, h), { offset: 0 })\n\t\t},\n\t},\n\theart: {\n\t\tsnapType: 'blobby',\n\t\ticon: 'geo-heart',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst cx = w / 2\n\t\t\tconst o = w / 4\n\t\t\tconst k = h / 4\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(cx, h, { geometry: { isFilled } })\n\t\t\t\t.cubicBezierTo(0, k * 1.2, o * 1.5, k * 3, 0, k * 2.5)\n\t\t\t\t.cubicBezierTo(cx, k * 0.9, 0, -k * 0.32, o * 1.85, -k * 0.32)\n\t\t\t\t.cubicBezierTo(w, k * 1.2, o * 2.15, -k * 0.32, w, -k * 0.32)\n\t\t\t\t.cubicBezierTo(cx, h, w, k * 2.5, o * 2.5, k * 3)\n\t\t\t\t.close()\n\t\t},\n\t},\n} as const satisfies Record<string, GeoTypeDefinition>\n\n/**\n * Look up a geo type definition by name, checking custom types first then\n * falling back to the built-in registry.\n *\n * @public\n */\nexport function getGeoTypeDefinition(\n\tname: string,\n\tcustomGeoTypes?: Record<string, GeoTypeDefinition>\n): GeoTypeDefinition | undefined {\n\treturn (\n\t\tcustomGeoTypes?.[name] ?? (defaultGeoTypeDefinitions as Record<string, GeoTypeDefinition>)[name]\n\t)\n}\n\nconst pathCache = new WeakCache<TLGeoShape, PathBuilder>()\nexport function getGeoShapePath(\n\tshape: TLGeoShape,\n\tstrokeWidth: number,\n\tcustomGeoTypes?: Record<string, GeoTypeDefinition>\n) {\n\t// Cache is keyed on shape only. For x-box, strokeWidth affects the diagonal\n\t// inset, but theme changes are rare enough that stale cache entries are acceptable.\n\treturn pathCache.get(shape, (s) => _getGeoPath(s, strokeWidth, customGeoTypes))\n}\n\nfunction _getGeoPath(\n\tshape: TLGeoShape,\n\tstrokeWidth: number,\n\tcustomGeoTypes?: Record<string, GeoTypeDefinition>\n) {\n\tconst w = Math.max(1, shape.props.w)\n\tconst h = Math.max(1, shape.props.h + shape.props.growY)\n\tconst sw = strokeWidth * shape.props.scale\n\n\tconst def = getGeoTypeDefinition(shape.props.geo, customGeoTypes)\n\tif (!def) {\n\t\tthrow new Error(`Unknown geo type: ${shape.props.geo}`)\n\t}\n\n\tconst path = def.getPath(w, h, shape, sw)\n\n\t// Mirror the geometry when the shape is flipped. We flip the path itself (rather than only the\n\t// rendered output) so that geometry, hit-testing, the selection indicator, and SVG export all\n\t// stay consistent. The label lives in its own container and is intentionally left unflipped so\n\t// text stays upright and readable.\n\tconst { flipX, flipY } = shape.props\n\tif (flipX || flipY) {\n\t\treturn path.transform(getFlipMatrix({ flipX, flipY }, w, h))\n\t}\n\n\treturn path\n}\n\nfunction getXBoxPath(\n\tw: number,\n\th: number,\n\tsw: number,\n\tdash: TLDefaultDashStyle,\n\tisFilled: boolean\n) {\n\tconst cx = w / 2\n\tconst cy = h / 2\n\n\tconst path = new PathBuilder()\n\t\t.moveTo(0, 0, { geometry: { isFilled } })\n\t\t.lineTo(w, 0)\n\t\t.lineTo(w, h)\n\t\t.lineTo(0, h)\n\t\t.close()\n\n\tif (dash === 'none') {\n\t\treturn path\n\t}\n\n\tif (dash === 'dashed' || dash === 'dotted') {\n\t\treturn path\n\t\t\t.moveTo(0, 0, {\n\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\tdashStart: 'skip',\n\t\t\t\tdashEnd: 'outset',\n\t\t\t})\n\t\t\t.lineTo(cx, cy)\n\t\t\t.moveTo(w, h, {\n\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\tdashStart: 'skip',\n\t\t\t\tdashEnd: 'outset',\n\t\t\t})\n\t\t\t.lineTo(cx, cy)\n\t\t\t.moveTo(0, h, {\n\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\tdashStart: 'skip',\n\t\t\t\tdashEnd: 'outset',\n\t\t\t})\n\t\t\t.lineTo(cx, cy)\n\t\t\t.moveTo(w, 0, {\n\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\tdashStart: 'skip',\n\t\t\t\tdashEnd: 'outset',\n\t\t\t})\n\t\t\t.lineTo(cx, cy)\n\t}\n\n\tconst inset = dash === 'draw' ? 0.62 : 0\n\n\tpath\n\t\t.moveTo(clamp(sw * inset, 0, w), clamp(sw * inset, 0, h), {\n\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t})\n\t\t.lineTo(clamp(w - sw * inset, 0, w), clamp(h - sw * inset, 0, h))\n\t\t.moveTo(clamp(w - sw * inset, 0, w), clamp(sw * inset, 0, h))\n\t\t.lineTo(clamp(sw * inset, 0, w), clamp(h - sw * inset, 0, h))\n\n\treturn path\n}\n\nfunction getStadiumPath(w: number, h: number, isFilled: boolean) {\n\t// stadium:\n\tif (h > w) {\n\t\tconst r = w / 2\n\t\treturn new PathBuilder()\n\t\t\t.moveTo(0, r, { geometry: { isFilled } })\n\t\t\t.arcTo(r, r, false, true, 0, w, r)\n\t\t\t.lineTo(w, h - r)\n\t\t\t.arcTo(r, r, false, true, 0, 0, h - r)\n\t\t\t.close()\n\t}\n\n\tconst r = h / 2\n\treturn new PathBuilder()\n\t\t.moveTo(r, h, { geometry: { isFilled } })\n\t\t.arcTo(r, r, false, true, 0, r, 0)\n\t\t.lineTo(w - r, 0)\n\t\t.arcTo(r, r, false, true, 0, w - r, h)\n\t\t.close()\n}\n\nfunction getStarPath(w: number, h: number, isFilled: boolean) {\n\t// Most of this code is to offset the center, a 5 point star\n\t// will need to be moved downward because from its center [0,0]\n\t// it will have a bigger minY than maxY. This is because it'll\n\t// have 2 points at the bottom.\n\tconst sides = 5\n\tconst step = PI2 / sides / 2\n\tconst rightMostIndex = Math.floor(sides / 4) * 2\n\tconst leftMostIndex = sides * 2 - rightMostIndex\n\tconst topMostIndex = 0\n\tconst bottomMostIndex = Math.floor(sides / 2) * 2\n\tconst maxX = (Math.cos(-HALF_PI + rightMostIndex * step) * w) / 2\n\tconst minX = (Math.cos(-HALF_PI + leftMostIndex * step) * w) / 2\n\n\tconst minY = (Math.sin(-HALF_PI + topMostIndex * step) * h) / 2\n\tconst maxY = (Math.sin(-HALF_PI + bottomMostIndex * step) * h) / 2\n\tconst diffX = w - Math.abs(maxX - minX)\n\tconst diffY = h - Math.abs(maxY - minY)\n\tconst offsetX = w / 2 + minX - (w / 2 - maxX)\n\tconst offsetY = h / 2 + minY - (h / 2 - maxY)\n\n\tconst ratio = 1\n\tconst cx = (w - offsetX) / 2\n\tconst cy = (h - offsetY) / 2\n\tconst ox = (w + diffX) / 2\n\tconst oy = (h + diffY) / 2\n\tconst ix = (ox * ratio) / 2\n\tconst iy = (oy * ratio) / 2\n\n\treturn PathBuilder.lineThroughPoints(\n\t\tArray.from(Array(sides * 2), (_, i) => {\n\t\t\tconst theta = -HALF_PI + i * step\n\t\t\treturn new Vec(\n\t\t\t\tcx + (i % 2 ? ix : ox) * Math.cos(theta),\n\t\t\t\tcy + (i % 2 ? iy : oy) * Math.sin(theta)\n\t\t\t)\n\t\t}),\n\t\t{ geometry: { isFilled } }\n\t).close()\n}\n\n/* ---------------------- Cloud --------------------- */\n\nfunction getOvalPerimeter(h: number, w: number) {\n\tif (h > w) return (PI * (w / 2) + (h - w)) * 2\n\telse return (PI * (h / 2) + (w - h)) * 2\n}\n\ntype PillSection =\n\t| {\n\t\t\ttype: 'straight'\n\t\t\tstart: VecModel\n\t\t\tdelta: VecModel\n\t }\n\t| {\n\t\t\ttype: 'arc'\n\t\t\tcenter: VecModel\n\t\t\tstartAngle: number\n\t }\n\nfunction getPillPoints(width: number, height: number, numPoints: number) {\n\tconst radius = Math.min(width, height) / 2\n\tconst longSide = Math.max(width, height) - radius * 2\n\tconst circumference = Math.PI * (radius * 2) + 2 * longSide\n\tconst spacing = circumference / numPoints\n\n\tconst sections: PillSection[] =\n\t\twidth > height\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\tstart: new Vec(radius, 0),\n\t\t\t\t\t\tdelta: new Vec(1, 0),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'arc',\n\t\t\t\t\t\tcenter: new Vec(width - radius, radius),\n\t\t\t\t\t\tstartAngle: -PI / 2,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\tstart: new Vec(width - radius, height),\n\t\t\t\t\t\tdelta: new Vec(-1, 0),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'arc',\n\t\t\t\t\t\tcenter: new Vec(radius, radius),\n\t\t\t\t\t\tstartAngle: PI / 2,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\tstart: new Vec(width, radius),\n\t\t\t\t\t\tdelta: new Vec(0, 1),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'arc',\n\t\t\t\t\t\tcenter: new Vec(radius, height - radius),\n\t\t\t\t\t\tstartAngle: 0,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\tstart: new Vec(0, height - radius),\n\t\t\t\t\t\tdelta: new Vec(0, -1),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'arc',\n\t\t\t\t\t\tcenter: new Vec(radius, radius),\n\t\t\t\t\t\tstartAngle: PI,\n\t\t\t\t\t},\n\t\t\t\t]\n\n\tlet sectionOffset = 0\n\n\tconst points: Vec[] = []\n\tfor (let i = 0; i < numPoints; i++) {\n\t\tconst section = sections[0]\n\t\tif (section.type === 'straight') {\n\t\t\tpoints.push(Vec.Add(section.start, Vec.Mul(section.delta, sectionOffset)))\n\t\t} else {\n\t\t\tpoints.push(\n\t\t\t\tgetPointOnCircle(section.center, radius, section.startAngle + sectionOffset / radius)\n\t\t\t)\n\t\t}\n\t\tsectionOffset += spacing\n\t\tlet sectionLength = section.type === 'straight' ? longSide : PI * radius\n\t\twhile (sectionOffset > sectionLength) {\n\t\t\tsectionOffset -= sectionLength\n\t\t\tsections.push(sections.shift()!)\n\t\t\tsectionLength = sections[0].type === 'straight' ? longSide : PI * radius\n\t\t}\n\t}\n\n\treturn points\n}\n\nconst SIZES: Record<TLDefaultSizeStyle, number> = {\n\ts: 50,\n\tm: 70,\n\tl: 100,\n\txl: 130,\n}\n\nconst BUMP_PROTRUSION = 0.2\n\nfunction getCloudPath(\n\twidth: number,\n\theight: number,\n\tseed: string,\n\tsize: TLDefaultSizeStyle,\n\tscale: number,\n\tisFilled: boolean\n) {\n\tconst path = new PathBuilder()\n\tconst getRandom = rng(seed)\n\tconst pillCircumference = getOvalPerimeter(width, height)\n\tconst numBumps = Math.max(\n\t\tMath.ceil(pillCircumference / SIZES[size]),\n\t\t6,\n\t\tMath.ceil(pillCircumference / Math.min(width, height))\n\t)\n\tconst targetBumpProtrusion = (pillCircumference / numBumps) * BUMP_PROTRUSION\n\n\t// if the aspect ratio is high, innerWidth should be smaller\n\tconst innerWidth = Math.max(width - targetBumpProtrusion * 2, 1)\n\tconst innerHeight = Math.max(height - targetBumpProtrusion * 2, 1)\n\tconst innerCircumference = getOvalPerimeter(innerWidth, innerHeight)\n\n\tconst distanceBetweenPointsOnPerimeter = innerCircumference / numBumps\n\n\tconst paddingX = (width - innerWidth) / 2\n\tconst paddingY = (height - innerHeight) / 2\n\tconst bumpPoints = getPillPoints(innerWidth, innerHeight, numBumps).map((p) => {\n\t\treturn p.addXY(paddingX, paddingY)\n\t})\n\tconst maxWiggleX = width < 20 ? 0 : targetBumpProtrusion * 0.3\n\tconst maxWiggleY = height < 20 ? 0 : targetBumpProtrusion * 0.3\n\n\t// wiggle the points from either end so that the bumps 'pop'\n\t// in at the bottom-right and the top-left looks relatively stable\n\t// note: it's important that we don't mutate here! these points are also the bump points\n\tconst wiggledPoints = bumpPoints.slice(0)\n\tfor (let i = 0; i < Math.floor(numBumps / 2); i++) {\n\t\twiggledPoints[i] = Vec.AddXY(\n\t\t\twiggledPoints[i],\n\t\t\tgetRandom() * maxWiggleX * scale,\n\t\t\tgetRandom() * maxWiggleY * scale\n\t\t)\n\t\twiggledPoints[numBumps - i - 1] = Vec.AddXY(\n\t\t\twiggledPoints[numBumps - i - 1],\n\t\t\tgetRandom() * maxWiggleX * scale,\n\t\t\tgetRandom() * maxWiggleY * scale\n\t\t)\n\t}\n\n\tfor (let i = 0; i < wiggledPoints.length; i++) {\n\t\tconst j = i === wiggledPoints.length - 1 ? 0 : i + 1\n\t\tconst leftWigglePoint = wiggledPoints[i]\n\t\tconst rightWigglePoint = wiggledPoints[j]\n\t\tconst leftPoint = bumpPoints[i]\n\t\tconst rightPoint = bumpPoints[j]\n\n\t\t// when the points are on the curvy part of a pill, there is a natural arc that we need to extends past\n\t\t// otherwise it looks like the bumps get less bumpy on the curvy parts\n\t\tconst distanceBetweenOriginalPoints = Vec.Dist(leftPoint, rightPoint)\n\t\tconst curvatureOffset = distanceBetweenPointsOnPerimeter - distanceBetweenOriginalPoints\n\t\tconst distanceBetweenWigglePoints = Vec.Dist(leftWigglePoint, rightWigglePoint)\n\t\tconst relativeSize = distanceBetweenWigglePoints / distanceBetweenOriginalPoints\n\t\tconst finalDistance = (Math.max(paddingX, paddingY) + curvatureOffset) * relativeSize\n\n\t\tconst arcPoint = Vec.Lrp(leftPoint, rightPoint, 0.5).add(\n\t\t\tVec.Sub(rightPoint, leftPoint).uni().per().mul(finalDistance)\n\t\t)\n\t\tif (arcPoint.x < 0) {\n\t\t\tarcPoint.x = 0\n\t\t} else if (arcPoint.x > width) {\n\t\t\tarcPoint.x = width\n\t\t}\n\t\tif (arcPoint.y < 0) {\n\t\t\tarcPoint.y = 0\n\t\t} else if (arcPoint.y > height) {\n\t\t\tarcPoint.y = height\n\t\t}\n\n\t\tconst center = centerOfCircleFromThreePoints(leftWigglePoint, rightWigglePoint, arcPoint)\n\n\t\tconst radius = Vec.Dist(\n\t\t\tcenter ? center : Vec.Average([leftWigglePoint, rightWigglePoint]),\n\t\t\tleftWigglePoint\n\t\t)\n\n\t\tif (i === 0) {\n\t\t\tpath.moveTo(leftWigglePoint.x, leftWigglePoint.y, { geometry: { isFilled } })\n\t\t}\n\n\t\tpath.circularArcTo(radius, false, true, rightWigglePoint.x, rightWigglePoint.y)\n\t}\n\n\treturn path.close()\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAeO;AACP,kBAA8B;AAC9B,yBAA4B;AA8CrB,MAAM,4BAA4B;AAAA,EACxC,WAAW;AAAA,IACV,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ,GAAG,GAAG,OAAO;AACpB,YAAM,WAAW,MAAM,MAAM,SAAS;AACtC,aAAO,IAAI,+BAAY,EACrB,OAAO,GAAG,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,EACvC,OAAO,GAAG,CAAC,EACX,OAAO,GAAG,CAAC,EACX,OAAO,GAAG,CAAC,EACX,MAAM;AAAA,IACT;AAAA,EACD;AAAA,EACA,SAAS;AAAA,IACR,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ,GAAG,GAAG,OAAO;AACpB,YAAM,WAAW,MAAM,MAAM,SAAS;AACtC,YAAM,KAAK,IAAI;AACf,YAAM,KAAK,IAAI;AACf,aAAO,IAAI,+BAAY,EACrB,OAAO,GAAG,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,EACxC,MAAM,IAAI,IAAI,OAAO,MAAM,GAAG,GAAG,EAAE,EACnC,MAAM,IAAI,IAAI,OAAO,MAAM,GAAG,GAAG,EAAE,EACnC,MAAM;AAAA,IACT;AAAA,EACD;AAAA,EACA,UAAU;AAAA,IACT,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ,GAAG,GAAG,OAAO;AACpB,YAAM,WAAW,MAAM,MAAM,SAAS;AACtC,YAAM,KAAK,IAAI;AACf,aAAO,IAAI,+BAAY,EACrB,OAAO,IAAI,GAAG,EAAE,UAAU,EAAE,SAAS,EA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,eAAS,IAAI;AAAA,IACd,WAAW,SAAS,IAAI,OAAO;AAC9B,eAAS,IAAI;AAAA,IACd;AACA,QAAI,SAAS,IAAI,GAAG;AACnB,eAAS,IAAI;AAAA,IACd,WAAW,SAAS,IAAI,QAAQ;AAC/B,eAAS,IAAI;AAAA,IACd;AAEA,UAAM,aAAS,6CAA8B,iBAAiB,kBAAkB,QAAQ;AAExF,UAAM,SAAS,kBAAI;AAAA,MAClB,SAAS,SAAS,kBAAI,QAAQ,CAAC,iBAAiB,gBAAgB,CAAC;AAAA,MACjE;AAAA,IACD;AAEA,QAAI,MAAM,GAAG;AACZ,WAAK,OAAO,gBAAgB,GAAG,gBAAgB,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAAA,IAC7E;AAEA,SAAK,cAAc,QAAQ,OAAO,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAAA,EAC/E;AAEA,SAAO,KAAK,MAAM;AACnB;",
|
|
4
|
+
"sourcesContent": ["import {\n\tcenterOfCircleFromThreePoints,\n\tclamp,\n\tgetPointOnCircle,\n\tgetPolygonVertices,\n\tHALF_PI,\n\tPI,\n\tPI2,\n\trng,\n\tTLDefaultDashStyle,\n\tTLDefaultSizeStyle,\n\tTLGeoShape,\n\tVec,\n\tVecModel,\n\tWeakCache,\n} from '@tldraw/editor'\nimport { getFlipMatrix } from '../shared/flip'\nimport { PathBuilder } from '../shared/PathBuilder'\n\n/**\n * Defines the behavior for a geo shape type. Every built-in geo type is\n * registered through this same interface (see {@link defaultGeoTypeDefinitions}),\n * and consumers can register additional types via\n * {@link @tldraw/tldraw#GeoShapeUtil.configure | GeoShapeUtil.configure()}.\n *\n * @public\n */\nexport interface GeoTypeDefinition {\n\t/**\n\t * Generate the path geometry for this geo type.\n\t *\n\t * @param w - The width of the shape (already clamped to min 1)\n\t * @param h - The height of the shape (already clamped to min 1, includes growY)\n\t * @param shape - The full geo shape record, for access to props like id, dash, fill, etc.\n\t * @param strokeWidth - The scaled stroke width (strokeWidth * scale)\n\t */\n\tgetPath(w: number, h: number, shape: TLGeoShape, strokeWidth: number): PathBuilder\n\t/** Snap behavior: 'polygon' snaps to vertices + center, 'blobby' snaps to center only. */\n\tsnapType: 'polygon' | 'blobby'\n\t/** Default creation size when clicking (not dragging). Defaults to 200x200. */\n\tdefaultSize?: { w: number; h: number }\n\t/** Icon name for the style panel geo picker. */\n\ticon: string\n\t/**\n\t * Optional double-click handler. Return an object with partial props to update the shape,\n\t * or void to do nothing.\n\t */\n\tonDoubleClick?(shape: TLGeoShape): { props: Partial<TLGeoShape['props']> } | void\n}\n\n/**\n * Built-in geo type definitions keyed by their `geo` prop value. Every default\n * geo type (rectangle, ellipse, cloud, etc.) is registered here. The same\n * registry powers path generation, handle snapping, the style panel picker,\n * and creation defaults \u2014 so custom types added through\n * {@link @tldraw/tldraw#GeoShapeUtil.configure | GeoShapeUtil.configure()} get\n * the same treatment as the built-ins.\n *\n * The key order here defines the visual order of items in the geo style panel\n * picker.\n *\n * @public\n */\nexport const defaultGeoTypeDefinitions = {\n\trectangle: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-rectangle',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, 0)\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\tellipse: {\n\t\tsnapType: 'blobby',\n\t\ticon: 'geo-ellipse',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst cx = w / 2\n\t\t\tconst cy = h / 2\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, cy, { geometry: { isFilled } })\n\t\t\t\t.arcTo(cx, cy, false, true, 0, w, cy)\n\t\t\t\t.arcTo(cx, cy, false, true, 0, 0, cy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\ttriangle: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-triangle',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst cx = w / 2\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(cx, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\tdiamond: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-diamond',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst cx = w / 2\n\t\t\tconst cy = h / 2\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(cx, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, cy)\n\t\t\t\t.lineTo(cx, h)\n\t\t\t\t.lineTo(0, cy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\tstar: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-star',\n\t\tdefaultSize: { w: 200, h: 190 },\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn getStarPath(w, h, isFilled)\n\t\t},\n\t},\n\tpentagon: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-pentagon',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn PathBuilder.lineThroughPoints(getPolygonVertices(w, h, 5), {\n\t\t\t\tgeometry: { isFilled },\n\t\t\t}).close()\n\t\t},\n\t},\n\thexagon: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-hexagon',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn PathBuilder.lineThroughPoints(getPolygonVertices(w, h, 6), {\n\t\t\t\tgeometry: { isFilled },\n\t\t\t}).close()\n\t\t},\n\t},\n\toctagon: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-octagon',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn PathBuilder.lineThroughPoints(getPolygonVertices(w, h, 8), {\n\t\t\t\tgeometry: { isFilled },\n\t\t\t}).close()\n\t\t},\n\t},\n\trhombus: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-rhombus',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst offset = Math.min(w * 0.38, h * 0.38)\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(offset, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, 0)\n\t\t\t\t.lineTo(w - offset, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'rhombus-2': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-rhombus-2',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst offset = Math.min(w * 0.38, h * 0.38)\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w - offset, 0)\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(offset, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\toval: {\n\t\tsnapType: 'blobby',\n\t\ticon: 'geo-oval',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn getStadiumPath(w, h, isFilled)\n\t\t},\n\t},\n\ttrapezoid: {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-trapezoid',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst offset = Math.min(w * 0.38, h * 0.38)\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(offset, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w - offset, 0)\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'arrow-left': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-arrow-left',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst ox = Math.min(w, h) * 0.38\n\t\t\tconst oy = h * 0.16\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(ox, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(ox, oy)\n\t\t\t\t.lineTo(w, oy)\n\t\t\t\t.lineTo(w, h - oy)\n\t\t\t\t.lineTo(ox, h - oy)\n\t\t\t\t.lineTo(ox, h)\n\t\t\t\t.lineTo(0, h / 2)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'arrow-up': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-arrow-up',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst ox = w * 0.16\n\t\t\tconst oy = Math.min(w, h) * 0.38\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(w / 2, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, oy)\n\t\t\t\t.lineTo(w - ox, oy)\n\t\t\t\t.lineTo(w - ox, h)\n\t\t\t\t.lineTo(ox, h)\n\t\t\t\t.lineTo(ox, oy)\n\t\t\t\t.lineTo(0, oy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'arrow-down': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-arrow-down',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst ox = w * 0.16\n\t\t\tconst oy = Math.min(w, h) * 0.38\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(ox, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w - ox, 0)\n\t\t\t\t.lineTo(w - ox, h - oy)\n\t\t\t\t.lineTo(w, h - oy)\n\t\t\t\t.lineTo(w / 2, h)\n\t\t\t\t.lineTo(0, h - oy)\n\t\t\t\t.lineTo(ox, h - oy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\t'arrow-right': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-arrow-right',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst ox = Math.min(w, h) * 0.38\n\t\t\tconst oy = h * 0.16\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, oy, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w - ox, oy)\n\t\t\t\t.lineTo(w - ox, 0)\n\t\t\t\t.lineTo(w, h / 2)\n\t\t\t\t.lineTo(w - ox, h)\n\t\t\t\t.lineTo(w - ox, h - oy)\n\t\t\t\t.lineTo(0, h - oy)\n\t\t\t\t.close()\n\t\t},\n\t},\n\tcloud: {\n\t\tsnapType: 'blobby',\n\t\ticon: 'geo-cloud',\n\t\tdefaultSize: { w: 300, h: 180 },\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn getCloudPath(w, h, shape.id, shape.props.size, shape.props.scale, isFilled)\n\t\t},\n\t},\n\t'x-box': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-x-box',\n\t\tgetPath(w, h, shape, strokeWidth) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\treturn getXBoxPath(w, h, strokeWidth, shape.props.dash, isFilled)\n\t\t},\n\t},\n\t'check-box': {\n\t\tsnapType: 'polygon',\n\t\ticon: 'geo-check-box',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst size = Math.min(w, h) * 0.82\n\t\t\tconst ox = (w - size) / 2\n\t\t\tconst oy = (h - size) / 2\n\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(0, 0, { geometry: { isFilled } })\n\t\t\t\t.lineTo(w, 0)\n\t\t\t\t.lineTo(w, h)\n\t\t\t\t.lineTo(0, h)\n\t\t\t\t.close()\n\t\t\t\t.moveTo(clamp(ox + size * 0.25, 0, w), clamp(oy + size * 0.52, 0, h), {\n\t\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\t\toffset: 0,\n\t\t\t\t})\n\t\t\t\t.lineTo(clamp(ox + size * 0.45, 0, w), clamp(oy + size * 0.82, 0, h))\n\t\t\t\t.lineTo(clamp(ox + size * 0.82, 0, w), clamp(oy + size * 0.22, 0, h), { offset: 0 })\n\t\t},\n\t},\n\theart: {\n\t\tsnapType: 'blobby',\n\t\ticon: 'geo-heart',\n\t\tgetPath(w, h, shape) {\n\t\t\tconst isFilled = shape.props.fill !== 'none'\n\t\t\tconst cx = w / 2\n\t\t\tconst o = w / 4\n\t\t\tconst k = h / 4\n\t\t\treturn new PathBuilder()\n\t\t\t\t.moveTo(cx, h, { geometry: { isFilled } })\n\t\t\t\t.cubicBezierTo(0, k * 1.2, o * 1.5, k * 3, 0, k * 2.5)\n\t\t\t\t.cubicBezierTo(cx, k * 0.9, 0, -k * 0.32, o * 1.85, -k * 0.32)\n\t\t\t\t.cubicBezierTo(w, k * 1.2, o * 2.15, -k * 0.32, w, -k * 0.32)\n\t\t\t\t.cubicBezierTo(cx, h, w, k * 2.5, o * 2.5, k * 3)\n\t\t\t\t.close()\n\t\t},\n\t},\n} as const satisfies Record<string, GeoTypeDefinition>\n\n/**\n * Look up a geo type definition by name, checking custom types first then\n * falling back to the built-in registry.\n *\n * @public\n */\nexport function getGeoTypeDefinition(\n\tname: string,\n\tcustomGeoTypes?: Record<string, GeoTypeDefinition>\n): GeoTypeDefinition | undefined {\n\treturn (\n\t\tcustomGeoTypes?.[name] ?? (defaultGeoTypeDefinitions as Record<string, GeoTypeDefinition>)[name]\n\t)\n}\n\nconst pathCache = new WeakCache<TLGeoShape, PathBuilder>()\nexport function getGeoShapePath(\n\tshape: TLGeoShape,\n\tstrokeWidth: number,\n\tcustomGeoTypes?: Record<string, GeoTypeDefinition>\n) {\n\t// Cache is keyed on shape only. For x-box, strokeWidth affects the diagonal\n\t// inset, but theme changes are rare enough that stale cache entries are acceptable.\n\treturn pathCache.get(shape, (s) => _getGeoPath(s, strokeWidth, customGeoTypes))\n}\n\nfunction _getGeoPath(\n\tshape: TLGeoShape,\n\tstrokeWidth: number,\n\tcustomGeoTypes?: Record<string, GeoTypeDefinition>\n) {\n\tconst w = Math.max(1, shape.props.w)\n\tconst h = Math.max(1, shape.props.h + shape.props.growY)\n\tconst sw = strokeWidth * shape.props.scale\n\n\tconst def = getGeoTypeDefinition(shape.props.geo, customGeoTypes)\n\tif (!def) {\n\t\tthrow new Error(`Unknown geo type: ${shape.props.geo}`)\n\t}\n\n\tconst path = def.getPath(w, h, shape, sw)\n\n\t// Mirror the geometry when the shape is flipped. We flip the path itself (rather than only the\n\t// rendered output) so that geometry, hit-testing, the selection indicator, and SVG export all\n\t// stay consistent. The label lives in its own container and is intentionally left unflipped so\n\t// text stays upright and readable.\n\tconst { flipX, flipY } = shape.props\n\tif (flipX || flipY) {\n\t\treturn path.transform(getFlipMatrix({ flipX, flipY }, w, h))\n\t}\n\n\treturn path\n}\n\nfunction getXBoxPath(\n\tw: number,\n\th: number,\n\tsw: number,\n\tdash: TLDefaultDashStyle,\n\tisFilled: boolean\n) {\n\tconst cx = w / 2\n\tconst cy = h / 2\n\n\tconst path = new PathBuilder()\n\t\t.moveTo(0, 0, { geometry: { isFilled } })\n\t\t.lineTo(w, 0)\n\t\t.lineTo(w, h)\n\t\t.lineTo(0, h)\n\t\t.close()\n\n\tif (dash === 'none') {\n\t\treturn path\n\t}\n\n\tif (dash === 'dashed' || dash === 'dotted') {\n\t\treturn path\n\t\t\t.moveTo(0, 0, {\n\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\tdashStart: 'skip',\n\t\t\t\tdashEnd: 'outset',\n\t\t\t})\n\t\t\t.lineTo(cx, cy)\n\t\t\t.moveTo(w, h, {\n\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\tdashStart: 'skip',\n\t\t\t\tdashEnd: 'outset',\n\t\t\t})\n\t\t\t.lineTo(cx, cy)\n\t\t\t.moveTo(0, h, {\n\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\tdashStart: 'skip',\n\t\t\t\tdashEnd: 'outset',\n\t\t\t})\n\t\t\t.lineTo(cx, cy)\n\t\t\t.moveTo(w, 0, {\n\t\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t\t\tdashStart: 'skip',\n\t\t\t\tdashEnd: 'outset',\n\t\t\t})\n\t\t\t.lineTo(cx, cy)\n\t}\n\n\tconst inset = dash === 'draw' ? 0.62 : 0\n\n\tpath\n\t\t.moveTo(clamp(sw * inset, 0, w), clamp(sw * inset, 0, h), {\n\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t})\n\t\t.lineTo(clamp(w - sw * inset, 0, w), clamp(h - sw * inset, 0, h))\n\t\t.moveTo(clamp(w - sw * inset, 0, w), clamp(sw * inset, 0, h), {\n\t\t\tgeometry: { isInternal: true, isFilled: false },\n\t\t})\n\t\t.lineTo(clamp(sw * inset, 0, w), clamp(h - sw * inset, 0, h))\n\n\treturn path\n}\n\nfunction getStadiumPath(w: number, h: number, isFilled: boolean) {\n\t// stadium:\n\tif (h > w) {\n\t\tconst r = w / 2\n\t\treturn new PathBuilder()\n\t\t\t.moveTo(0, r, { geometry: { isFilled } })\n\t\t\t.arcTo(r, r, false, true, 0, w, r)\n\t\t\t.lineTo(w, h - r)\n\t\t\t.arcTo(r, r, false, true, 0, 0, h - r)\n\t\t\t.close()\n\t}\n\n\tconst r = h / 2\n\treturn new PathBuilder()\n\t\t.moveTo(r, h, { geometry: { isFilled } })\n\t\t.arcTo(r, r, false, true, 0, r, 0)\n\t\t.lineTo(w - r, 0)\n\t\t.arcTo(r, r, false, true, 0, w - r, h)\n\t\t.close()\n}\n\nfunction getStarPath(w: number, h: number, isFilled: boolean) {\n\t// Most of this code is to offset the center, a 5 point star\n\t// will need to be moved downward because from its center [0,0]\n\t// it will have a bigger minY than maxY. This is because it'll\n\t// have 2 points at the bottom.\n\tconst sides = 5\n\tconst step = PI2 / sides / 2\n\tconst rightMostIndex = Math.floor(sides / 4) * 2\n\tconst leftMostIndex = sides * 2 - rightMostIndex\n\tconst topMostIndex = 0\n\tconst bottomMostIndex = Math.floor(sides / 2) * 2\n\tconst maxX = (Math.cos(-HALF_PI + rightMostIndex * step) * w) / 2\n\tconst minX = (Math.cos(-HALF_PI + leftMostIndex * step) * w) / 2\n\n\tconst minY = (Math.sin(-HALF_PI + topMostIndex * step) * h) / 2\n\tconst maxY = (Math.sin(-HALF_PI + bottomMostIndex * step) * h) / 2\n\tconst diffX = w - Math.abs(maxX - minX)\n\tconst diffY = h - Math.abs(maxY - minY)\n\tconst offsetX = w / 2 + minX - (w / 2 - maxX)\n\tconst offsetY = h / 2 + minY - (h / 2 - maxY)\n\n\tconst ratio = 1\n\tconst cx = (w - offsetX) / 2\n\tconst cy = (h - offsetY) / 2\n\tconst ox = (w + diffX) / 2\n\tconst oy = (h + diffY) / 2\n\tconst ix = (ox * ratio) / 2\n\tconst iy = (oy * ratio) / 2\n\n\treturn PathBuilder.lineThroughPoints(\n\t\tArray.from(Array(sides * 2), (_, i) => {\n\t\t\tconst theta = -HALF_PI + i * step\n\t\t\treturn new Vec(\n\t\t\t\tcx + (i % 2 ? ix : ox) * Math.cos(theta),\n\t\t\t\tcy + (i % 2 ? iy : oy) * Math.sin(theta)\n\t\t\t)\n\t\t}),\n\t\t{ geometry: { isFilled } }\n\t).close()\n}\n\n/* ---------------------- Cloud --------------------- */\n\nfunction getOvalPerimeter(h: number, w: number) {\n\tif (h > w) return (PI * (w / 2) + (h - w)) * 2\n\telse return (PI * (h / 2) + (w - h)) * 2\n}\n\ntype PillSection =\n\t| {\n\t\t\ttype: 'straight'\n\t\t\tstart: VecModel\n\t\t\tdelta: VecModel\n\t }\n\t| {\n\t\t\ttype: 'arc'\n\t\t\tcenter: VecModel\n\t\t\tstartAngle: number\n\t }\n\nfunction getPillPoints(width: number, height: number, numPoints: number) {\n\tconst radius = Math.min(width, height) / 2\n\tconst longSide = Math.max(width, height) - radius * 2\n\tconst circumference = Math.PI * (radius * 2) + 2 * longSide\n\tconst spacing = circumference / numPoints\n\n\tconst sections: PillSection[] =\n\t\twidth > height\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\tstart: new Vec(radius, 0),\n\t\t\t\t\t\tdelta: new Vec(1, 0),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'arc',\n\t\t\t\t\t\tcenter: new Vec(width - radius, radius),\n\t\t\t\t\t\tstartAngle: -PI / 2,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\tstart: new Vec(width - radius, height),\n\t\t\t\t\t\tdelta: new Vec(-1, 0),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'arc',\n\t\t\t\t\t\tcenter: new Vec(radius, radius),\n\t\t\t\t\t\tstartAngle: PI / 2,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\tstart: new Vec(width, radius),\n\t\t\t\t\t\tdelta: new Vec(0, 1),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'arc',\n\t\t\t\t\t\tcenter: new Vec(radius, height - radius),\n\t\t\t\t\t\tstartAngle: 0,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'straight',\n\t\t\t\t\t\tstart: new Vec(0, height - radius),\n\t\t\t\t\t\tdelta: new Vec(0, -1),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'arc',\n\t\t\t\t\t\tcenter: new Vec(radius, radius),\n\t\t\t\t\t\tstartAngle: PI,\n\t\t\t\t\t},\n\t\t\t\t]\n\n\tlet sectionOffset = 0\n\n\tconst points: Vec[] = []\n\tfor (let i = 0; i < numPoints; i++) {\n\t\tconst section = sections[0]\n\t\tif (section.type === 'straight') {\n\t\t\tpoints.push(Vec.Add(section.start, Vec.Mul(section.delta, sectionOffset)))\n\t\t} else {\n\t\t\tpoints.push(\n\t\t\t\tgetPointOnCircle(section.center, radius, section.startAngle + sectionOffset / radius)\n\t\t\t)\n\t\t}\n\t\tsectionOffset += spacing\n\t\tlet sectionLength = section.type === 'straight' ? longSide : PI * radius\n\t\twhile (sectionOffset > sectionLength) {\n\t\t\tsectionOffset -= sectionLength\n\t\t\tsections.push(sections.shift()!)\n\t\t\tsectionLength = sections[0].type === 'straight' ? longSide : PI * radius\n\t\t}\n\t}\n\n\treturn points\n}\n\nconst SIZES: Record<TLDefaultSizeStyle, number> = {\n\ts: 50,\n\tm: 70,\n\tl: 100,\n\txl: 130,\n}\n\nconst BUMP_PROTRUSION = 0.2\n\nfunction getCloudPath(\n\twidth: number,\n\theight: number,\n\tseed: string,\n\tsize: TLDefaultSizeStyle,\n\tscale: number,\n\tisFilled: boolean\n) {\n\tconst path = new PathBuilder()\n\tconst getRandom = rng(seed)\n\tconst pillCircumference = getOvalPerimeter(width, height)\n\tconst numBumps = Math.max(\n\t\tMath.ceil(pillCircumference / SIZES[size]),\n\t\t6,\n\t\tMath.ceil(pillCircumference / Math.min(width, height))\n\t)\n\tconst targetBumpProtrusion = (pillCircumference / numBumps) * BUMP_PROTRUSION\n\n\t// if the aspect ratio is high, innerWidth should be smaller\n\tconst innerWidth = Math.max(width - targetBumpProtrusion * 2, 1)\n\tconst innerHeight = Math.max(height - targetBumpProtrusion * 2, 1)\n\tconst innerCircumference = getOvalPerimeter(innerWidth, innerHeight)\n\n\tconst distanceBetweenPointsOnPerimeter = innerCircumference / numBumps\n\n\tconst paddingX = (width - innerWidth) / 2\n\tconst paddingY = (height - innerHeight) / 2\n\tconst bumpPoints = getPillPoints(innerWidth, innerHeight, numBumps).map((p) => {\n\t\treturn p.addXY(paddingX, paddingY)\n\t})\n\tconst maxWiggleX = width < 20 ? 0 : targetBumpProtrusion * 0.3\n\tconst maxWiggleY = height < 20 ? 0 : targetBumpProtrusion * 0.3\n\n\t// wiggle the points from either end so that the bumps 'pop'\n\t// in at the bottom-right and the top-left looks relatively stable\n\t// note: it's important that we don't mutate here! these points are also the bump points\n\tconst wiggledPoints = bumpPoints.slice(0)\n\tfor (let i = 0; i < Math.floor(numBumps / 2); i++) {\n\t\twiggledPoints[i] = Vec.AddXY(\n\t\t\twiggledPoints[i],\n\t\t\tgetRandom() * maxWiggleX * scale,\n\t\t\tgetRandom() * maxWiggleY * scale\n\t\t)\n\t\twiggledPoints[numBumps - i - 1] = Vec.AddXY(\n\t\t\twiggledPoints[numBumps - i - 1],\n\t\t\tgetRandom() * maxWiggleX * scale,\n\t\t\tgetRandom() * maxWiggleY * scale\n\t\t)\n\t}\n\n\tfor (let i = 0; i < wiggledPoints.length; i++) {\n\t\tconst j = i === wiggledPoints.length - 1 ? 0 : i + 1\n\t\tconst leftWigglePoint = wiggledPoints[i]\n\t\tconst rightWigglePoint = wiggledPoints[j]\n\t\tconst leftPoint = bumpPoints[i]\n\t\tconst rightPoint = bumpPoints[j]\n\n\t\t// when the points are on the curvy part of a pill, there is a natural arc that we need to extends past\n\t\t// otherwise it looks like the bumps get less bumpy on the curvy parts\n\t\tconst distanceBetweenOriginalPoints = Vec.Dist(leftPoint, rightPoint)\n\t\tconst curvatureOffset = distanceBetweenPointsOnPerimeter - distanceBetweenOriginalPoints\n\t\tconst distanceBetweenWigglePoints = Vec.Dist(leftWigglePoint, rightWigglePoint)\n\t\tconst relativeSize = distanceBetweenWigglePoints / distanceBetweenOriginalPoints\n\t\tconst finalDistance = (Math.max(paddingX, paddingY) + curvatureOffset) * relativeSize\n\n\t\tconst arcPoint = Vec.Lrp(leftPoint, rightPoint, 0.5).add(\n\t\t\tVec.Sub(rightPoint, leftPoint).uni().per().mul(finalDistance)\n\t\t)\n\t\tif (arcPoint.x < 0) {\n\t\t\tarcPoint.x = 0\n\t\t} else if (arcPoint.x > width) {\n\t\t\tarcPoint.x = width\n\t\t}\n\t\tif (arcPoint.y < 0) {\n\t\t\tarcPoint.y = 0\n\t\t} else if (arcPoint.y > height) {\n\t\t\tarcPoint.y = height\n\t\t}\n\n\t\tconst center = centerOfCircleFromThreePoints(leftWigglePoint, rightWigglePoint, arcPoint)\n\n\t\tconst radius = Vec.Dist(\n\t\t\tcenter ? center : Vec.Average([leftWigglePoint, rightWigglePoint]),\n\t\t\tleftWigglePoint\n\t\t)\n\n\t\tif (i === 0) {\n\t\t\tpath.moveTo(leftWigglePoint.x, leftWigglePoint.y, { geometry: { isFilled } })\n\t\t}\n\n\t\tpath.circularArcTo(radius, false, true, rightWigglePoint.x, rightWigglePoint.y)\n\t}\n\n\treturn path.close()\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAeO;AACP,kBAA8B;AAC9B,yBAA4B;AA8CrB,MAAM,4BAA4B;AAAA,EACxC,WAAW;AAAA,IACV,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ,GAAG,GAAG,OAAO;AACpB,YAAM,WAAW,MAAM,MAAM,SAAS;AACtC,aAAO,IAAI,+BAAY,EACrB,OAAO,GAAG,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,EACvC,OAAO,GAAG,CAAC,EACX,OAAO,GAAG,CAAC,EACX,OAAO,GAAG,CAAC,EACX,MAAM;AAAA,IACT;AAAA,EACD;AAAA,EACA,SAAS;AAAA,IACR,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ,GAAG,GAAG,OAAO;AACpB,YAAM,WAAW,MAAM,MAAM,SAAS;AACtC,YAAM,KAAK,IA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= this;
|
|
36
36
|
if (info.key === "Enter") {
|
|
37
37
|
const onlySelectedShape = editor.getOnlySelectedShape();
|
|
38
|
-
if (editor.canEditShape(onlySelectedShape))
|
|
39
|
-
|
|
40
|
-
}
|
|
38
|
+
if (!editor.canEditShape(onlySelectedShape)) return;
|
|
39
|
+
(0, import_selectHelpers.startEditingShape)(editor, onlySelectedShape, { selectAll: true });
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
onCancel() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/shapes/geo/toolStates/Idle.ts"],
|
|
4
|
-
"sourcesContent": ["import { StateNode, TLKeyboardEventInfo, TLPointerEventInfo } from '@tldraw/editor'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmE;AACnE,
|
|
4
|
+
"sourcesContent": ["import { StateNode, TLKeyboardEventInfo, TLPointerEventInfo } from '@tldraw/editor'\nimport { startEditingShape } from '../../../tools/SelectTool/selectHelpers'\n\nexport class Idle extends StateNode {\n\tstatic override id = 'idle'\n\n\toverride onPointerDown(info: TLPointerEventInfo) {\n\t\tthis.parent.transition('pointing', info)\n\t}\n\n\toverride onEnter() {\n\t\tthis.editor.setCursor({ type: 'cross', rotation: 0 })\n\t}\n\n\toverride onKeyUp(info: TLKeyboardEventInfo) {\n\t\tconst { editor } = this\n\t\tif (info.key === 'Enter') {\n\t\t\tconst onlySelectedShape = editor.getOnlySelectedShape()\n\t\t\tif (!editor.canEditShape(onlySelectedShape)) return\n\t\t\tstartEditingShape(editor, onlySelectedShape, { selectAll: true })\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.editor.setCurrentTool('select')\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmE;AACnE,2BAAkC;AAE3B,MAAM,aAAa,wBAAU;AAAA,EACnC,OAAgB,KAAK;AAAA,EAEZ,cAAc,MAA0B;AAChD,SAAK,OAAO,WAAW,YAAY,IAAI;AAAA,EACxC;AAAA,EAES,UAAU;AAClB,SAAK,OAAO,UAAU,EAAE,MAAM,SAAS,UAAU,EAAE,CAAC;AAAA,EACrD;AAAA,EAES,QAAQ,MAA2B;AAC3C,UAAM,EAAE,OAAO,IAAI;AACnB,QAAI,KAAK,QAAQ,SAAS;AACzB,YAAM,oBAAoB,OAAO,qBAAqB;AACtD,UAAI,CAAC,OAAO,aAAa,iBAAiB,EAAG;AAC7C,kDAAkB,QAAQ,mBAAmB,EAAE,WAAW,KAAK,CAAC;AAAA,IACjE;AAAA,EACD;AAAA,EAES,WAAW;AACnB,SAAK,OAAO,eAAe,QAAQ;AAAA,EACpC;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/lib/shapes/geo/toolStates/Pointing.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tGeoShapeGeoStyle,\n\tStateNode,\n\tTLGeoShape,\n\tTLPointerEventInfo,\n\tVec,\n\tcreateShapeId,\n\tmaybeSnapToGrid,\n} from '@tldraw/editor'\nimport { GeoShapeUtil } from '../GeoShapeUtil'\nimport { getGeoTypeDefinition } from '../getGeoShapePath'\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onLongPress() {\n\t\t// On a touch (coarse pointer) long-press, cancel the pending shape so it leaves nothing behind.\n\t\tif (this.editor.getInstanceState().isCoarsePointer) this.cancel()\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\n\t\t\tconst id = createShapeId()\n\n\t\t\tconst creatingMarkId = this.editor.markHistoryStoppingPoint(`creating_geo:${id}`)\n\t\t\tconst newPoint = maybeSnapToGrid(originPagePoint, this.editor)\n\t\t\tthis.editor\n\t\t\t\t.createShapes([\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\t\ty: newPoint.y,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tw: 1,\n\t\t\t\t\t\t\th: 1,\n\t\t\t\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\t\t\t\tscale: this.editor.getResizeScaleFactor(),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\t.select(id)\n\n\t\t\tconst shape = this.editor.getShape(id)\n\t\t\tif (!shape) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.editor.setCurrentTool('select.resizing', {\n\t\t\t\t...info,\n\t\t\t\ttarget: 'selection',\n\t\t\t\thandle: 'bottom_right',\n\t\t\t\tisCreating: true,\n\t\t\t\tcreatingMarkId,\n\t\t\t\tcreationCursorOffset: { x: 1, y: 1 },\n\t\t\t\tonInteractionEnd: 'geo',\n\t\t\t})\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\tthis.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO;AAEP,6BAAqC;AAE9B,MAAM,iBAAiB,wBAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAEZ,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AAEtB,QAAI,KAAK,OAAO,iBAAiB,EAAE,gBAAiB,MAAK,OAAO;AAAA,EACjE;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC,YAAM,kBAAkB,KAAK,OAAO,OAAO,mBAAmB;AAE9D,YAAM,SAAK,6BAAc;AAEzB,YAAM,iBAAiB,KAAK,OAAO,yBAAyB,gBAAgB,EAAE,EAAE;AAChF,YAAM,eAAW,+BAAgB,iBAAiB,KAAK,MAAM;AAC7D,WAAK,OACH,aAAa;AAAA,QACb;AAAA,UACC;AAAA,UACA,MAAM;AAAA,UACN,GAAG,SAAS;AAAA,UACZ,GAAG,SAAS;AAAA,UACZ,OAAO;AAAA,YACN,GAAG;AAAA,YACH,GAAG;AAAA,YACH,KAAK,KAAK,OAAO,qBAAqB,8BAAgB;AAAA,YACtD,OAAO,KAAK,OAAO,qBAAqB;AAAA,UACzC;AAAA,QACD;AAAA,MACD,CAAC,EACA,OAAO,EAAE;AAEX,YAAM,QAAQ,KAAK,OAAO,SAAS,EAAE;AACrC,UAAI,CAAC,OAAO;AACX,aAAK,OAAO;AACZ;AAAA,MACD;AAEA,WAAK,OAAO,eAAe,mBAAmB;AAAA,QAC7C,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ;AAAA,QACA,sBAAsB,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,QACnC,kBAAkB;AAAA,MACnB,CAAC;AAAA,IACF;AAAA,EACD;AAAA,EAES,WAAW;AACnB,SAAK,OAAO;AAAA,EACb;AAAA,EAES,aAAa;
|
|
4
|
+
"sourcesContent": ["import {\n\tGeoShapeGeoStyle,\n\tStateNode,\n\tTLGeoShape,\n\tTLPointerEventInfo,\n\tVec,\n\tcreateShapeId,\n\tmaybeSnapToGrid,\n} from '@tldraw/editor'\nimport { GeoShapeUtil } from '../GeoShapeUtil'\nimport { getGeoTypeDefinition } from '../getGeoShapePath'\n\nexport class Pointing extends StateNode {\n\tstatic override id = 'pointing'\n\n\toverride onPointerUp() {\n\t\tthis.complete()\n\t}\n\n\toverride onLongPress() {\n\t\t// On a touch (coarse pointer) long-press, cancel the pending shape so it leaves nothing behind.\n\t\tif (this.editor.getInstanceState().isCoarsePointer) this.cancel()\n\t}\n\n\toverride onPointerMove(info: TLPointerEventInfo) {\n\t\tif (this.editor.inputs.getIsDragging()) {\n\t\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\n\t\t\tconst id = createShapeId()\n\n\t\t\tconst creatingMarkId = this.editor.markHistoryStoppingPoint(`creating_geo:${id}`)\n\t\t\tconst newPoint = maybeSnapToGrid(originPagePoint, this.editor)\n\t\t\tthis.editor\n\t\t\t\t.createShapes([\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\ttype: 'geo',\n\t\t\t\t\t\tx: newPoint.x,\n\t\t\t\t\t\ty: newPoint.y,\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tw: 1,\n\t\t\t\t\t\t\th: 1,\n\t\t\t\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\t\t\t\tscale: this.editor.getResizeScaleFactor(),\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t])\n\t\t\t\t.select(id)\n\n\t\t\tconst shape = this.editor.getShape(id)\n\t\t\tif (!shape) {\n\t\t\t\tthis.cancel()\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.editor.setCurrentTool('select.resizing', {\n\t\t\t\t...info,\n\t\t\t\ttarget: 'selection',\n\t\t\t\thandle: 'bottom_right',\n\t\t\t\tisCreating: true,\n\t\t\t\tcreatingMarkId,\n\t\t\t\tcreationCursorOffset: { x: 1, y: 1 },\n\t\t\t\tonInteractionEnd: 'geo',\n\t\t\t})\n\t\t}\n\t}\n\n\toverride onCancel() {\n\t\tthis.cancel()\n\t}\n\n\toverride onComplete() {\n\t\t// Not a release: see BaseBoxShapeTool's Pointing state for why this cancels.\n\t\tthis.cancel()\n\t}\n\n\toverride onInterrupt() {\n\t\tthis.cancel()\n\t}\n\n\tprivate complete() {\n\t\tconst originPagePoint = this.editor.inputs.getOriginPagePoint()\n\n\t\tconst id = createShapeId()\n\n\t\tthis.editor.markHistoryStoppingPoint(`creating_geo:${id}`)\n\n\t\tconst scale = this.editor.getResizeScaleFactor()\n\n\t\tconst geo = this.editor.getStyleForNextShape(GeoShapeGeoStyle)\n\t\tconst geoShapeUtil = this.editor.getShapeUtil<GeoShapeUtil>('geo')\n\n\t\tconst def = getGeoTypeDefinition(geo, geoShapeUtil.options.customGeoTypes)\n\t\tconst size = def?.defaultSize ?? { w: 200, h: 200 }\n\n\t\tthis.editor.createShapes([\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\ttype: 'geo',\n\t\t\t\tx: originPagePoint.x,\n\t\t\t\ty: originPagePoint.y,\n\t\t\t\tprops: {\n\t\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\t\tscale,\n\t\t\t\t\t...size,\n\t\t\t\t},\n\t\t\t},\n\t\t])\n\n\t\tconst shape = this.editor.getShape<TLGeoShape>(id)!\n\t\tif (!shape) {\n\t\t\tthis.cancel()\n\t\t\treturn\n\t\t}\n\n\t\tconst { w, h } = shape.props\n\n\t\tconst delta = new Vec(w / 2, h / 2).mul(scale)\n\t\tconst parentTransform = this.editor.getShapeParentTransform(shape)\n\t\tif (parentTransform) delta.rot(-parentTransform.rotation())\n\t\tconst newPoint = maybeSnapToGrid(new Vec(shape.x - delta.x, shape.y - delta.y), this.editor)\n\t\tthis.editor.select(id)\n\t\tthis.editor.updateShape({\n\t\t\tid: shape.id,\n\t\t\ttype: 'geo',\n\t\t\tx: newPoint.x,\n\t\t\ty: newPoint.y,\n\t\t\tprops: {\n\t\t\t\tgeo: this.editor.getStyleForNextShape(GeoShapeGeoStyle),\n\t\t\t\tw: w * scale,\n\t\t\t\th: h * scale,\n\t\t\t},\n\t\t})\n\n\t\tif (this.editor.getInstanceState().isToolLocked) {\n\t\t\tthis.parent.transition('idle')\n\t\t} else {\n\t\t\tthis.editor.setCurrentTool('select', {})\n\t\t}\n\t}\n\n\tprivate cancel() {\n\t\t// we should not have created any shapes yet, so no need to bail\n\t\tthis.parent.transition('idle')\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAQO;AAEP,6BAAqC;AAE9B,MAAM,iBAAiB,wBAAU;AAAA,EACvC,OAAgB,KAAK;AAAA,EAEZ,cAAc;AACtB,SAAK,SAAS;AAAA,EACf;AAAA,EAES,cAAc;AAEtB,QAAI,KAAK,OAAO,iBAAiB,EAAE,gBAAiB,MAAK,OAAO;AAAA,EACjE;AAAA,EAES,cAAc,MAA0B;AAChD,QAAI,KAAK,OAAO,OAAO,cAAc,GAAG;AACvC,YAAM,kBAAkB,KAAK,OAAO,OAAO,mBAAmB;AAE9D,YAAM,SAAK,6BAAc;AAEzB,YAAM,iBAAiB,KAAK,OAAO,yBAAyB,gBAAgB,EAAE,EAAE;AAChF,YAAM,eAAW,+BAAgB,iBAAiB,KAAK,MAAM;AAC7D,WAAK,OACH,aAAa;AAAA,QACb;AAAA,UACC;AAAA,UACA,MAAM;AAAA,UACN,GAAG,SAAS;AAAA,UACZ,GAAG,SAAS;AAAA,UACZ,OAAO;AAAA,YACN,GAAG;AAAA,YACH,GAAG;AAAA,YACH,KAAK,KAAK,OAAO,qBAAqB,8BAAgB;AAAA,YACtD,OAAO,KAAK,OAAO,qBAAqB;AAAA,UACzC;AAAA,QACD;AAAA,MACD,CAAC,EACA,OAAO,EAAE;AAEX,YAAM,QAAQ,KAAK,OAAO,SAAS,EAAE;AACrC,UAAI,CAAC,OAAO;AACX,aAAK,OAAO;AACZ;AAAA,MACD;AAEA,WAAK,OAAO,eAAe,mBAAmB;AAAA,QAC7C,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ;AAAA,QACA,sBAAsB,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,QACnC,kBAAkB;AAAA,MAC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