@yuzhouu/canvas-kit 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -78
- package/_vendor/canvas-core/bindings/bindingUtil.d.ts +45 -0
- package/_vendor/canvas-core/bindings/bindingUtilRegistry.d.ts +8 -0
- package/_vendor/canvas-core/bindings/terminalBinding.d.ts +28 -0
- package/_vendor/canvas-core/editor/camera.d.ts +3 -0
- package/_vendor/canvas-core/editor/clipboard.d.ts +43 -0
- package/_vendor/canvas-core/editor/commands.d.ts +131 -0
- package/_vendor/canvas-core/editor/createEditorWithPlugins.d.ts +6 -0
- package/_vendor/canvas-core/editor/edgeScroll.d.ts +5 -0
- package/_vendor/canvas-core/editor/editor.d.ts +559 -0
- package/_vendor/canvas-core/editor/editorComputedHelpers.d.ts +21 -0
- package/_vendor/canvas-core/editor/editorSelectionTransforms.d.ts +6 -0
- package/_vendor/canvas-core/editor/events.d.ts +71 -0
- package/_vendor/canvas-core/editor/historyManager.d.ts +18 -0
- package/_vendor/canvas-core/editor/index.d.ts +11 -0
- package/_vendor/canvas-core/editor/interactions.d.ts +51 -0
- package/_vendor/canvas-core/editor/internal.d.ts +7 -0
- package/_vendor/canvas-core/editor/managers/bindingManager.d.ts +27 -0
- package/_vendor/canvas-core/editor/managers/cameraManager.d.ts +39 -0
- package/_vendor/canvas-core/editor/managers/clipboardManager.d.ts +14 -0
- package/_vendor/canvas-core/editor/managers/documentSnapshotManager.d.ts +28 -0
- package/_vendor/canvas-core/editor/managers/inputsManager.d.ts +44 -0
- package/_vendor/canvas-core/editor/managers/interactionTransientManager.d.ts +55 -0
- package/_vendor/canvas-core/editor/managers/queryManager.d.ts +77 -0
- package/_vendor/canvas-core/editor/managers/queryState.d.ts +18 -0
- package/_vendor/canvas-core/editor/managers/renderWindowManager.d.ts +25 -0
- package/_vendor/canvas-core/editor/managers/selectionGeometry.d.ts +28 -0
- package/_vendor/canvas-core/editor/managers/selectionLayoutManager.d.ts +29 -0
- package/_vendor/canvas-core/editor/managers/selectionManager.d.ts +21 -0
- package/_vendor/canvas-core/editor/managers/selectionOverlayManager.d.ts +24 -0
- package/_vendor/canvas-core/editor/managers/shapeEditingManager.d.ts +29 -0
- package/_vendor/canvas-core/editor/managers/shapeGeometryManager.d.ts +42 -0
- package/_vendor/canvas-core/editor/managers/shapeHierarchyManager.d.ts +55 -0
- package/_vendor/canvas-core/editor/managers/shapeOrder.d.ts +14 -0
- package/_vendor/canvas-core/editor/managers/shapeReparenting.d.ts +6 -0
- package/_vendor/canvas-core/editor/managers/shortcutManager.d.ts +56 -0
- package/_vendor/canvas-core/editor/managers/sideEffectManager.d.ts +23 -0
- package/_vendor/canvas-core/editor/managers/snapCalculations.d.ts +40 -0
- package/_vendor/canvas-core/editor/managers/snapGeometry.d.ts +26 -0
- package/_vendor/canvas-core/editor/managers/snapIndicators.d.ts +22 -0
- package/_vendor/canvas-core/editor/managers/snapManager.d.ts +29 -0
- package/_vendor/canvas-core/editor/managers/snapSnapshotBuilder.d.ts +22 -0
- package/_vendor/canvas-core/editor/managers/snapTypes.d.ts +98 -0
- package/_vendor/canvas-core/editor/managers/spatialIndexManager.d.ts +30 -0
- package/_vendor/canvas-core/editor/managers/toolManager.d.ts +24 -0
- package/_vendor/canvas-core/editor/queries/shapeTransforms.d.ts +27 -0
- package/_vendor/canvas-core/editor/renderWindow.d.ts +30 -0
- package/_vendor/canvas-core/editor/resizeGeometry.d.ts +97 -0
- package/_vendor/canvas-core/editor/selection.d.ts +231 -0
- package/_vendor/canvas-core/editor/selectionHandleInteractions.d.ts +11 -0
- package/_vendor/canvas-core/editor/selectionOverlay.d.ts +33 -0
- package/_vendor/canvas-core/editor/stateNode.d.ts +31 -0
- package/_vendor/canvas-core/exports/integrity.d.ts +32 -0
- package/_vendor/canvas-core/exports/svg.d.ts +52 -0
- package/_vendor/canvas-core/geometry/box.d.ts +19 -0
- package/_vendor/canvas-core/geometry/ellipse2d.d.ts +16 -0
- package/_vendor/canvas-core/geometry/geometry2d.d.ts +15 -0
- package/_vendor/canvas-core/geometry/index.d.ts +8 -0
- package/_vendor/canvas-core/geometry/mat.d.ts +28 -0
- package/_vendor/canvas-core/geometry/polyline2d.d.ts +14 -0
- package/_vendor/canvas-core/geometry/rectangle2d.d.ts +16 -0
- package/_vendor/canvas-core/geometry/segments.d.ts +5 -0
- package/_vendor/canvas-core/geometry/vec.d.ts +37 -0
- package/_vendor/canvas-core/index.d.ts +59 -0
- package/_vendor/canvas-core/plugins/editorPlugin.d.ts +28 -0
- package/_vendor/canvas-core/plugins/index.d.ts +1 -0
- package/_vendor/canvas-core/reactivity.d.ts +4 -0
- package/_vendor/canvas-core/schema/records.d.ts +112 -0
- package/_vendor/canvas-core/schema/snapshotSupport.d.ts +43 -0
- package/_vendor/canvas-core/schema/snapshots.d.ts +31 -0
- package/_vendor/canvas-core/shapes/capabilities.d.ts +25 -0
- package/_vendor/canvas-core/shapes/colors.d.ts +26 -0
- package/_vendor/canvas-core/shapes/shapeUtil.d.ts +146 -0
- package/_vendor/canvas-core/shapes/shapeUtilRegistry.d.ts +9 -0
- package/_vendor/canvas-core/shapes/types.d.ts +2 -0
- package/_vendor/canvas-core/surfaces/actions.d.ts +35 -0
- package/_vendor/canvas-core/surfaces/contextMenu.d.ts +64 -0
- package/_vendor/canvas-core/surfaces/toolbar.d.ts +96 -0
- package/_vendor/canvas-core/tools/hand/handTool.d.ts +5 -0
- package/_vendor/canvas-core/tools/index.d.ts +2 -0
- package/_vendor/canvas-core/tools/select/selectContainment.d.ts +12 -0
- package/_vendor/canvas-core/tools/select/selectTool.d.ts +5 -0
- package/_vendor/canvas-core/tools/select/selectToolHelpers.d.ts +161 -0
- package/_vendor/canvas-core/tools/select/states/brushingState.d.ts +19 -0
- package/_vendor/canvas-core/tools/select/states/draggingSelectionHandleInteractionState.d.ts +15 -0
- package/_vendor/canvas-core/tools/select/states/idleState.d.ts +8 -0
- package/_vendor/canvas-core/tools/select/states/index.d.ts +11 -0
- package/_vendor/canvas-core/tools/select/states/pointingCanvasState.d.ts +11 -0
- package/_vendor/canvas-core/tools/select/states/pointingResizeHandleState.d.ts +10 -0
- package/_vendor/canvas-core/tools/select/states/pointingRotateHandleState.d.ts +10 -0
- package/_vendor/canvas-core/tools/select/states/pointingSelectionHandleInteractionState.d.ts +10 -0
- package/_vendor/canvas-core/tools/select/states/pointingShapeState.d.ts +12 -0
- package/_vendor/canvas-core/tools/select/states/resizingState.d.ts +16 -0
- package/_vendor/canvas-core/tools/select/states/rotatingState.d.ts +14 -0
- package/_vendor/canvas-core/tools/select/states/selectStateNode.d.ts +60 -0
- package/_vendor/canvas-core/tools/select/states/translatingState.d.ts +17 -0
- package/_vendor/canvas-react/components/CanvasView.d.ts +14 -0
- package/_vendor/canvas-react/components/OverlayLayer.d.ts +1 -0
- package/_vendor/canvas-react/components/PageSpace.d.ts +6 -0
- package/_vendor/canvas-react/components/ShapeLayer.d.ts +4 -0
- package/_vendor/canvas-react/components/index.d.ts +2 -0
- package/_vendor/canvas-react/components/overlays/BindingGuide.d.ts +24 -0
- package/_vendor/canvas-react/components/overlays/BindingPreviewOverlay.d.ts +1 -0
- package/_vendor/canvas-react/components/overlays/BrushBoxOverlay.d.ts +1 -0
- package/_vendor/canvas-react/components/overlays/OverlaySvgRoot.d.ts +1 -0
- package/_vendor/canvas-react/components/overlays/SelectionFrameOverlay.d.ts +1 -0
- package/_vendor/canvas-react/components/overlays/SelectionHandlesOverlay.d.ts +1 -0
- package/_vendor/canvas-react/components/overlays/SelectionOverlaySvg.d.ts +1 -0
- package/_vendor/canvas-react/components/overlays/SelectionPathOverlay.d.ts +1 -0
- package/_vendor/canvas-react/components/overlays/ShapeOutlineOverlay.d.ts +8 -0
- package/_vendor/canvas-react/components/overlays/SnapIndicatorsOverlay.d.ts +1 -0
- package/_vendor/canvas-react/components/useCanvasDomEvents.d.ts +21 -0
- package/_vendor/canvas-react/dom.d.ts +10 -0
- package/_vendor/canvas-react/hooks/useEditor.d.ts +3 -0
- package/_vendor/canvas-react/hooks/useValue.d.ts +2 -0
- package/_vendor/canvas-react/host/canvasOverlayRegistryContext.d.ts +3 -0
- package/_vendor/canvas-react/host/canvasPlugin.d.ts +73 -0
- package/_vendor/canvas-react/host/canvasRendererRegistryContext.d.ts +3 -0
- package/_vendor/canvas-react/host/contextMenuRegistry.d.ts +12 -0
- package/_vendor/canvas-react/host/domEventGuards.d.ts +11 -0
- package/_vendor/canvas-react/host/extension.d.ts +37 -0
- package/_vendor/canvas-react/host/index.d.ts +13 -0
- package/_vendor/canvas-react/host/overlayRegistry.d.ts +18 -0
- package/_vendor/canvas-react/host/pluginHost.d.ts +2 -0
- package/_vendor/canvas-react/host/pluginHostManifest.d.ts +2 -0
- package/_vendor/canvas-react/host/pluginHostRuntime.d.ts +3 -0
- package/_vendor/canvas-react/host/pluginHostTypes.d.ts +102 -0
- package/_vendor/canvas-react/host/pluginHostValidation.d.ts +11 -0
- package/_vendor/canvas-react/host/rendererRegistry.d.ts +12 -0
- package/_vendor/canvas-react/host/toolbarRegistry.d.ts +24 -0
- package/_vendor/canvas-react/index.d.ts +4 -0
- package/_vendor/plugin-arrow/arrowBindingAnchors.d.ts +5 -0
- package/_vendor/plugin-arrow/arrowBindingGeometry.d.ts +28 -0
- package/_vendor/plugin-arrow/arrowBindingUtil.d.ts +27 -0
- package/_vendor/plugin-arrow/arrowGeometry.d.ts +74 -0
- package/_vendor/plugin-arrow/arrowShapeUtil.d.ts +21 -0
- package/_vendor/plugin-arrow/arrowTerminalBindingResolver.d.ts +20 -0
- package/_vendor/plugin-arrow/arrowTerminalCommands.d.ts +12 -0
- package/_vendor/plugin-arrow/arrowTool.d.ts +4 -0
- package/_vendor/plugin-arrow/canvas.d.ts +2 -0
- package/_vendor/plugin-arrow/editor.d.ts +7 -0
- package/_vendor/plugin-arrow/feature.d.ts +3 -0
- package/_vendor/plugin-arrow/index.d.ts +12 -0
- package/_vendor/plugin-arrow/selectionHandleInteractions.d.ts +3 -0
- package/_vendor/plugin-arrow/types.d.ts +31 -0
- package/_vendor/plugin-draw/DrawShapeRenderer.d.ts +10 -0
- package/_vendor/plugin-draw/canvas.d.ts +2 -0
- package/_vendor/plugin-draw/drawGeometry.d.ts +45 -0
- package/_vendor/plugin-draw/drawHitTest.d.ts +11 -0
- package/_vendor/plugin-draw/drawInterpolation.d.ts +5 -0
- package/_vendor/plugin-draw/drawPath.d.ts +37 -0
- package/_vendor/plugin-draw/drawSegments.d.ts +11 -0
- package/_vendor/plugin-draw/drawSelectionTransform.d.ts +18 -0
- package/_vendor/plugin-draw/drawShapeGeometry.d.ts +33 -0
- package/_vendor/plugin-draw/drawShapeUtil.d.ts +21 -0
- package/_vendor/plugin-draw/drawStrokeGeometry.d.ts +17 -0
- package/_vendor/plugin-draw/drawTool.d.ts +6 -0
- package/_vendor/plugin-draw/editor.d.ts +7 -0
- package/_vendor/plugin-draw/feature.d.ts +3 -0
- package/_vendor/plugin-draw/index.d.ts +13 -0
- package/_vendor/plugin-draw/types.d.ts +23 -0
- package/_vendor/plugin-eraser/canvas.d.ts +2 -0
- package/_vendor/plugin-eraser/editor.d.ts +2 -0
- package/_vendor/plugin-eraser/eraserTool.d.ts +5 -0
- package/_vendor/plugin-eraser/feature.d.ts +3 -0
- package/_vendor/plugin-eraser/{index.ts → index.d.ts} +2 -2
- package/_vendor/plugin-frame/canvas.d.ts +9 -0
- package/_vendor/plugin-frame/editor.d.ts +7 -0
- package/_vendor/plugin-frame/feature.d.ts +3 -0
- package/_vendor/plugin-frame/frameShapeUtil.d.ts +23 -0
- package/_vendor/plugin-frame/frameTool.d.ts +6 -0
- package/_vendor/plugin-frame/index.d.ts +6 -0
- package/_vendor/plugin-geo/canvas.d.ts +13 -0
- package/_vendor/plugin-geo/editor.d.ts +7 -0
- package/_vendor/plugin-geo/feature.d.ts +3 -0
- package/_vendor/plugin-geo/geoGeometry.d.ts +8 -0
- package/_vendor/plugin-geo/geoShapeUtil.d.ts +13 -0
- package/_vendor/plugin-geo/geoTools.d.ts +26 -0
- package/_vendor/plugin-geo/index.d.ts +7 -0
- package/_vendor/plugin-geo/types.d.ts +17 -0
- package/_vendor/plugin-group/canvas.d.ts +10 -0
- package/_vendor/plugin-group/editor.d.ts +7 -0
- package/_vendor/plugin-group/feature.d.ts +3 -0
- package/_vendor/plugin-group/groupShapeUtil.d.ts +15 -0
- package/_vendor/plugin-group/index.d.ts +5 -0
- package/_vendor/plugin-image/canvas.d.ts +2 -0
- package/_vendor/plugin-image/crop.d.ts +112 -0
- package/_vendor/plugin-image/cropInteractions.d.ts +3 -0
- package/_vendor/plugin-image/cropSession.d.ts +4 -0
- package/_vendor/plugin-image/editor.d.ts +16 -0
- package/_vendor/plugin-image/feature.d.ts +3 -0
- package/_vendor/plugin-image/imageShapeUtil.d.ts +11 -0
- package/_vendor/plugin-image/index.d.ts +8 -0
- package/_vendor/plugin-image/types.d.ts +37 -0
- package/_vendor/plugin-laser/canvas.d.ts +2 -0
- package/_vendor/plugin-laser/editor.d.ts +2 -0
- package/_vendor/plugin-laser/feature.d.ts +3 -0
- package/_vendor/plugin-laser/{index.ts → index.d.ts} +2 -2
- package/_vendor/plugin-laser/laserTool.d.ts +4 -0
- package/_vendor/plugin-text/arrowLabelBindingUtil.d.ts +42 -0
- package/_vendor/plugin-text/canvas.d.ts +2 -0
- package/_vendor/plugin-text/editor.d.ts +2 -0
- package/_vendor/plugin-text/feature.d.ts +3 -0
- package/_vendor/plugin-text/geoLabelBindingUtil.d.ts +45 -0
- package/_vendor/plugin-text/host/RichTextEditingBox.d.ts +5 -0
- package/_vendor/plugin-text/host/RichTextToolbar.d.ts +8 -0
- package/_vendor/plugin-text/host/TiptapTextEditor.d.ts +24 -0
- package/_vendor/plugin-text/host/richTextBubbleMenuPositionSync.d.ts +7 -0
- package/_vendor/plugin-text/host/richTextRendering.d.ts +3 -0
- package/_vendor/plugin-text/host/textDomSelection.d.ts +7 -0
- package/_vendor/plugin-text/host/textEditingBoxStyle.d.ts +3 -0
- package/_vendor/plugin-text/host/textEntryFocus.d.ts +22 -0
- package/_vendor/plugin-text/host/textFontLoader.d.ts +2 -0
- package/_vendor/plugin-text/host/textMeasurement.d.ts +12 -0
- package/_vendor/plugin-text/host/textMeasurementSync.d.ts +10 -0
- package/_vendor/plugin-text/host/textRangeSelection.d.ts +14 -0
- package/_vendor/plugin-text/host/textShapeRendererRuntime.d.ts +8 -0
- package/_vendor/plugin-text/host/textShapeSync.d.ts +17 -0
- package/_vendor/plugin-text/host/tiptapTextEditorController.d.ts +33 -0
- package/_vendor/plugin-text/index.d.ts +4 -0
- package/_vendor/plugin-text/richTextUtils.d.ts +18 -0
- package/_vendor/plugin-text/textInteractions.d.ts +2 -0
- package/_vendor/plugin-text/textLabelHelpers.d.ts +44 -0
- package/_vendor/plugin-text/textShapeHelpers.d.ts +21 -0
- package/_vendor/plugin-text/textShapeSvgExporter.d.ts +6 -0
- package/_vendor/plugin-text/textShapeUtil.d.ts +19 -0
- package/_vendor/plugin-text/textStyle.d.ts +9 -0
- package/_vendor/plugin-text/textTool.d.ts +4 -0
- package/_vendor/plugin-text/textTypes.d.ts +28 -0
- package/_vendor/signals/atom.d.ts +9 -0
- package/_vendor/signals/computed.d.ts +11 -0
- package/_vendor/signals/core.d.ts +17 -0
- package/_vendor/signals/effect.d.ts +29 -0
- package/_vendor/signals/types.d.ts +15 -0
- package/_vendor/store/diff.d.ts +9 -0
- package/_vendor/store/history.d.ts +37 -0
- package/_vendor/store/index.d.ts +5 -0
- package/_vendor/store/store.d.ts +32 -0
- package/_vendor/store/types.d.ts +27 -0
- package/browser/localSnapshotRestore.d.ts +13 -0
- package/browser/persistence.d.ts +46 -0
- package/builtins/controller/createBuiltInCanvasController.d.ts +16 -0
- package/builtins/controller/layerController.d.ts +9 -0
- package/builtins/controller/shapeCreationController.d.ts +74 -0
- package/builtins/extensions.d.ts +15 -0
- package/builtins/index.d.ts +5 -0
- package/chrome/CanvasKitFloatingToolbarLayer.d.ts +6 -0
- package/chrome/FloatingSelectionToolbarPageSpace.d.ts +9 -0
- package/chrome/bindings/useCanvasKitChromeControls.d.ts +27 -0
- package/chrome/bindings/useContextMenuSurface.d.ts +12 -0
- package/chrome/bindings/useSvgExport.d.ts +15 -0
- package/chrome/bindings/useToolbarSurfaces.d.ts +26 -0
- package/chrome/types.d.ts +66 -0
- package/chrome/useCanvasKitChromeContext.d.ts +19 -0
- package/controller/canvasKitController.d.ts +36 -0
- package/core/controller/canvasProductController.d.ts +114 -0
- package/core/controller/featureControllerRegistry.d.ts +12 -0
- package/core/controller/index.d.ts +4 -0
- package/core/controller/productLayerTree.d.ts +10 -0
- package/core/features/actions/canvasActionContext.d.ts +15 -0
- package/core/features/actions/canvasActions.d.ts +26 -0
- package/core/features/clipboard/clipboardContextMenuContributions.d.ts +2 -0
- package/core/features/clipboard/clipboardContribution.d.ts +19 -0
- package/core/features/clipboard/clipboardService.d.ts +10 -0
- package/core/features/context-menu/contextMenuActions.d.ts +12 -0
- package/core/features/context-menu/contextMenuContext.d.ts +6 -0
- package/core/features/context-menu/contextMenuContribution.d.ts +4 -0
- package/core/features/context-menu/viewContextMenuContributions.d.ts +2 -0
- package/core/features/export/svgExport.d.ts +33 -0
- package/core/features/hostActionIds.d.ts +1 -0
- package/core/features/toolbar/selectionContextMenuContributions.d.ts +2 -0
- package/core/features/toolbar/toolContextMenuContributions.d.ts +2 -0
- package/core/features/toolbar/toolbarContribution.d.ts +4 -0
- package/core/features/toolbar/toolbarLabels.d.ts +8 -0
- package/core/index.d.ts +23 -0
- package/core/runtime/productAssets.d.ts +18 -0
- package/core/runtime/productContributions.d.ts +9 -0
- package/core/runtime/productDefinition.d.ts +32 -0
- package/core/runtime/productEditor.d.ts +3 -0
- package/core/runtime/productHost.d.ts +17 -0
- package/core/runtime/productServices.d.ts +30 -0
- package/features/image/ImageImportController.d.ts +9 -0
- package/features/image/imageAssetService.d.ts +7 -0
- package/features/image/imageBlobStore.d.ts +25 -0
- package/features/image/imageFileHelpers.d.ts +35 -0
- package/features/image/imageHostActions.d.ts +36 -0
- package/features/image/imageHostExtension.d.ts +5 -0
- package/features/image/imageProductController.d.ts +22 -0
- package/features/image/imageProductToolbarActions.d.ts +2 -0
- package/features/image/imageToolbarHostBridge.d.ts +14 -0
- package/features/image/index.d.ts +15 -0
- package/features/image/svgImageAssetInliner.d.ts +3 -0
- package/features/image/useImageImport.d.ts +17 -0
- package/index.css +1 -2
- package/index.d.ts +12 -15
- package/index.mjs +66 -1
- package/package.json +1 -11
- package/product/canvasKitProduct.d.ts +59 -0
- package/react/CanvasKitPersistenceNotice.d.ts +4 -0
- package/react/CanvasKitRoot.d.ts +5 -0
- package/react/useCanvasKitController.d.ts +5 -0
- package/react/useCanvasKitKeyboardShortcuts.d.ts +6 -0
- package/react/useCanvasKitRuntime.d.ts +4 -0
- package/react/useCanvasKitStartup.d.ts +9 -0
- package/runtime/canvasKitHostExtensions.d.ts +19 -0
- package/runtime/canvasKitRuntime.d.ts +19 -0
- package/runtime/canvasKitRuntimeInitializer.d.ts +11 -0
- package/_vendor/canvas-core/bindings/BindingUtil.ts +0 -92
- package/_vendor/canvas-core/bindings/BindingUtilRegistry.ts +0 -22
- package/_vendor/canvas-core/bindings/arrow/arrowBindingHelpers.ts +0 -52
- package/_vendor/canvas-core/contextMenu.ts +0 -85
- package/_vendor/canvas-core/editor/Editor.ts +0 -2614
- package/_vendor/canvas-core/editor/HistoryManager.ts +0 -83
- package/_vendor/canvas-core/editor/StateNode.ts +0 -162
- package/_vendor/canvas-core/editor/camera.ts +0 -6
- package/_vendor/canvas-core/editor/clipboard.ts +0 -478
- package/_vendor/canvas-core/editor/commands.ts +0 -833
- package/_vendor/canvas-core/editor/edgeScroll.ts +0 -37
- package/_vendor/canvas-core/editor/editorComputedHelpers.ts +0 -257
- package/_vendor/canvas-core/editor/editorSelectionTransforms.ts +0 -116
- package/_vendor/canvas-core/editor/events.ts +0 -93
- package/_vendor/canvas-core/editor/index.ts +0 -12
- package/_vendor/canvas-core/editor/interactions.ts +0 -101
- package/_vendor/canvas-core/editor/internal.ts +0 -22
- package/_vendor/canvas-core/editor/managers/BindingManager.ts +0 -262
- package/_vendor/canvas-core/editor/managers/CameraManager.ts +0 -147
- package/_vendor/canvas-core/editor/managers/ClipboardManager.ts +0 -32
- package/_vendor/canvas-core/editor/managers/DocumentSnapshotManager.ts +0 -256
- package/_vendor/canvas-core/editor/managers/InputsManager.ts +0 -319
- package/_vendor/canvas-core/editor/managers/InteractionTransientManager.ts +0 -218
- package/_vendor/canvas-core/editor/managers/QueryManager.ts +0 -837
- package/_vendor/canvas-core/editor/managers/RenderWindowManager.ts +0 -347
- package/_vendor/canvas-core/editor/managers/SelectionLayoutManager.ts +0 -196
- package/_vendor/canvas-core/editor/managers/SelectionManager.ts +0 -98
- package/_vendor/canvas-core/editor/managers/SelectionOverlayManager.ts +0 -308
- package/_vendor/canvas-core/editor/managers/ShapeEditingManager.ts +0 -226
- package/_vendor/canvas-core/editor/managers/ShapeGeometryManager.ts +0 -162
- package/_vendor/canvas-core/editor/managers/ShapeHierarchyManager.ts +0 -797
- package/_vendor/canvas-core/editor/managers/SideEffectManager.ts +0 -83
- package/_vendor/canvas-core/editor/managers/SnapManager.ts +0 -433
- package/_vendor/canvas-core/editor/managers/SnapSnapshotBuilder.ts +0 -430
- package/_vendor/canvas-core/editor/managers/SpatialIndexManager.ts +0 -354
- package/_vendor/canvas-core/editor/managers/ToolManager.ts +0 -81
- package/_vendor/canvas-core/editor/managers/queryState.ts +0 -583
- package/_vendor/canvas-core/editor/managers/selectionGeometry.ts +0 -287
- package/_vendor/canvas-core/editor/managers/shapeOrder.ts +0 -350
- package/_vendor/canvas-core/editor/managers/shapeReparenting.ts +0 -160
- package/_vendor/canvas-core/editor/managers/snapCalculations.ts +0 -412
- package/_vendor/canvas-core/editor/managers/snapGeometry.ts +0 -202
- package/_vendor/canvas-core/editor/managers/snapIndicators.ts +0 -403
- package/_vendor/canvas-core/editor/managers/snapTypes.ts +0 -122
- package/_vendor/canvas-core/editor/queries/shapeTransforms.ts +0 -171
- package/_vendor/canvas-core/editor/renderWindow.ts +0 -439
- package/_vendor/canvas-core/editor/resizeGeometry.ts +0 -654
- package/_vendor/canvas-core/editor/selection.ts +0 -489
- package/_vendor/canvas-core/editor/selectionHandleInteractions.ts +0 -43
- package/_vendor/canvas-core/editor/selectionOverlay.ts +0 -567
- package/_vendor/canvas-core/exports/integrity.ts +0 -174
- package/_vendor/canvas-core/exports/svg.ts +0 -494
- package/_vendor/canvas-core/geometry/Box.ts +0 -80
- package/_vendor/canvas-core/geometry/Ellipse2d.ts +0 -67
- package/_vendor/canvas-core/geometry/Geometry2d.ts +0 -52
- package/_vendor/canvas-core/geometry/Mat.ts +0 -92
- package/_vendor/canvas-core/geometry/Polyline2d.ts +0 -63
- package/_vendor/canvas-core/geometry/Rectangle2d.ts +0 -64
- package/_vendor/canvas-core/geometry/Vec.ts +0 -123
- package/_vendor/canvas-core/geometry/index.ts +0 -13
- package/_vendor/canvas-core/geometry/segments.ts +0 -65
- package/_vendor/canvas-core/index.ts +0 -391
- package/_vendor/canvas-core/plugins/index.ts +0 -5
- package/_vendor/canvas-core/plugins/types.ts +0 -53
- package/_vendor/canvas-core/reactivity.ts +0 -16
- package/_vendor/canvas-core/schema/records.ts +0 -221
- package/_vendor/canvas-core/schema/snapshots.ts +0 -527
- package/_vendor/canvas-core/shapes/ShapeUtil.ts +0 -516
- package/_vendor/canvas-core/shapes/ShapeUtilRegistry.ts +0 -26
- package/_vendor/canvas-core/shapes/capabilities.ts +0 -67
- package/_vendor/canvas-core/shapes/types.ts +0 -20
- package/_vendor/canvas-core/toolbar.ts +0 -148
- package/_vendor/canvas-core/tools/hand/HandTool.ts +0 -75
- package/_vendor/canvas-core/tools/index.ts +0 -2
- package/_vendor/canvas-core/tools/select/SelectTool.ts +0 -33
- package/_vendor/canvas-core/tools/select/selectContainment.ts +0 -104
- package/_vendor/canvas-core/tools/select/selectToolHelpers.ts +0 -801
- package/_vendor/canvas-core/tools/select/states/BrushingState.ts +0 -145
- package/_vendor/canvas-core/tools/select/states/DraggingSelectionHandleInteractionState.ts +0 -116
- package/_vendor/canvas-core/tools/select/states/IdleState.ts +0 -159
- package/_vendor/canvas-core/tools/select/states/PointingCanvasState.ts +0 -41
- package/_vendor/canvas-core/tools/select/states/PointingResizeHandleState.ts +0 -78
- package/_vendor/canvas-core/tools/select/states/PointingRotateHandleState.ts +0 -64
- package/_vendor/canvas-core/tools/select/states/PointingSelectionHandleInteractionState.ts +0 -34
- package/_vendor/canvas-core/tools/select/states/PointingShapeState.ts +0 -140
- package/_vendor/canvas-core/tools/select/states/ResizingState.ts +0 -171
- package/_vendor/canvas-core/tools/select/states/RotatingState.ts +0 -124
- package/_vendor/canvas-core/tools/select/states/SelectStateNode.ts +0 -128
- package/_vendor/canvas-core/tools/select/states/TranslatingState.ts +0 -139
- package/_vendor/canvas-core/tools/select/states/index.ts +0 -11
- package/_vendor/canvas-plugin-api/feature.ts +0 -204
- package/_vendor/canvas-plugin-api/index.ts +0 -142
- package/_vendor/canvas-product-react/api/apiRegistry.ts +0 -35
- package/_vendor/canvas-product-react/api/canvasProductApi.ts +0 -422
- package/_vendor/canvas-product-react/api/index.ts +0 -31
- package/_vendor/canvas-product-react/capabilities/clipboard/clipboardService.ts +0 -36
- package/_vendor/canvas-product-react/capabilities/clipboard/systemClipboard.ts +0 -245
- package/_vendor/canvas-product-react/capabilities/context-menu/systemContextMenu.ts +0 -396
- package/_vendor/canvas-product-react/capabilities/context-menu/useContextMenuSurface.ts +0 -59
- package/_vendor/canvas-product-react/capabilities/export/useSvgExport.ts +0 -156
- package/_vendor/canvas-product-react/capabilities/history/useHistoryControls.ts +0 -23
- package/_vendor/canvas-product-react/capabilities/pages/usePageControls.ts +0 -41
- package/_vendor/canvas-product-react/capabilities/toolbar/systemToolbar.ts +0 -490
- package/_vendor/canvas-product-react/capabilities/toolbar/useToolbarSurfaces.ts +0 -92
- package/_vendor/canvas-product-react/capabilities/zoom/useZoomControls.ts +0 -27
- package/_vendor/canvas-product-react/index.ts +0 -84
- package/_vendor/canvas-product-react/persistence/index.ts +0 -18
- package/_vendor/canvas-product-react/persistence/localSnapshotPersistence.ts +0 -294
- package/_vendor/canvas-product-react/runtime/CanvasProductRoot.tsx +0 -250
- package/_vendor/canvas-product-react/runtime/productDefinition.ts +0 -72
- package/_vendor/canvas-product-react/runtime/productServices.ts +0 -96
- package/_vendor/canvas-react/components/CanvasView.tsx +0 -796
- package/_vendor/canvas-react/components/OverlayLayer.tsx +0 -879
- package/_vendor/canvas-react/components/PageSpace.tsx +0 -34
- package/_vendor/canvas-react/components/ShapeLayer.tsx +0 -428
- package/_vendor/canvas-react/components/index.ts +0 -4
- package/_vendor/canvas-react/hooks/useEditor.ts +0 -11
- package/_vendor/canvas-react/hooks/useValue.ts +0 -14
- package/_vendor/canvas-react/host/CanvasRendererRegistryContext.tsx +0 -14
- package/_vendor/canvas-react/host/contextMenuRegistry.ts +0 -61
- package/_vendor/canvas-react/host/domEventGuards.ts +0 -61
- package/_vendor/canvas-react/host/index.ts +0 -38
- package/_vendor/canvas-react/host/pluginHost.ts +0 -635
- package/_vendor/canvas-react/host/rendererRegistry.tsx +0 -58
- package/_vendor/canvas-react/host/toolbarRegistry.ts +0 -100
- package/_vendor/canvas-react/index.ts +0 -3
- package/_vendor/plugin-arrow/ArrowBindingUtil.ts +0 -239
- package/_vendor/plugin-arrow/ArrowShapeUtil.ts +0 -311
- package/_vendor/plugin-arrow/ArrowTool.ts +0 -208
- package/_vendor/plugin-arrow/arrowGeometry.ts +0 -441
- package/_vendor/plugin-arrow/arrowTerminalBindingResolver.ts +0 -253
- package/_vendor/plugin-arrow/arrowTerminalCommands.ts +0 -230
- package/_vendor/plugin-arrow/canvas.tsx +0 -92
- package/_vendor/plugin-arrow/core.ts +0 -409
- package/_vendor/plugin-arrow/feature.ts +0 -20
- package/_vendor/plugin-arrow/index.ts +0 -28
- package/_vendor/plugin-arrow/selectionHandleInteractions.ts +0 -154
- package/_vendor/plugin-arrow/types.ts +0 -63
- package/_vendor/plugin-draw/DrawShapeRenderer.tsx +0 -60
- package/_vendor/plugin-draw/DrawShapeUtil.ts +0 -372
- package/_vendor/plugin-draw/DrawTool.ts +0 -444
- package/_vendor/plugin-draw/canvas.tsx +0 -24
- package/_vendor/plugin-draw/core.ts +0 -515
- package/_vendor/plugin-draw/drawGeometry.ts +0 -491
- package/_vendor/plugin-draw/drawHitTest.ts +0 -271
- package/_vendor/plugin-draw/drawInterpolation.ts +0 -250
- package/_vendor/plugin-draw/drawPath.ts +0 -550
- package/_vendor/plugin-draw/drawSegments.ts +0 -106
- package/_vendor/plugin-draw/drawSelectionTransform.ts +0 -67
- package/_vendor/plugin-draw/drawShapeGeometry.ts +0 -307
- package/_vendor/plugin-draw/drawStrokeGeometry.ts +0 -454
- package/_vendor/plugin-draw/feature.ts +0 -20
- package/_vendor/plugin-draw/index.ts +0 -31
- package/_vendor/plugin-draw/types.ts +0 -36
- package/_vendor/plugin-eraser/EraserTool.ts +0 -297
- package/_vendor/plugin-eraser/canvas.tsx +0 -616
- package/_vendor/plugin-eraser/core.ts +0 -49
- package/_vendor/plugin-eraser/feature.ts +0 -20
- package/_vendor/plugin-frame/FrameShapeUtil.ts +0 -173
- package/_vendor/plugin-frame/FrameTool.ts +0 -225
- package/_vendor/plugin-frame/canvas.tsx +0 -75
- package/_vendor/plugin-frame/core.ts +0 -534
- package/_vendor/plugin-frame/feature.ts +0 -20
- package/_vendor/plugin-frame/index.ts +0 -6
- package/_vendor/plugin-geo/GeoShapeUtil.ts +0 -463
- package/_vendor/plugin-geo/GeoTools.ts +0 -247
- package/_vendor/plugin-geo/canvas.tsx +0 -90
- package/_vendor/plugin-geo/core.ts +0 -495
- package/_vendor/plugin-geo/feature.ts +0 -20
- package/_vendor/plugin-geo/index.ts +0 -7
- package/_vendor/plugin-geo/types.ts +0 -27
- package/_vendor/plugin-group/GroupShapeUtil.ts +0 -59
- package/_vendor/plugin-group/canvas.tsx +0 -59
- package/_vendor/plugin-group/core.ts +0 -40
- package/_vendor/plugin-group/feature.ts +0 -20
- package/_vendor/plugin-group/index.ts +0 -5
- package/_vendor/plugin-image/ImageShapeUtil.ts +0 -95
- package/_vendor/plugin-image/canvas.tsx +0 -212
- package/_vendor/plugin-image/core.ts +0 -542
- package/_vendor/plugin-image/crop.ts +0 -770
- package/_vendor/plugin-image/cropInteractions.ts +0 -350
- package/_vendor/plugin-image/cropSession.ts +0 -38
- package/_vendor/plugin-image/feature.ts +0 -20
- package/_vendor/plugin-image/index.ts +0 -29
- package/_vendor/plugin-image/types.ts +0 -55
- package/_vendor/plugin-image-product-react/ImageImportController.tsx +0 -143
- package/_vendor/plugin-image-product-react/imageAssetService.ts +0 -52
- package/_vendor/plugin-image-product-react/imageBlobStore.ts +0 -315
- package/_vendor/plugin-image-product-react/imageHostActions.ts +0 -438
- package/_vendor/plugin-image-product-react/imageProductApi.ts +0 -88
- package/_vendor/plugin-image-product-react/imageToolbarHostBridge.ts +0 -48
- package/_vendor/plugin-image-product-react/imageToolbarRuntime.ts +0 -21
- package/_vendor/plugin-image-product-react/index.ts +0 -60
- package/_vendor/plugin-image-product-react/snapshotGuards.ts +0 -33
- package/_vendor/plugin-image-product-react/svgImageAssetInliner.ts +0 -54
- package/_vendor/plugin-image-product-react/useImageImport.ts +0 -64
- package/_vendor/plugin-laser/LaserTool.ts +0 -154
- package/_vendor/plugin-laser/canvas.tsx +0 -645
- package/_vendor/plugin-laser/core.ts +0 -49
- package/_vendor/plugin-laser/feature.ts +0 -20
- package/_vendor/plugin-text/ArrowLabelBindingUtil.ts +0 -336
- package/_vendor/plugin-text/GeoLabelBindingUtil.ts +0 -391
- package/_vendor/plugin-text/TextShapeSvgExporter.ts +0 -101
- package/_vendor/plugin-text/TextShapeUtil.ts +0 -284
- package/_vendor/plugin-text/TextTool.ts +0 -228
- package/_vendor/plugin-text/canvas.tsx +0 -115
- package/_vendor/plugin-text/core.ts +0 -422
- package/_vendor/plugin-text/feature.ts +0 -20
- package/_vendor/plugin-text/host/RichTextEditingBox.tsx +0 -144
- package/_vendor/plugin-text/host/RichTextToolbar.tsx +0 -266
- package/_vendor/plugin-text/host/TiptapTextEditor.tsx +0 -191
- package/_vendor/plugin-text/host/richTextRendering.tsx +0 -49
- package/_vendor/plugin-text/host/textDomSelection.ts +0 -93
- package/_vendor/plugin-text/host/textEditingBoxStyle.ts +0 -36
- package/_vendor/plugin-text/host/textEntryFocus.ts +0 -307
- package/_vendor/plugin-text/host/textFontLoader.ts +0 -149
- package/_vendor/plugin-text/host/textMeasurement.ts +0 -258
- package/_vendor/plugin-text/host/textMeasurementSync.ts +0 -77
- package/_vendor/plugin-text/host/textRangeSelection.ts +0 -134
- package/_vendor/plugin-text/host/textShapeRendererRuntime.tsx +0 -89
- package/_vendor/plugin-text/host/textShapeSync.ts +0 -173
- package/_vendor/plugin-text/host/tiptapTextEditorController.ts +0 -148
- package/_vendor/plugin-text/index.ts +0 -18
- package/_vendor/plugin-text/richTextUtils.ts +0 -259
- package/_vendor/plugin-text/textInteractions.ts +0 -366
- package/_vendor/plugin-text/textLabelHelpers.ts +0 -235
- package/_vendor/plugin-text/textShapeHelpers.ts +0 -123
- package/_vendor/plugin-text/textStyle.ts +0 -96
- package/_vendor/plugin-text/textTypes.ts +0 -48
- package/_vendor/signals/atom.ts +0 -74
- package/_vendor/signals/computed.ts +0 -132
- package/_vendor/signals/core.ts +0 -130
- package/_vendor/signals/effect.ts +0 -117
- package/_vendor/signals/types.ts +0 -17
- package/_vendor/store/Store.ts +0 -171
- package/_vendor/store/diff.ts +0 -229
- package/_vendor/store/history.ts +0 -177
- package/_vendor/store/index.ts +0 -32
- package/_vendor/store/types.ts +0 -37
- package/api/canvasKitApi.d.ts +0 -29
- package/internal-modules.d.ts +0 -187
- package/product/Shell.d.ts +0 -19
- package/product/chromeContext.d.ts +0 -70
- package/product/createCanvasKitEditor.d.ts +0 -6
- package/product/index.d.ts +0 -7
- package/product/persistence.d.ts +0 -3
- package/product/product.d.ts +0 -22
- package/product/useCanvasClipboardShortcuts.d.ts +0 -6
- package/product-iyBbEPIs.mjs +0 -4
- package/product.mjs +0 -1
- package/standard/extensions.d.ts +0 -1
- package/standard/index.d.ts +0 -3
- package/standard/standardApi.d.ts +0 -91
- package/standard-BmrxwqpJ.mjs +0 -44
- package/standard.mjs +0 -1
- /package/_vendor/signals/{index.ts → index.d.ts} +0 -0
|
@@ -1,550 +0,0 @@
|
|
|
1
|
-
import { Vec } from "@land/canvas-core";
|
|
2
|
-
import type { DrawShapePoint, DrawShapeSegment } from "./types";
|
|
3
|
-
|
|
4
|
-
export interface DrawPointSamplingOptions {
|
|
5
|
-
minPointDistance: number;
|
|
6
|
-
positionBlend: number;
|
|
7
|
-
pressureBlend: number;
|
|
8
|
-
maxPointCount: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface DrawInputPointGuardOptions {
|
|
12
|
-
minPointDistance: number;
|
|
13
|
-
pressureDeltaThreshold: number;
|
|
14
|
-
softMaxPointCount: number;
|
|
15
|
-
hardMaxPointCount: number;
|
|
16
|
-
maxDistanceMultiplier: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface DrawPointSamplingResult {
|
|
20
|
-
points: DrawShapePoint[];
|
|
21
|
-
rawPointCount: number;
|
|
22
|
-
sampledPointCount: number;
|
|
23
|
-
maxPointCount: number;
|
|
24
|
-
reduced: boolean;
|
|
25
|
-
capped: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function formatNumber(value: number): string {
|
|
29
|
-
return Number.isInteger(value) ? `${value}` : `${Number(value.toFixed(2))}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function clamp(value: number, min: number, max: number): number {
|
|
33
|
-
return Math.max(min, Math.min(max, value));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function getDrawPointSamplingLimit(isPen: boolean): number {
|
|
37
|
-
return isPen ? 640 : 480;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function getDrawSegmentPointLimit(isPen: boolean): number {
|
|
41
|
-
return getDrawPointSamplingLimit(isPen);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getAdaptiveMinPointDistance(
|
|
45
|
-
pointCount: number,
|
|
46
|
-
options: DrawInputPointGuardOptions,
|
|
47
|
-
): number {
|
|
48
|
-
if (pointCount <= options.softMaxPointCount) {
|
|
49
|
-
return options.minPointDistance;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const overflowRatio = clamp(
|
|
53
|
-
(pointCount - options.softMaxPointCount) /
|
|
54
|
-
Math.max(options.hardMaxPointCount - options.softMaxPointCount, 1),
|
|
55
|
-
0,
|
|
56
|
-
1,
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
return options.minPointDistance * (1 + overflowRatio * options.maxDistanceMultiplier);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function areDrawPointsEqual(a: DrawShapePoint, b: DrawShapePoint): boolean {
|
|
63
|
-
return (
|
|
64
|
-
a.x === b.x &&
|
|
65
|
-
a.y === b.y &&
|
|
66
|
-
a.pressure === b.pressure &&
|
|
67
|
-
a.segment === b.segment
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function drawPointToVec(point: DrawShapePoint): Vec {
|
|
72
|
-
return new Vec(point.x, point.y);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function cloneDrawPoint(point: DrawShapePoint): DrawShapePoint {
|
|
76
|
-
return {
|
|
77
|
-
x: point.x,
|
|
78
|
-
y: point.y,
|
|
79
|
-
...(point.pressure === undefined ? null : { pressure: point.pressure }),
|
|
80
|
-
...(point.segment === undefined ? null : { segment: point.segment }),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function cloneDrawSegment(segment: DrawShapeSegment): DrawShapeSegment {
|
|
85
|
-
return {
|
|
86
|
-
points: segment.points.map(cloneDrawPoint),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function getFlattenedDrawSegmentPoints(
|
|
91
|
-
segments: readonly DrawShapeSegment[],
|
|
92
|
-
): DrawShapePoint[] {
|
|
93
|
-
const points: DrawShapePoint[] = [];
|
|
94
|
-
for (const segment of segments) {
|
|
95
|
-
points.push(...segment.points.map(cloneDrawPoint));
|
|
96
|
-
}
|
|
97
|
-
return points;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function getDrawSegmentsFromPoints(
|
|
101
|
-
points: readonly DrawShapePoint[],
|
|
102
|
-
): DrawShapeSegment[] {
|
|
103
|
-
return [{ points: points.map(cloneDrawPoint) }];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function normalizePressure(pressure: number | undefined): number | undefined {
|
|
107
|
-
if (pressure === undefined || !Number.isFinite(pressure)) {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return clamp(pressure, 0.05, 1);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function getDrawInputPointGuardOptions(
|
|
115
|
-
strokeWidth: number,
|
|
116
|
-
isPen: boolean,
|
|
117
|
-
): DrawInputPointGuardOptions {
|
|
118
|
-
return isPen
|
|
119
|
-
? {
|
|
120
|
-
minPointDistance: Math.max(0.12, strokeWidth * 0.08),
|
|
121
|
-
pressureDeltaThreshold: 0.035,
|
|
122
|
-
softMaxPointCount: 1600,
|
|
123
|
-
hardMaxPointCount: 3200,
|
|
124
|
-
maxDistanceMultiplier: 2.5,
|
|
125
|
-
}
|
|
126
|
-
: {
|
|
127
|
-
minPointDistance: Math.max(0.3, strokeWidth * 0.14),
|
|
128
|
-
pressureDeltaThreshold: 0.08,
|
|
129
|
-
softMaxPointCount: 900,
|
|
130
|
-
hardMaxPointCount: 2200,
|
|
131
|
-
maxDistanceMultiplier: 6,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function appendGuardedDrawPoint(
|
|
136
|
-
points: DrawShapePoint[],
|
|
137
|
-
point: DrawShapePoint,
|
|
138
|
-
options: DrawInputPointGuardOptions,
|
|
139
|
-
): void {
|
|
140
|
-
const candidate = cloneDrawPoint(point);
|
|
141
|
-
const previous = points[points.length - 1];
|
|
142
|
-
|
|
143
|
-
if (!previous) {
|
|
144
|
-
points.push(candidate);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (areDrawPointsEqual(previous, candidate)) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const minDistance = getAdaptiveMinPointDistance(points.length, options);
|
|
153
|
-
const dx = candidate.x - previous.x;
|
|
154
|
-
const dy = candidate.y - previous.y;
|
|
155
|
-
const pressureDelta = Math.abs(
|
|
156
|
-
(candidate.pressure ?? 0) - (previous.pressure ?? 0),
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
dx * dx + dy * dy < minDistance * minDistance &&
|
|
161
|
-
pressureDelta < options.pressureDeltaThreshold
|
|
162
|
-
) {
|
|
163
|
-
points[points.length - 1] = candidate;
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
points.push(candidate);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function getDrawPointsWithinStableLimit(
|
|
171
|
-
points: readonly DrawShapePoint[],
|
|
172
|
-
maxPointCount: number,
|
|
173
|
-
): DrawShapePoint[] {
|
|
174
|
-
const limit = Math.max(2, Math.floor(maxPointCount));
|
|
175
|
-
if (points.length <= limit) {
|
|
176
|
-
return points.map(cloneDrawPoint);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const removalCount = points.length - limit;
|
|
180
|
-
const removalIndices = getStableDrawPointRemovalIndices(
|
|
181
|
-
points,
|
|
182
|
-
removalCount,
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
return points
|
|
186
|
-
.filter((_point, index) => !removalIndices.has(index))
|
|
187
|
-
.map(cloneDrawPoint);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function getStableDrawPointRemovalIndices(
|
|
191
|
-
points: readonly DrawShapePoint[],
|
|
192
|
-
removalCount: number,
|
|
193
|
-
): Set<number> {
|
|
194
|
-
let candidates = getStableDrawPointRemovalCandidates(points, true);
|
|
195
|
-
if (candidates.length < removalCount) {
|
|
196
|
-
candidates = getStableDrawPointRemovalCandidates(points, false);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return new Set(
|
|
200
|
-
candidates
|
|
201
|
-
.slice(0, removalCount)
|
|
202
|
-
.map((candidate) => candidate.index),
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function getStableDrawPointRemovalCandidates(
|
|
207
|
-
points: readonly DrawShapePoint[],
|
|
208
|
-
preserveStraightSegmentPoints: boolean,
|
|
209
|
-
): { index: number; score: number }[] {
|
|
210
|
-
const candidates: { index: number; score: number }[] = [];
|
|
211
|
-
|
|
212
|
-
for (let index = 1; index < points.length - 1; index += 1) {
|
|
213
|
-
if (
|
|
214
|
-
preserveStraightSegmentPoints &&
|
|
215
|
-
isStraightSegmentControlPoint(points, index)
|
|
216
|
-
) {
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const point = points[index];
|
|
221
|
-
const previous = points[index - 1];
|
|
222
|
-
const next = points[index + 1];
|
|
223
|
-
if (!point || !previous || !next) {
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
candidates.push({
|
|
228
|
-
index,
|
|
229
|
-
score: getDrawPointRemovalCost(point, previous, next),
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
candidates.sort(
|
|
234
|
-
(a, b) =>
|
|
235
|
-
a.score - b.score ||
|
|
236
|
-
getDrawPointRemovalTieBreakScore(a.index) -
|
|
237
|
-
getDrawPointRemovalTieBreakScore(b.index),
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
return candidates;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function getDrawPointRemovalTieBreakScore(index: number): number {
|
|
244
|
-
return index;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function isStraightSegmentControlPoint(
|
|
248
|
-
points: readonly DrawShapePoint[],
|
|
249
|
-
index: number,
|
|
250
|
-
): boolean {
|
|
251
|
-
return (
|
|
252
|
-
points[index]?.segment === "straight" ||
|
|
253
|
-
points[index + 1]?.segment === "straight"
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function getDrawPointRemovalCost(
|
|
258
|
-
point: DrawShapePoint,
|
|
259
|
-
previous: DrawShapePoint,
|
|
260
|
-
next: DrawShapePoint,
|
|
261
|
-
): number {
|
|
262
|
-
const positionCost = getPointToSegmentDistanceSquared(point, previous, next);
|
|
263
|
-
const pressureCost = getPressureRemovalCost(point, previous, next);
|
|
264
|
-
return positionCost + pressureCost * pressureCost;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function getPointToSegmentDistanceSquared(
|
|
268
|
-
point: DrawShapePoint,
|
|
269
|
-
start: DrawShapePoint,
|
|
270
|
-
end: DrawShapePoint,
|
|
271
|
-
): number {
|
|
272
|
-
const dx = end.x - start.x;
|
|
273
|
-
const dy = end.y - start.y;
|
|
274
|
-
const lengthSquared = dx * dx + dy * dy;
|
|
275
|
-
if (lengthSquared === 0) {
|
|
276
|
-
const pointDx = point.x - start.x;
|
|
277
|
-
const pointDy = point.y - start.y;
|
|
278
|
-
return pointDx * pointDx + pointDy * pointDy;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const t = clamp(
|
|
282
|
-
((point.x - start.x) * dx + (point.y - start.y) * dy) / lengthSquared,
|
|
283
|
-
0,
|
|
284
|
-
1,
|
|
285
|
-
);
|
|
286
|
-
const projectedX = start.x + dx * t;
|
|
287
|
-
const projectedY = start.y + dy * t;
|
|
288
|
-
const pointDx = point.x - projectedX;
|
|
289
|
-
const pointDy = point.y - projectedY;
|
|
290
|
-
return pointDx * pointDx + pointDy * pointDy;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function getPressureRemovalCost(
|
|
294
|
-
point: DrawShapePoint,
|
|
295
|
-
previous: DrawShapePoint,
|
|
296
|
-
next: DrawShapePoint,
|
|
297
|
-
): number {
|
|
298
|
-
if (point.pressure === undefined) {
|
|
299
|
-
return 0;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const previousPressure = previous.pressure ?? point.pressure;
|
|
303
|
-
const nextPressure = next.pressure ?? point.pressure;
|
|
304
|
-
return Math.abs(point.pressure - (previousPressure + nextPressure) / 2) * 8;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export function sampleDrawPoints(
|
|
308
|
-
points: readonly DrawShapePoint[],
|
|
309
|
-
options: DrawPointSamplingOptions,
|
|
310
|
-
): DrawPointSamplingResult {
|
|
311
|
-
if (points.length <= 1) {
|
|
312
|
-
return {
|
|
313
|
-
points: points.map(cloneDrawPoint),
|
|
314
|
-
rawPointCount: points.length,
|
|
315
|
-
sampledPointCount: points.length,
|
|
316
|
-
maxPointCount: options.maxPointCount,
|
|
317
|
-
reduced: false,
|
|
318
|
-
capped: false,
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
const sampled: DrawShapePoint[] = [cloneDrawPoint(points[0]!)];
|
|
323
|
-
const minDistanceSquared =
|
|
324
|
-
options.minPointDistance * options.minPointDistance;
|
|
325
|
-
let previousSmoothedPoint = drawPointToVec(points[0]!);
|
|
326
|
-
let previousSmoothedPressure = normalizePressure(points[0]!.pressure);
|
|
327
|
-
|
|
328
|
-
for (let index = 1; index < points.length; index += 1) {
|
|
329
|
-
const point = points[index];
|
|
330
|
-
if (!point) {
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const rawPoint = drawPointToVec(point);
|
|
335
|
-
const rawPressure = normalizePressure(point.pressure);
|
|
336
|
-
const isLastPoint = index === points.length - 1;
|
|
337
|
-
const isStraightSegment = point.segment === "straight";
|
|
338
|
-
const smoothedPoint =
|
|
339
|
-
isLastPoint || isStraightSegment
|
|
340
|
-
? rawPoint
|
|
341
|
-
: Vec.Lrp(previousSmoothedPoint, rawPoint, options.positionBlend);
|
|
342
|
-
const smoothedPressure =
|
|
343
|
-
isStraightSegment
|
|
344
|
-
? rawPressure
|
|
345
|
-
: rawPressure === undefined
|
|
346
|
-
? undefined
|
|
347
|
-
: previousSmoothedPressure === undefined
|
|
348
|
-
? rawPressure
|
|
349
|
-
: previousSmoothedPressure +
|
|
350
|
-
(rawPressure - previousSmoothedPressure) * options.pressureBlend;
|
|
351
|
-
|
|
352
|
-
previousSmoothedPoint = smoothedPoint;
|
|
353
|
-
previousSmoothedPressure = smoothedPressure;
|
|
354
|
-
|
|
355
|
-
const candidate: DrawShapePoint =
|
|
356
|
-
smoothedPressure === undefined
|
|
357
|
-
? {
|
|
358
|
-
x: smoothedPoint.x,
|
|
359
|
-
y: smoothedPoint.y,
|
|
360
|
-
...(point.segment === undefined ? null : { segment: point.segment }),
|
|
361
|
-
}
|
|
362
|
-
: {
|
|
363
|
-
x: smoothedPoint.x,
|
|
364
|
-
y: smoothedPoint.y,
|
|
365
|
-
pressure: smoothedPressure,
|
|
366
|
-
...(point.segment === undefined ? null : { segment: point.segment }),
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
const previousAccepted = sampled[sampled.length - 1];
|
|
370
|
-
if (!previousAccepted) {
|
|
371
|
-
sampled.push(candidate);
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
const dx = candidate.x - previousAccepted.x;
|
|
376
|
-
const dy = candidate.y - previousAccepted.y;
|
|
377
|
-
const pressureDelta = Math.abs(
|
|
378
|
-
(candidate.pressure ?? 0) - (previousAccepted.pressure ?? 0),
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
if (dx * dx + dy * dy < minDistanceSquared) {
|
|
382
|
-
if (isStraightSegment) {
|
|
383
|
-
if (areDrawPointsEqual(previousAccepted, candidate)) {
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
sampled.push(candidate);
|
|
387
|
-
continue;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if (pressureDelta > 0.08 || isLastPoint) {
|
|
391
|
-
sampled[sampled.length - 1] = candidate;
|
|
392
|
-
}
|
|
393
|
-
continue;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
sampled.push(candidate);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
const wasOverLimit = sampled.length > options.maxPointCount;
|
|
400
|
-
const clamped = getDrawPointsWithinStableLimit(
|
|
401
|
-
sampled,
|
|
402
|
-
options.maxPointCount,
|
|
403
|
-
);
|
|
404
|
-
|
|
405
|
-
return {
|
|
406
|
-
points: clamped,
|
|
407
|
-
rawPointCount: points.length,
|
|
408
|
-
sampledPointCount: clamped.length,
|
|
409
|
-
maxPointCount: options.maxPointCount,
|
|
410
|
-
reduced: clamped.length < points.length,
|
|
411
|
-
capped: wasOverLimit,
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
export function getDrawCenterlinePathFromPoints(
|
|
416
|
-
points: readonly DrawShapePoint[],
|
|
417
|
-
): string | null {
|
|
418
|
-
if (points.length === 0) {
|
|
419
|
-
return null;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
if (points.length === 1) {
|
|
423
|
-
const point = points[0]!;
|
|
424
|
-
return `M ${formatNumber(point.x)} ${formatNumber(point.y)}`;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
if (points.length === 2) {
|
|
428
|
-
const start = points[0]!;
|
|
429
|
-
const end = points[1]!;
|
|
430
|
-
return [
|
|
431
|
-
`M ${formatNumber(start.x)} ${formatNumber(start.y)}`,
|
|
432
|
-
`L ${formatNumber(end.x)} ${formatNumber(end.y)}`,
|
|
433
|
-
].join(" ");
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
const commands: string[] = [];
|
|
437
|
-
const first = points[0]!;
|
|
438
|
-
commands.push(`M ${formatNumber(first.x)} ${formatNumber(first.y)}`);
|
|
439
|
-
|
|
440
|
-
for (let index = 1; index < points.length; index += 1) {
|
|
441
|
-
const current = points[index];
|
|
442
|
-
if (!current) {
|
|
443
|
-
continue;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
if (current.segment === "straight") {
|
|
447
|
-
commands.push(`L ${formatNumber(current.x)} ${formatNumber(current.y)}`);
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const next = points[index + 1];
|
|
452
|
-
if (!next || next.segment === "straight") {
|
|
453
|
-
if (canSmoothFreeRunEnd(points, index)) {
|
|
454
|
-
const previous = points[index - 1]!;
|
|
455
|
-
commands.push(
|
|
456
|
-
`Q ${formatNumber(previous.x)} ${formatNumber(previous.y)} ${formatNumber(current.x)} ${formatNumber(current.y)}`,
|
|
457
|
-
);
|
|
458
|
-
} else {
|
|
459
|
-
commands.push(`L ${formatNumber(current.x)} ${formatNumber(current.y)}`);
|
|
460
|
-
}
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
const midpoint = Vec.Med(drawPointToVec(current), drawPointToVec(next));
|
|
465
|
-
commands.push(
|
|
466
|
-
`Q ${formatNumber(current.x)} ${formatNumber(current.y)} ${formatNumber(midpoint.x)} ${formatNumber(midpoint.y)}`,
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
return commands.join(" ");
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
export function getClosedDrawCenterlinePathFromPoints(
|
|
474
|
-
points: readonly DrawShapePoint[],
|
|
475
|
-
): string | null {
|
|
476
|
-
if (points.length < 3) {
|
|
477
|
-
return null;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
const centerlinePath = getDrawCenterlinePathFromPoints(points);
|
|
481
|
-
if (!centerlinePath) {
|
|
482
|
-
return null;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
return `${centerlinePath} Z`;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
function canSmoothFreeRunEnd(
|
|
489
|
-
points: readonly DrawShapePoint[],
|
|
490
|
-
index: number,
|
|
491
|
-
): boolean {
|
|
492
|
-
return (
|
|
493
|
-
index >= 2 &&
|
|
494
|
-
points[index - 1]?.segment !== "straight" &&
|
|
495
|
-
points[index - 2]?.segment !== "straight"
|
|
496
|
-
);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
export function getClosedSvgPathFromVecs(points: readonly Vec[]): string | null {
|
|
500
|
-
if (points.length === 0) {
|
|
501
|
-
return null;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
const [first, ...rest] = points;
|
|
505
|
-
if (!first) {
|
|
506
|
-
return null;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return [
|
|
510
|
-
`M ${formatNumber(first.x)} ${formatNumber(first.y)}`,
|
|
511
|
-
...rest.map(
|
|
512
|
-
(point) => `L ${formatNumber(point.x)} ${formatNumber(point.y)}`,
|
|
513
|
-
),
|
|
514
|
-
"Z",
|
|
515
|
-
].join(" ");
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
export function getSmoothClosedSvgPathFromVecs(
|
|
519
|
-
points: readonly Vec[],
|
|
520
|
-
): string | null {
|
|
521
|
-
if (points.length < 3) {
|
|
522
|
-
return getClosedSvgPathFromVecs(points);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
const first = points[0];
|
|
526
|
-
const last = points[points.length - 1];
|
|
527
|
-
if (!first || !last) {
|
|
528
|
-
return null;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
const start = Vec.Med(last, first);
|
|
532
|
-
const commands: string[] = [
|
|
533
|
-
`M ${formatNumber(start.x)} ${formatNumber(start.y)}`,
|
|
534
|
-
];
|
|
535
|
-
for (let index = 0; index < points.length; index += 1) {
|
|
536
|
-
const current = points[index];
|
|
537
|
-
const next = points[(index + 1) % points.length];
|
|
538
|
-
if (!current || !next) {
|
|
539
|
-
continue;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
const midpoint = Vec.Med(current, next);
|
|
543
|
-
commands.push(
|
|
544
|
-
`Q ${formatNumber(current.x)} ${formatNumber(current.y)} ${formatNumber(midpoint.x)} ${formatNumber(midpoint.y)}`,
|
|
545
|
-
);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
commands.push("Z");
|
|
549
|
-
return commands.join(" ");
|
|
550
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { Box, Vec } from "@land/canvas-core";
|
|
2
|
-
import {
|
|
3
|
-
cloneDrawPoint,
|
|
4
|
-
cloneDrawSegment as cloneDrawSegmentImpl,
|
|
5
|
-
drawPointToVec,
|
|
6
|
-
} from "./drawPath";
|
|
7
|
-
import type { DrawShapePoint, DrawShapeSegment } from "./types";
|
|
8
|
-
|
|
9
|
-
export function cloneDrawPoints(
|
|
10
|
-
points: readonly DrawShapePoint[],
|
|
11
|
-
): DrawShapePoint[] {
|
|
12
|
-
return points.map(cloneDrawPoint);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function cloneDrawSegments(
|
|
16
|
-
segments: readonly DrawShapeSegment[],
|
|
17
|
-
): DrawShapeSegment[] {
|
|
18
|
-
return segments.map(cloneDrawSegment);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function cloneDrawSegment(segment: DrawShapeSegment): DrawShapeSegment {
|
|
22
|
-
return cloneDrawSegmentImpl(segment);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function translateDrawPoints(
|
|
26
|
-
points: readonly DrawShapePoint[],
|
|
27
|
-
dx: number,
|
|
28
|
-
dy: number,
|
|
29
|
-
): DrawShapePoint[] {
|
|
30
|
-
return points.map((point) => ({
|
|
31
|
-
x: point.x + dx,
|
|
32
|
-
y: point.y + dy,
|
|
33
|
-
...(point.pressure === undefined ? null : { pressure: point.pressure }),
|
|
34
|
-
...(point.segment === undefined ? null : { segment: point.segment }),
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function translateDrawSegments(
|
|
39
|
-
segments: readonly DrawShapeSegment[],
|
|
40
|
-
dx: number,
|
|
41
|
-
dy: number,
|
|
42
|
-
): DrawShapeSegment[] {
|
|
43
|
-
return segments.map((segment) => ({
|
|
44
|
-
points: translateDrawPoints(segment.points, dx, dy),
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function mapDrawPointCoordinates(
|
|
49
|
-
points: readonly DrawShapePoint[],
|
|
50
|
-
mapper: (point: Vec, index: number) => Vec,
|
|
51
|
-
): DrawShapePoint[] {
|
|
52
|
-
return points.map((point, index) => {
|
|
53
|
-
const mapped = mapper(drawPointToVec(point), index);
|
|
54
|
-
return {
|
|
55
|
-
x: mapped.x,
|
|
56
|
-
y: mapped.y,
|
|
57
|
-
...(point.pressure === undefined ? null : { pressure: point.pressure }),
|
|
58
|
-
...(point.segment === undefined ? null : { segment: point.segment }),
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function mapDrawSegmentCoordinates(
|
|
64
|
-
segments: readonly DrawShapeSegment[],
|
|
65
|
-
mapper: (point: Vec, segmentIndex: number, pointIndex: number) => Vec,
|
|
66
|
-
): DrawShapeSegment[] {
|
|
67
|
-
return segments.map((segment, segmentIndex) => ({
|
|
68
|
-
points: segment.points.map((point, pointIndex) => {
|
|
69
|
-
const mapped = mapper(drawPointToVec(point), segmentIndex, pointIndex);
|
|
70
|
-
return {
|
|
71
|
-
x: mapped.x,
|
|
72
|
-
y: mapped.y,
|
|
73
|
-
...(point.pressure === undefined ? null : { pressure: point.pressure }),
|
|
74
|
-
...(point.segment === undefined ? null : { segment: point.segment }),
|
|
75
|
-
};
|
|
76
|
-
}),
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function mapDrawShapePointsToBounds(
|
|
81
|
-
points: readonly DrawShapePoint[],
|
|
82
|
-
fromBounds: Box,
|
|
83
|
-
toBounds: Box,
|
|
84
|
-
): DrawShapePoint[] {
|
|
85
|
-
const fromWidth = fromBounds.w === 0 ? 1 : fromBounds.w;
|
|
86
|
-
const fromHeight = fromBounds.h === 0 ? 1 : fromBounds.h;
|
|
87
|
-
const toWidth = toBounds.w === 0 ? 1 : toBounds.w;
|
|
88
|
-
const toHeight = toBounds.h === 0 ? 1 : toBounds.h;
|
|
89
|
-
|
|
90
|
-
return points.map((point) => ({
|
|
91
|
-
x: toBounds.minX + ((point.x - fromBounds.minX) / fromWidth) * toWidth,
|
|
92
|
-
y: toBounds.minY + ((point.y - fromBounds.minY) / fromHeight) * toHeight,
|
|
93
|
-
...(point.pressure === undefined ? null : { pressure: point.pressure }),
|
|
94
|
-
...(point.segment === undefined ? null : { segment: point.segment }),
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function mapDrawShapeSegmentsToBounds(
|
|
99
|
-
segments: readonly DrawShapeSegment[],
|
|
100
|
-
fromBounds: Box,
|
|
101
|
-
toBounds: Box,
|
|
102
|
-
): DrawShapeSegment[] {
|
|
103
|
-
return segments.map((segment) => ({
|
|
104
|
-
points: mapDrawShapePointsToBounds(segment.points, fromBounds, toBounds),
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Box,
|
|
3
|
-
Vec,
|
|
4
|
-
mirrorSelectionLocalPoint,
|
|
5
|
-
selectionLocalPointToPagePoint,
|
|
6
|
-
selectionPagePointToLocalPoint,
|
|
7
|
-
type SelectionMirrorAxis,
|
|
8
|
-
} from "@land/canvas-core";
|
|
9
|
-
import { mapDrawSegmentCoordinates } from "./drawSegments";
|
|
10
|
-
import type { DrawShapeSegment } from "./types";
|
|
11
|
-
|
|
12
|
-
export interface DrawSelectionRotationTransform {
|
|
13
|
-
selectionRotation: number;
|
|
14
|
-
selectionRotationCenter: Vec;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface DrawSelectionResizeInput
|
|
18
|
-
extends DrawSelectionRotationTransform {
|
|
19
|
-
targetSelectionStrokeBounds: Box;
|
|
20
|
-
scaleX: number;
|
|
21
|
-
scaleY: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface DrawSelectionFlipInput extends DrawSelectionRotationTransform {
|
|
25
|
-
axis: SelectionMirrorAxis;
|
|
26
|
-
selectionMirrorBounds: Box;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function getSelectionTransform(input: DrawSelectionRotationTransform) {
|
|
30
|
-
return {
|
|
31
|
-
rotation: input.selectionRotation,
|
|
32
|
-
rotationCenter: input.selectionRotationCenter,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function mapPageDrawSegmentsToSelectionLocal(
|
|
37
|
-
segments: readonly DrawShapeSegment[],
|
|
38
|
-
input: DrawSelectionRotationTransform,
|
|
39
|
-
): DrawShapeSegment[] {
|
|
40
|
-
const transform = getSelectionTransform(input);
|
|
41
|
-
return mapDrawSegmentCoordinates(segments, (point) =>
|
|
42
|
-
selectionPagePointToLocalPoint(point, transform),
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function mapSelectionLocalDrawSegmentsToPage(
|
|
47
|
-
segments: readonly DrawShapeSegment[],
|
|
48
|
-
input: DrawSelectionRotationTransform,
|
|
49
|
-
): DrawShapeSegment[] {
|
|
50
|
-
const transform = getSelectionTransform(input);
|
|
51
|
-
return mapDrawSegmentCoordinates(segments, (point) =>
|
|
52
|
-
selectionLocalPointToPagePoint(point, transform),
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function mirrorSelectionLocalDrawSegments(
|
|
57
|
-
segments: readonly DrawShapeSegment[],
|
|
58
|
-
input: DrawSelectionFlipInput,
|
|
59
|
-
): DrawShapeSegment[] {
|
|
60
|
-
return mapDrawSegmentCoordinates(segments, (point) =>
|
|
61
|
-
mirrorSelectionLocalPoint({
|
|
62
|
-
axis: input.axis,
|
|
63
|
-
bounds: input.selectionMirrorBounds,
|
|
64
|
-
point,
|
|
65
|
-
}),
|
|
66
|
-
);
|
|
67
|
-
}
|