js-draw 0.25.1 → 1.0.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/README.md +60 -20
- package/build-config.json +22 -21
- package/dist/Editor.css +1281 -0
- package/dist/bundle.js +3 -3
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/Editor.d.ts +91 -12
- package/dist/cjs/Editor.js +619 -590
- package/dist/cjs/EditorImage.d.ts +5 -2
- package/dist/cjs/EditorImage.js +258 -297
- package/dist/cjs/EventDispatcher.js +17 -19
- package/dist/cjs/Pointer.d.ts +3 -1
- package/dist/cjs/Pointer.js +41 -44
- package/dist/cjs/SVGLoader.d.ts +7 -1
- package/dist/cjs/SVGLoader.js +373 -474
- package/dist/cjs/UndoRedoHistory.js +28 -40
- package/dist/cjs/Viewport.d.ts +1 -4
- package/dist/cjs/Viewport.js +150 -193
- package/dist/cjs/bundle/bundled.js +4 -1
- package/dist/cjs/commands/Command.js +22 -49
- package/dist/cjs/commands/Duplicate.js +28 -44
- package/dist/cjs/commands/Erase.js +36 -54
- package/dist/cjs/commands/SerializableCommand.js +20 -35
- package/dist/cjs/commands/UnresolvedCommand.js +14 -29
- package/dist/cjs/commands/invertCommand.js +29 -51
- package/dist/cjs/commands/lib.js +9 -6
- package/dist/cjs/commands/localization.d.ts +1 -1
- package/dist/cjs/commands/localization.js +9 -9
- package/dist/cjs/commands/uniteCommands.js +57 -87
- package/dist/cjs/components/AbstractComponent.d.ts +11 -3
- package/dist/cjs/components/AbstractComponent.js +141 -169
- package/dist/cjs/components/BackgroundComponent.d.ts +3 -6
- package/dist/cjs/components/BackgroundComponent.js +124 -149
- package/dist/cjs/components/ImageComponent.d.ts +3 -5
- package/dist/cjs/components/ImageComponent.js +95 -175
- package/dist/cjs/components/RestylableComponent.d.ts +1 -1
- package/dist/cjs/components/RestylableComponent.js +41 -56
- package/dist/cjs/components/SVGGlobalAttributesObject.d.ts +1 -3
- package/dist/cjs/components/SVGGlobalAttributesObject.js +34 -51
- package/dist/cjs/components/Stroke.d.ts +4 -6
- package/dist/cjs/components/Stroke.js +95 -121
- package/dist/cjs/components/TextComponent.d.ts +2 -4
- package/dist/cjs/components/TextComponent.js +189 -234
- package/dist/cjs/components/UnknownSVGObject.d.ts +1 -3
- package/dist/cjs/components/UnknownSVGObject.js +30 -43
- package/dist/cjs/components/builders/ArrowBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/ArrowBuilder.js +43 -42
- package/dist/cjs/components/builders/CircleBuilder.js +43 -43
- package/dist/cjs/components/builders/FreehandLineBuilder.d.ts +3 -2
- package/dist/cjs/components/builders/FreehandLineBuilder.js +73 -86
- package/dist/cjs/components/builders/LineBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/LineBuilder.js +38 -36
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.js +131 -139
- package/dist/cjs/components/builders/RectangleBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/RectangleBuilder.js +31 -31
- package/dist/cjs/components/builders/types.d.ts +1 -1
- package/dist/cjs/components/lib.d.ts +3 -1
- package/dist/cjs/components/lib.js +10 -7
- package/dist/cjs/components/localization.js +4 -4
- package/dist/cjs/components/util/StrokeSmoother.d.ts +1 -2
- package/dist/cjs/components/util/StrokeSmoother.js +67 -72
- package/dist/cjs/components/util/describeComponentList.d.ts +1 -1
- package/dist/cjs/components/util/describeComponentList.js +4 -5
- package/dist/cjs/dialogs/makeAboutDialog.d.ts +15 -0
- package/dist/cjs/dialogs/makeAboutDialog.js +54 -0
- package/dist/cjs/inputEvents.d.ts +84 -0
- package/dist/cjs/inputEvents.js +40 -0
- package/dist/cjs/lib.d.ts +29 -13
- package/dist/cjs/lib.js +38 -23
- package/dist/cjs/localization.js +19 -18
- package/dist/cjs/localizations/de.js +117 -13
- package/dist/cjs/localizations/en.js +4 -13
- package/dist/cjs/localizations/es.js +62 -23
- package/dist/cjs/localizations/getLocalizationTable.js +15 -13
- package/dist/cjs/rendering/Display.d.ts +1 -2
- package/dist/cjs/rendering/Display.js +70 -83
- package/dist/cjs/rendering/RenderablePathSpec.d.ts +15 -0
- package/dist/cjs/rendering/RenderablePathSpec.js +70 -0
- package/dist/cjs/rendering/RenderingStyle.d.ts +4 -4
- package/dist/cjs/rendering/RenderingStyle.js +18 -28
- package/dist/cjs/rendering/TextRenderingStyle.d.ts +10 -10
- package/dist/cjs/rendering/TextRenderingStyle.js +13 -18
- package/dist/cjs/rendering/caching/CacheRecord.d.ts +1 -2
- package/dist/cjs/rendering/caching/CacheRecord.js +20 -22
- package/dist/cjs/rendering/caching/CacheRecordManager.d.ts +1 -1
- package/dist/cjs/rendering/caching/CacheRecordManager.js +17 -15
- package/dist/cjs/rendering/caching/RenderingCache.js +19 -19
- package/dist/cjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
- package/dist/cjs/rendering/caching/RenderingCacheNode.js +98 -118
- package/dist/cjs/rendering/caching/testUtils.js +24 -23
- package/dist/cjs/rendering/caching/types.d.ts +3 -3
- package/dist/cjs/rendering/lib.js +8 -5
- package/dist/cjs/rendering/localization.js +5 -5
- package/dist/cjs/rendering/renderers/AbstractRenderer.d.ts +2 -11
- package/dist/cjs/rendering/renderers/AbstractRenderer.js +53 -57
- package/dist/cjs/rendering/renderers/CanvasRenderer.d.ts +3 -5
- package/dist/cjs/rendering/renderers/CanvasRenderer.js +91 -106
- package/dist/cjs/rendering/renderers/DummyRenderer.d.ts +1 -4
- package/dist/cjs/rendering/renderers/DummyRenderer.js +56 -76
- package/dist/cjs/rendering/renderers/SVGRenderer.d.ts +5 -5
- package/dist/cjs/rendering/renderers/SVGRenderer.js +194 -176
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.d.ts +1 -3
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.js +47 -72
- package/dist/cjs/shortcuts/KeyBinding.d.ts +5 -0
- package/dist/cjs/shortcuts/KeyBinding.js +94 -70
- package/dist/cjs/shortcuts/KeyboardShortcutManager.d.ts +1 -1
- package/dist/cjs/shortcuts/KeyboardShortcutManager.js +36 -45
- package/dist/cjs/shortcuts/lib.js +5 -2
- package/dist/cjs/testing/createEditor.js +7 -4
- package/dist/cjs/testing/getUniquePointerId.js +4 -5
- package/dist/cjs/testing/lib.js +5 -2
- package/dist/cjs/testing/sendPenEvent.d.ts +2 -2
- package/dist/cjs/testing/sendPenEvent.js +10 -7
- package/dist/cjs/testing/sendTouchEvent.d.ts +2 -2
- package/dist/cjs/testing/sendTouchEvent.js +34 -16
- package/dist/cjs/toolbar/AbstractToolbar.d.ts +166 -0
- package/dist/cjs/toolbar/AbstractToolbar.js +410 -0
- package/dist/cjs/toolbar/DropdownToolbar.d.ts +43 -0
- package/dist/cjs/toolbar/DropdownToolbar.js +176 -0
- package/dist/cjs/toolbar/EdgeToolbar.d.ts +47 -0
- package/dist/cjs/toolbar/EdgeToolbar.js +422 -0
- package/dist/cjs/toolbar/IconProvider.d.ts +54 -30
- package/dist/cjs/toolbar/IconProvider.js +652 -224
- package/dist/cjs/toolbar/constants.d.ts +1 -0
- package/dist/cjs/toolbar/constants.js +4 -0
- package/dist/cjs/toolbar/lib.d.ts +4 -2
- package/dist/cjs/toolbar/lib.js +10 -3
- package/dist/cjs/toolbar/localization.d.ts +9 -2
- package/dist/cjs/toolbar/localization.js +26 -19
- package/dist/cjs/toolbar/types.d.ts +7 -0
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.js +23 -39
- package/dist/cjs/toolbar/widgets/BaseToolWidget.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/BaseToolWidget.js +35 -37
- package/dist/cjs/toolbar/widgets/BaseWidget.d.ts +60 -5
- package/dist/cjs/toolbar/widgets/BaseWidget.js +232 -177
- package/dist/cjs/toolbar/widgets/DocumentPropertiesWidget.js +130 -117
- package/dist/cjs/toolbar/widgets/EraserToolWidget.d.ts +1 -3
- package/dist/cjs/toolbar/widgets/EraserToolWidget.js +45 -73
- package/dist/cjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
- package/dist/cjs/toolbar/widgets/HandToolWidget.js +126 -141
- package/dist/cjs/toolbar/widgets/InsertImageWidget.d.ts +9 -7
- package/dist/cjs/toolbar/widgets/InsertImageWidget.js +147 -212
- package/dist/cjs/toolbar/widgets/OverflowWidget.js +33 -61
- package/dist/cjs/toolbar/widgets/PenToolWidget.d.ts +8 -1
- package/dist/cjs/toolbar/widgets/PenToolWidget.js +162 -234
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.d.ts +3 -1
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.js +105 -177
- package/dist/cjs/toolbar/widgets/TextToolWidget.js +64 -87
- package/dist/cjs/toolbar/widgets/components/makeColorInput.d.ts +10 -0
- package/dist/cjs/toolbar/{makeColorInput.js → widgets/components/makeColorInput.js} +57 -34
- package/dist/cjs/toolbar/widgets/components/makeFileInput.d.ts +12 -0
- package/dist/cjs/toolbar/widgets/components/makeFileInput.js +111 -0
- package/dist/cjs/toolbar/widgets/components/makeGridSelector.d.ts +24 -0
- package/dist/cjs/toolbar/widgets/components/makeGridSelector.js +127 -0
- package/dist/cjs/toolbar/widgets/components/makeSeparator.d.ts +7 -0
- package/dist/cjs/toolbar/widgets/components/makeSeparator.js +16 -0
- package/dist/cjs/toolbar/widgets/components/makeThicknessSlider.d.ts +8 -0
- package/dist/cjs/toolbar/widgets/components/makeThicknessSlider.js +47 -0
- package/dist/cjs/toolbar/widgets/keybindings.js +8 -5
- package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.d.ts +21 -0
- package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.js +199 -0
- package/dist/cjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.d.ts +14 -0
- package/dist/cjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.js +60 -0
- package/dist/cjs/toolbar/widgets/layout/types.d.ts +63 -0
- package/dist/cjs/toolbar/widgets/layout/types.js +2 -0
- package/dist/cjs/toolbar/widgets/lib.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/lib.js +15 -11
- package/dist/cjs/tools/BaseTool.d.ts +28 -9
- package/dist/cjs/tools/BaseTool.js +128 -51
- package/dist/cjs/tools/Eraser.d.ts +8 -1
- package/dist/cjs/tools/Eraser.js +82 -92
- package/dist/cjs/tools/FindTool.d.ts +1 -1
- package/dist/cjs/tools/FindTool.js +61 -77
- package/dist/cjs/tools/InputFilter/FunctionMapper.d.ts +12 -0
- package/dist/cjs/tools/InputFilter/FunctionMapper.js +21 -0
- package/dist/cjs/tools/InputFilter/InputMapper.d.ts +23 -0
- package/dist/cjs/tools/InputFilter/InputMapper.js +38 -0
- package/dist/cjs/tools/InputFilter/InputPipeline.d.ts +15 -0
- package/dist/cjs/tools/InputFilter/InputPipeline.js +54 -0
- package/dist/cjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
- package/dist/cjs/tools/InputFilter/InputStabilizer.js +181 -0
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.js +84 -0
- package/dist/cjs/tools/PanZoom.d.ts +4 -2
- package/dist/cjs/tools/PanZoom.js +186 -248
- package/dist/cjs/tools/PasteHandler.d.ts +1 -1
- package/dist/cjs/tools/PasteHandler.js +49 -148
- package/dist/cjs/tools/Pen.d.ts +12 -11
- package/dist/cjs/tools/Pen.js +123 -158
- package/dist/cjs/tools/PipetteTool.d.ts +11 -2
- package/dist/cjs/tools/PipetteTool.js +51 -48
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -1
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.js +15 -30
- package/dist/cjs/tools/SelectionTool/Selection.d.ts +5 -5
- package/dist/cjs/tools/SelectionTool/Selection.js +308 -415
- package/dist/cjs/tools/SelectionTool/SelectionHandle.d.ts +15 -5
- package/dist/cjs/tools/SelectionTool/SelectionHandle.js +63 -37
- package/dist/cjs/tools/SelectionTool/SelectionTool.d.ts +4 -4
- package/dist/cjs/tools/SelectionTool/SelectionTool.js +164 -187
- package/dist/cjs/tools/SelectionTool/TransformMode.d.ts +1 -1
- package/dist/cjs/tools/SelectionTool/TransformMode.js +65 -66
- package/dist/cjs/tools/SoundUITool.d.ts +2 -1
- package/dist/cjs/tools/SoundUITool.js +70 -84
- package/dist/cjs/tools/TextTool.d.ts +5 -3
- package/dist/cjs/tools/TextTool.js +169 -173
- package/dist/cjs/tools/ToolController.d.ts +16 -2
- package/dist/cjs/tools/ToolController.js +124 -100
- package/dist/cjs/tools/ToolEnabledGroup.js +6 -9
- package/dist/cjs/tools/ToolSwitcherShortcut.d.ts +1 -1
- package/dist/cjs/tools/ToolSwitcherShortcut.js +16 -32
- package/dist/cjs/tools/ToolbarShortcutHandler.d.ts +1 -1
- package/dist/cjs/tools/ToolbarShortcutHandler.js +17 -33
- package/dist/cjs/tools/UndoRedoShortcut.d.ts +1 -1
- package/dist/cjs/tools/UndoRedoShortcut.js +12 -27
- package/dist/cjs/tools/keybindings.js +21 -18
- package/dist/cjs/tools/lib.js +17 -14
- package/dist/cjs/tools/localization.d.ts +2 -1
- package/dist/cjs/tools/localization.js +8 -7
- package/dist/cjs/types.d.ts +22 -80
- package/dist/cjs/types.js +8 -16
- package/dist/cjs/util/ReactiveValue.d.ts +65 -0
- package/dist/cjs/util/ReactiveValue.js +166 -0
- package/dist/cjs/util/assertions.js +5 -8
- package/dist/cjs/util/fileToBase64.js +6 -6
- package/dist/cjs/util/guessKeyCodeFromKey.d.ts +9 -0
- package/dist/cjs/util/guessKeyCodeFromKey.js +32 -0
- package/dist/cjs/util/listPrefixMatch.d.ts +6 -0
- package/dist/cjs/util/listPrefixMatch.js +17 -0
- package/dist/cjs/util/stopPropagationOfScrollingWheelEvents.d.ts +2 -0
- package/dist/cjs/util/stopPropagationOfScrollingWheelEvents.js +17 -0
- package/dist/cjs/util/untilNextAnimationFrame.js +3 -3
- package/dist/cjs/util/waitForAll.js +3 -3
- package/dist/cjs/util/waitForTimeout.js +3 -3
- package/dist/cjs/version.d.ts +4 -0
- package/dist/cjs/version.js +5 -0
- package/dist/mjs/Editor.d.ts +91 -12
- package/dist/mjs/Editor.mjs +565 -563
- package/dist/mjs/EditorImage.d.ts +5 -2
- package/dist/mjs/EditorImage.mjs +248 -291
- package/dist/mjs/EventDispatcher.mjs +17 -20
- package/dist/mjs/Pointer.d.ts +3 -1
- package/dist/mjs/Pointer.mjs +40 -44
- package/dist/mjs/SVGLoader.d.ts +7 -1
- package/dist/mjs/SVGLoader.mjs +338 -466
- package/dist/mjs/UndoRedoHistory.mjs +27 -39
- package/dist/mjs/Viewport.d.ts +1 -4
- package/dist/mjs/Viewport.mjs +139 -187
- package/dist/mjs/commands/Command.mjs +21 -49
- package/dist/mjs/commands/Duplicate.mjs +22 -41
- package/dist/mjs/commands/Erase.mjs +30 -51
- package/dist/mjs/commands/SerializableCommand.mjs +16 -34
- package/dist/mjs/commands/UnresolvedCommand.mjs +10 -29
- package/dist/mjs/commands/invertCommand.mjs +24 -49
- package/dist/mjs/commands/localization.d.ts +1 -1
- package/dist/mjs/commands/localization.mjs +10 -10
- package/dist/mjs/commands/uniteCommands.mjs +52 -85
- package/dist/mjs/components/AbstractComponent.d.ts +11 -3
- package/dist/mjs/components/AbstractComponent.mjs +135 -166
- package/dist/mjs/components/BackgroundComponent.d.ts +3 -6
- package/dist/mjs/components/BackgroundComponent.mjs +107 -136
- package/dist/mjs/components/ImageComponent.d.ts +3 -5
- package/dist/mjs/components/ImageComponent.mjs +90 -174
- package/dist/mjs/components/RestylableComponent.d.ts +1 -1
- package/dist/mjs/components/RestylableComponent.mjs +35 -53
- package/dist/mjs/components/SVGGlobalAttributesObject.d.ts +1 -3
- package/dist/mjs/components/SVGGlobalAttributesObject.mjs +29 -50
- package/dist/mjs/components/Stroke.d.ts +4 -6
- package/dist/mjs/components/Stroke.mjs +89 -119
- package/dist/mjs/components/TextComponent.d.ts +2 -4
- package/dist/mjs/components/TextComponent.mjs +180 -228
- package/dist/mjs/components/UnknownSVGObject.d.ts +1 -3
- package/dist/mjs/components/UnknownSVGObject.mjs +26 -43
- package/dist/mjs/components/builders/ArrowBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/ArrowBuilder.mjs +32 -35
- package/dist/mjs/components/builders/CircleBuilder.mjs +35 -38
- package/dist/mjs/components/builders/FreehandLineBuilder.d.ts +3 -2
- package/dist/mjs/components/builders/FreehandLineBuilder.mjs +52 -69
- package/dist/mjs/components/builders/LineBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/LineBuilder.mjs +30 -32
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.mjs +103 -115
- package/dist/mjs/components/builders/RectangleBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/RectangleBuilder.mjs +27 -31
- package/dist/mjs/components/builders/types.d.ts +1 -1
- package/dist/mjs/components/lib.d.ts +3 -1
- package/dist/mjs/components/lib.mjs +1 -1
- package/dist/mjs/components/localization.mjs +5 -5
- package/dist/mjs/components/util/StrokeSmoother.d.ts +1 -2
- package/dist/mjs/components/util/StrokeSmoother.mjs +63 -69
- package/dist/mjs/components/util/describeComponentList.d.ts +1 -1
- package/dist/mjs/components/util/describeComponentList.mjs +4 -5
- package/dist/mjs/dialogs/makeAboutDialog.d.ts +15 -0
- package/dist/mjs/dialogs/makeAboutDialog.mjs +52 -0
- package/dist/mjs/inputEvents.d.ts +84 -0
- package/dist/mjs/inputEvents.mjs +34 -0
- package/dist/mjs/lib.d.ts +29 -13
- package/dist/mjs/lib.mjs +30 -13
- package/dist/mjs/localization.mjs +14 -13
- package/dist/mjs/localizations/de.mjs +116 -12
- package/dist/mjs/localizations/en.mjs +3 -12
- package/dist/mjs/localizations/es.mjs +61 -22
- package/dist/mjs/localizations/getLocalizationTable.mjs +12 -13
- package/dist/mjs/rendering/Display.d.ts +1 -2
- package/dist/mjs/rendering/Display.mjs +62 -79
- package/dist/mjs/rendering/RenderablePathSpec.d.ts +15 -0
- package/dist/mjs/rendering/RenderablePathSpec.mjs +64 -0
- package/dist/mjs/rendering/RenderingStyle.d.ts +4 -4
- package/dist/mjs/rendering/RenderingStyle.mjs +16 -26
- package/dist/mjs/rendering/TextRenderingStyle.d.ts +10 -10
- package/dist/mjs/rendering/TextRenderingStyle.mjs +12 -17
- package/dist/mjs/rendering/caching/CacheRecord.d.ts +1 -2
- package/dist/mjs/rendering/caching/CacheRecord.mjs +20 -23
- package/dist/mjs/rendering/caching/CacheRecordManager.d.ts +1 -1
- package/dist/mjs/rendering/caching/CacheRecordManager.mjs +13 -15
- package/dist/mjs/rendering/caching/RenderingCache.mjs +13 -17
- package/dist/mjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
- package/dist/mjs/rendering/caching/RenderingCacheNode.mjs +94 -115
- package/dist/mjs/rendering/caching/testUtils.mjs +19 -21
- package/dist/mjs/rendering/caching/types.d.ts +3 -3
- package/dist/mjs/rendering/localization.mjs +6 -6
- package/dist/mjs/rendering/renderers/AbstractRenderer.d.ts +2 -11
- package/dist/mjs/rendering/renderers/AbstractRenderer.mjs +47 -52
- package/dist/mjs/rendering/renderers/CanvasRenderer.d.ts +3 -5
- package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +84 -103
- package/dist/mjs/rendering/renderers/DummyRenderer.d.ts +1 -4
- package/dist/mjs/rendering/renderers/DummyRenderer.mjs +51 -75
- package/dist/mjs/rendering/renderers/SVGRenderer.d.ts +5 -5
- package/dist/mjs/rendering/renderers/SVGRenderer.mjs +185 -171
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.d.ts +1 -3
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.mjs +43 -72
- package/dist/mjs/shortcuts/KeyBinding.d.ts +5 -0
- package/dist/mjs/shortcuts/KeyBinding.mjs +94 -71
- package/dist/mjs/shortcuts/KeyboardShortcutManager.d.ts +1 -1
- package/dist/mjs/shortcuts/KeyboardShortcutManager.mjs +32 -44
- package/dist/mjs/testing/createEditor.mjs +2 -2
- package/dist/mjs/testing/getUniquePointerId.mjs +4 -5
- package/dist/mjs/testing/sendPenEvent.d.ts +2 -2
- package/dist/mjs/testing/sendPenEvent.mjs +5 -5
- package/dist/mjs/testing/sendTouchEvent.d.ts +2 -2
- package/dist/mjs/testing/sendTouchEvent.mjs +8 -16
- package/dist/mjs/toolbar/AbstractToolbar.d.ts +166 -0
- package/dist/mjs/toolbar/AbstractToolbar.mjs +405 -0
- package/dist/mjs/toolbar/DropdownToolbar.d.ts +43 -0
- package/dist/mjs/toolbar/DropdownToolbar.mjs +168 -0
- package/dist/mjs/toolbar/EdgeToolbar.d.ts +47 -0
- package/dist/mjs/toolbar/EdgeToolbar.mjs +414 -0
- package/dist/mjs/toolbar/IconProvider.d.ts +54 -30
- package/dist/mjs/toolbar/IconProvider.mjs +644 -219
- package/dist/mjs/toolbar/constants.d.ts +1 -0
- package/dist/mjs/toolbar/constants.mjs +1 -0
- package/dist/mjs/toolbar/lib.d.ts +4 -2
- package/dist/mjs/toolbar/lib.mjs +3 -1
- package/dist/mjs/toolbar/localization.d.ts +9 -2
- package/dist/mjs/toolbar/localization.mjs +27 -20
- package/dist/mjs/toolbar/types.d.ts +7 -0
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.mjs +19 -39
- package/dist/mjs/toolbar/widgets/BaseToolWidget.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/BaseToolWidget.mjs +30 -36
- package/dist/mjs/toolbar/widgets/BaseWidget.d.ts +60 -5
- package/dist/mjs/toolbar/widgets/BaseWidget.mjs +227 -176
- package/dist/mjs/toolbar/widgets/DocumentPropertiesWidget.mjs +98 -111
- package/dist/mjs/toolbar/widgets/EraserToolWidget.d.ts +1 -3
- package/dist/mjs/toolbar/widgets/EraserToolWidget.mjs +41 -73
- package/dist/mjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
- package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +94 -136
- package/dist/mjs/toolbar/widgets/InsertImageWidget.d.ts +9 -7
- package/dist/mjs/toolbar/widgets/InsertImageWidget.mjs +140 -208
- package/dist/mjs/toolbar/widgets/OverflowWidget.mjs +30 -62
- package/dist/mjs/toolbar/widgets/PenToolWidget.d.ts +8 -1
- package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +150 -225
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.d.ts +3 -1
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.mjs +97 -173
- package/dist/mjs/toolbar/widgets/TextToolWidget.mjs +59 -85
- package/dist/mjs/toolbar/widgets/components/makeColorInput.d.ts +10 -0
- package/dist/mjs/toolbar/{makeColorInput.mjs → widgets/components/makeColorInput.mjs} +53 -33
- package/dist/mjs/toolbar/widgets/components/makeFileInput.d.ts +12 -0
- package/dist/mjs/toolbar/widgets/components/makeFileInput.mjs +106 -0
- package/dist/mjs/toolbar/widgets/components/makeGridSelector.d.ts +24 -0
- package/dist/mjs/toolbar/widgets/components/makeGridSelector.mjs +122 -0
- package/dist/mjs/toolbar/widgets/components/makeSeparator.d.ts +7 -0
- package/dist/mjs/toolbar/widgets/components/makeSeparator.mjs +14 -0
- package/dist/mjs/toolbar/widgets/components/makeThicknessSlider.d.ts +8 -0
- package/dist/mjs/toolbar/widgets/components/makeThicknessSlider.mjs +45 -0
- package/dist/mjs/toolbar/widgets/keybindings.mjs +5 -5
- package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.d.ts +21 -0
- package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.mjs +193 -0
- package/dist/mjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.d.ts +14 -0
- package/dist/mjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.mjs +57 -0
- package/dist/mjs/toolbar/widgets/layout/types.d.ts +63 -0
- package/dist/mjs/toolbar/widgets/lib.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/lib.mjs +1 -1
- package/dist/mjs/tools/BaseTool.d.ts +28 -9
- package/dist/mjs/tools/BaseTool.mjs +127 -50
- package/dist/mjs/tools/Eraser.d.ts +8 -1
- package/dist/mjs/tools/Eraser.mjs +72 -86
- package/dist/mjs/tools/FindTool.d.ts +1 -1
- package/dist/mjs/tools/FindTool.mjs +55 -75
- package/dist/mjs/tools/InputFilter/FunctionMapper.d.ts +12 -0
- package/dist/mjs/tools/InputFilter/FunctionMapper.mjs +15 -0
- package/dist/mjs/tools/InputFilter/InputMapper.d.ts +23 -0
- package/dist/mjs/tools/InputFilter/InputMapper.mjs +36 -0
- package/dist/mjs/tools/InputFilter/InputPipeline.d.ts +15 -0
- package/dist/mjs/tools/InputFilter/InputPipeline.mjs +49 -0
- package/dist/mjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
- package/dist/mjs/tools/InputFilter/InputStabilizer.mjs +175 -0
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.mjs +78 -0
- package/dist/mjs/tools/PanZoom.d.ts +4 -2
- package/dist/mjs/tools/PanZoom.mjs +169 -235
- package/dist/mjs/tools/PasteHandler.d.ts +1 -1
- package/dist/mjs/tools/PasteHandler.mjs +42 -145
- package/dist/mjs/tools/Pen.d.ts +12 -11
- package/dist/mjs/tools/Pen.mjs +115 -154
- package/dist/mjs/tools/PipetteTool.d.ts +11 -2
- package/dist/mjs/tools/PipetteTool.mjs +47 -48
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -1
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.mjs +9 -28
- package/dist/mjs/tools/SelectionTool/Selection.d.ts +5 -5
- package/dist/mjs/tools/SelectionTool/Selection.mjs +268 -401
- package/dist/mjs/tools/SelectionTool/SelectionHandle.d.ts +15 -5
- package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +62 -37
- package/dist/mjs/tools/SelectionTool/SelectionTool.d.ts +4 -4
- package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +153 -179
- package/dist/mjs/tools/SelectionTool/TransformMode.d.ts +1 -1
- package/dist/mjs/tools/SelectionTool/TransformMode.mjs +52 -59
- package/dist/mjs/tools/SoundUITool.d.ts +2 -1
- package/dist/mjs/tools/SoundUITool.mjs +66 -84
- package/dist/mjs/tools/TextTool.d.ts +5 -3
- package/dist/mjs/tools/TextTool.mjs +155 -163
- package/dist/mjs/tools/ToolController.d.ts +16 -2
- package/dist/mjs/tools/ToolController.mjs +81 -84
- package/dist/mjs/tools/ToolEnabledGroup.mjs +6 -10
- package/dist/mjs/tools/ToolSwitcherShortcut.d.ts +1 -1
- package/dist/mjs/tools/ToolSwitcherShortcut.mjs +12 -32
- package/dist/mjs/tools/ToolbarShortcutHandler.d.ts +1 -1
- package/dist/mjs/tools/ToolbarShortcutHandler.mjs +13 -33
- package/dist/mjs/tools/UndoRedoShortcut.d.ts +1 -1
- package/dist/mjs/tools/UndoRedoShortcut.mjs +7 -26
- package/dist/mjs/tools/keybindings.mjs +34 -34
- package/dist/mjs/tools/localization.d.ts +2 -1
- package/dist/mjs/tools/localization.mjs +9 -8
- package/dist/mjs/types.d.ts +22 -80
- package/dist/mjs/types.mjs +7 -15
- package/dist/mjs/util/ReactiveValue.d.ts +65 -0
- package/dist/mjs/util/ReactiveValue.mjs +161 -0
- package/dist/mjs/util/assertions.mjs +5 -8
- package/dist/mjs/util/fileToBase64.mjs +6 -6
- package/dist/mjs/util/guessKeyCodeFromKey.d.ts +9 -0
- package/dist/mjs/util/guessKeyCodeFromKey.mjs +30 -0
- package/dist/mjs/util/listPrefixMatch.d.ts +6 -0
- package/dist/mjs/util/listPrefixMatch.mjs +15 -0
- package/dist/mjs/util/stopPropagationOfScrollingWheelEvents.d.ts +2 -0
- package/dist/mjs/util/stopPropagationOfScrollingWheelEvents.mjs +15 -0
- package/dist/mjs/util/untilNextAnimationFrame.mjs +3 -3
- package/dist/mjs/util/waitForAll.mjs +3 -3
- package/dist/mjs/util/waitForTimeout.mjs +3 -3
- package/dist/mjs/version.d.ts +4 -0
- package/dist/mjs/version.mjs +3 -0
- package/package.json +11 -22
- package/src/Coloris.css +8 -8
- package/src/Editor.scss +148 -0
- package/src/dialogs/dialogs.scss +36 -0
- package/src/dialogs/makeAboutDialog.scss +41 -0
- package/src/styles.js +1 -1
- package/src/toolbar/{toolbar.css → AbstractToolbar.scss} +47 -85
- package/src/toolbar/DropdownToolbar.scss +46 -0
- package/src/toolbar/EdgeToolbar.scss +511 -0
- package/src/toolbar/toolbar.scss +11 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.scss +7 -0
- package/src/toolbar/widgets/HandToolWidget.scss +14 -0
- package/src/toolbar/widgets/InsertImageWidget.scss +41 -0
- package/src/toolbar/widgets/PenToolWidget.css +0 -51
- package/src/toolbar/widgets/SelectionToolWidget.scss +6 -0
- package/src/toolbar/widgets/components/components.scss +5 -0
- package/src/toolbar/widgets/components/makeColorInput.scss +82 -0
- package/src/toolbar/widgets/components/makeFileInput.scss +77 -0
- package/src/toolbar/widgets/components/makeGridSelector.scss +60 -0
- package/src/toolbar/widgets/components/makeSeparator.scss +14 -0
- package/src/toolbar/widgets/components/makeThicknessSlider.scss +9 -0
- package/src/tools/FindTool.css +3 -3
- package/src/tools/SelectionTool/SelectionTool.css +23 -11
- package/src/tools/tools.scss +4 -0
- package/tsconfig.json +1 -1
- package/typedoc.json +4 -0
- package/dist/cjs/Color4.d.ts +0 -69
- package/dist/cjs/Color4.js +0 -263
- package/dist/cjs/Editor.loadFrom.test.d.ts +0 -1
- package/dist/cjs/Editor.toSVG.test.d.ts +0 -1
- package/dist/cjs/EditorImage.test.d.ts +0 -1
- package/dist/cjs/EventDispatcher.test.d.ts +0 -1
- package/dist/cjs/SVGLoader.test.d.ts +0 -1
- package/dist/cjs/UndoRedoHistory.test.d.ts +0 -1
- package/dist/cjs/commands/uniteCommands.test.d.ts +0 -1
- package/dist/cjs/components/AbstractComponent.transformBy.test.d.ts +0 -1
- package/dist/cjs/components/BackgroundComponent.test.d.ts +0 -1
- package/dist/cjs/components/Stroke.test.d.ts +0 -1
- package/dist/cjs/components/TextComponent.test.d.ts +0 -1
- package/dist/cjs/components/UnknownSVGObject.test.d.ts +0 -1
- package/dist/cjs/components/builders/FreehandLineBuilder.test.d.ts +0 -1
- package/dist/cjs/localizations/getLocalizationTable.test.d.ts +0 -1
- package/dist/cjs/math/Mat33.d.ts +0 -123
- package/dist/cjs/math/Mat33.js +0 -340
- package/dist/cjs/math/Mat33.test.d.ts +0 -1
- package/dist/cjs/math/Vec2.d.ts +0 -33
- package/dist/cjs/math/Vec2.js +0 -37
- package/dist/cjs/math/Vec2.test.d.ts +0 -1
- package/dist/cjs/math/Vec3.d.ts +0 -106
- package/dist/cjs/math/Vec3.js +0 -183
- package/dist/cjs/math/Vec3.test.d.ts +0 -1
- package/dist/cjs/math/lib.d.ts +0 -7
- package/dist/cjs/math/lib.js +0 -15
- package/dist/cjs/math/polynomial/solveQuadratic.d.ts +0 -9
- package/dist/cjs/math/polynomial/solveQuadratic.js +0 -39
- package/dist/cjs/math/polynomial/solveQuadratic.test.d.ts +0 -1
- package/dist/cjs/math/rounding.d.ts +0 -4
- package/dist/cjs/math/rounding.js +0 -140
- package/dist/cjs/math/rounding.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Abstract2DShape.d.ts +0 -49
- package/dist/cjs/math/shapes/Abstract2DShape.js +0 -42
- package/dist/cjs/math/shapes/BezierJSWrapper.d.ts +0 -36
- package/dist/cjs/math/shapes/BezierJSWrapper.js +0 -109
- package/dist/cjs/math/shapes/CubicBezier.d.ts +0 -17
- package/dist/cjs/math/shapes/CubicBezier.js +0 -50
- package/dist/cjs/math/shapes/LineSegment2.d.ts +0 -70
- package/dist/cjs/math/shapes/LineSegment2.js +0 -204
- package/dist/cjs/math/shapes/LineSegment2.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Path.d.ts +0 -93
- package/dist/cjs/math/shapes/Path.fromString.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Path.js +0 -865
- package/dist/cjs/math/shapes/Path.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Path.toString.test.d.ts +0 -1
- package/dist/cjs/math/shapes/PointShape2D.d.ts +0 -18
- package/dist/cjs/math/shapes/PointShape2D.js +0 -46
- package/dist/cjs/math/shapes/QuadraticBezier.d.ts +0 -34
- package/dist/cjs/math/shapes/QuadraticBezier.js +0 -133
- package/dist/cjs/math/shapes/QuadraticBezier.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Rect2.d.ts +0 -57
- package/dist/cjs/math/shapes/Rect2.js +0 -311
- package/dist/cjs/math/shapes/Rect2.test.d.ts +0 -1
- package/dist/cjs/math/shapes/Triangle.d.ts +0 -46
- package/dist/cjs/math/shapes/Triangle.js +0 -148
- package/dist/cjs/math/shapes/Triangle.test.d.ts +0 -1
- package/dist/cjs/rendering/RenderingStyle.test.d.ts +0 -1
- package/dist/cjs/rendering/caching/CacheRecord.test.d.ts +0 -1
- package/dist/cjs/rendering/caching/RenderingCache.test.d.ts +0 -1
- package/dist/cjs/rendering/renderers/DummyRenderer.test.d.ts +0 -1
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.test.d.ts +0 -1
- package/dist/cjs/shortcuts/KeyBinding.test.d.ts +0 -1
- package/dist/cjs/shortcuts/KeyboardShortcutManager.test.d.ts +0 -1
- package/dist/cjs/toolbar/HTMLToolbar.d.ts +0 -105
- package/dist/cjs/toolbar/HTMLToolbar.js +0 -465
- package/dist/cjs/toolbar/makeColorInput.d.ts +0 -6
- package/dist/cjs/tools/Eraser.test.d.ts +0 -1
- package/dist/cjs/tools/PanZoom.test.d.ts +0 -1
- package/dist/cjs/tools/Pen.test.d.ts +0 -1
- package/dist/cjs/tools/SelectionTool/SelectionTool.test.d.ts +0 -1
- package/dist/cjs/tools/UndoRedoShortcut.test.d.ts +0 -1
- package/dist/mjs/Color4.d.ts +0 -69
- package/dist/mjs/Color4.mjs +0 -260
- package/dist/mjs/Color4.test.d.ts +0 -1
- package/dist/mjs/Editor.loadFrom.test.d.ts +0 -1
- package/dist/mjs/Editor.toSVG.test.d.ts +0 -1
- package/dist/mjs/EditorImage.test.d.ts +0 -1
- package/dist/mjs/EventDispatcher.test.d.ts +0 -1
- package/dist/mjs/SVGLoader.test.d.ts +0 -1
- package/dist/mjs/UndoRedoHistory.test.d.ts +0 -1
- package/dist/mjs/commands/uniteCommands.test.d.ts +0 -1
- package/dist/mjs/components/AbstractComponent.transformBy.test.d.ts +0 -1
- package/dist/mjs/components/BackgroundComponent.test.d.ts +0 -1
- package/dist/mjs/components/Stroke.test.d.ts +0 -1
- package/dist/mjs/components/TextComponent.test.d.ts +0 -1
- package/dist/mjs/components/UnknownSVGObject.test.d.ts +0 -1
- package/dist/mjs/components/builders/FreehandLineBuilder.test.d.ts +0 -1
- package/dist/mjs/localizations/getLocalizationTable.test.d.ts +0 -1
- package/dist/mjs/math/Mat33.d.ts +0 -123
- package/dist/mjs/math/Mat33.mjs +0 -338
- package/dist/mjs/math/Mat33.test.d.ts +0 -1
- package/dist/mjs/math/Vec2.d.ts +0 -33
- package/dist/mjs/math/Vec2.mjs +0 -34
- package/dist/mjs/math/Vec2.test.d.ts +0 -1
- package/dist/mjs/math/Vec3.d.ts +0 -106
- package/dist/mjs/math/Vec3.mjs +0 -181
- package/dist/mjs/math/Vec3.test.d.ts +0 -1
- package/dist/mjs/math/lib.d.ts +0 -7
- package/dist/mjs/math/lib.mjs +0 -7
- package/dist/mjs/math/polynomial/solveQuadratic.d.ts +0 -9
- package/dist/mjs/math/polynomial/solveQuadratic.mjs +0 -37
- package/dist/mjs/math/polynomial/solveQuadratic.test.d.ts +0 -1
- package/dist/mjs/math/rounding.d.ts +0 -4
- package/dist/mjs/math/rounding.mjs +0 -133
- package/dist/mjs/math/rounding.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Abstract2DShape.d.ts +0 -49
- package/dist/mjs/math/shapes/Abstract2DShape.mjs +0 -40
- package/dist/mjs/math/shapes/BezierJSWrapper.d.ts +0 -36
- package/dist/mjs/math/shapes/BezierJSWrapper.mjs +0 -107
- package/dist/mjs/math/shapes/CubicBezier.d.ts +0 -17
- package/dist/mjs/math/shapes/CubicBezier.mjs +0 -48
- package/dist/mjs/math/shapes/LineSegment2.d.ts +0 -70
- package/dist/mjs/math/shapes/LineSegment2.mjs +0 -202
- package/dist/mjs/math/shapes/LineSegment2.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Path.d.ts +0 -93
- package/dist/mjs/math/shapes/Path.fromString.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Path.mjs +0 -862
- package/dist/mjs/math/shapes/Path.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Path.toString.test.d.ts +0 -1
- package/dist/mjs/math/shapes/PointShape2D.d.ts +0 -18
- package/dist/mjs/math/shapes/PointShape2D.mjs +0 -44
- package/dist/mjs/math/shapes/QuadraticBezier.d.ts +0 -34
- package/dist/mjs/math/shapes/QuadraticBezier.mjs +0 -131
- package/dist/mjs/math/shapes/QuadraticBezier.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Rect2.d.ts +0 -57
- package/dist/mjs/math/shapes/Rect2.mjs +0 -309
- package/dist/mjs/math/shapes/Rect2.test.d.ts +0 -1
- package/dist/mjs/math/shapes/Triangle.d.ts +0 -46
- package/dist/mjs/math/shapes/Triangle.mjs +0 -146
- package/dist/mjs/math/shapes/Triangle.test.d.ts +0 -1
- package/dist/mjs/rendering/RenderingStyle.test.d.ts +0 -1
- package/dist/mjs/rendering/caching/CacheRecord.test.d.ts +0 -1
- package/dist/mjs/rendering/caching/RenderingCache.test.d.ts +0 -1
- package/dist/mjs/rendering/renderers/DummyRenderer.test.d.ts +0 -1
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.test.d.ts +0 -1
- package/dist/mjs/shortcuts/KeyBinding.test.d.ts +0 -1
- package/dist/mjs/shortcuts/KeyboardShortcutManager.test.d.ts +0 -1
- package/dist/mjs/toolbar/HTMLToolbar.d.ts +0 -105
- package/dist/mjs/toolbar/HTMLToolbar.mjs +0 -462
- package/dist/mjs/toolbar/makeColorInput.d.ts +0 -6
- package/dist/mjs/tools/Eraser.test.d.ts +0 -1
- package/dist/mjs/tools/PanZoom.test.d.ts +0 -1
- package/dist/mjs/tools/Pen.test.d.ts +0 -1
- package/dist/mjs/tools/SelectionTool/SelectionTool.test.d.ts +0 -1
- package/dist/mjs/tools/UndoRedoShortcut.test.d.ts +0 -1
- package/dist-test/test_imports/package-lock.json +0 -13
- package/dist-test/test_imports/package.json +0 -12
- package/dist-test/test_imports/test-imports.js +0 -17
- package/dist-test/test_imports/test-require.cjs +0 -19
- package/src/Color4.test.ts +0 -47
- package/src/Color4.ts +0 -304
- package/src/Editor.css +0 -98
- package/src/Editor.loadFrom.test.ts +0 -24
- package/src/Editor.toSVG.test.ts +0 -111
- package/src/Editor.ts +0 -1171
- package/src/EditorImage.test.ts +0 -120
- package/src/EditorImage.ts +0 -603
- package/src/EventDispatcher.test.ts +0 -123
- package/src/EventDispatcher.ts +0 -72
- package/src/Pointer.ts +0 -170
- package/src/SVGLoader.test.ts +0 -114
- package/src/SVGLoader.ts +0 -610
- package/src/UndoRedoHistory.test.ts +0 -33
- package/src/UndoRedoHistory.ts +0 -102
- package/src/Viewport.ts +0 -325
- package/src/bundle/bundled.ts +0 -7
- package/src/commands/Command.ts +0 -45
- package/src/commands/Duplicate.ts +0 -75
- package/src/commands/Erase.ts +0 -94
- package/src/commands/SerializableCommand.ts +0 -49
- package/src/commands/UnresolvedCommand.ts +0 -37
- package/src/commands/invertCommand.ts +0 -58
- package/src/commands/lib.ts +0 -16
- package/src/commands/localization.ts +0 -47
- package/src/commands/uniteCommands.test.ts +0 -23
- package/src/commands/uniteCommands.ts +0 -140
- package/src/components/AbstractComponent.transformBy.test.ts +0 -22
- package/src/components/AbstractComponent.ts +0 -374
- package/src/components/BackgroundComponent.test.ts +0 -45
- package/src/components/BackgroundComponent.ts +0 -353
- package/src/components/ImageComponent.ts +0 -178
- package/src/components/RestylableComponent.ts +0 -161
- package/src/components/SVGGlobalAttributesObject.ts +0 -81
- package/src/components/Stroke.test.ts +0 -139
- package/src/components/Stroke.ts +0 -296
- package/src/components/TextComponent.test.ts +0 -204
- package/src/components/TextComponent.ts +0 -432
- package/src/components/UnknownSVGObject.test.ts +0 -10
- package/src/components/UnknownSVGObject.ts +0 -60
- package/src/components/builders/ArrowBuilder.ts +0 -107
- package/src/components/builders/CircleBuilder.ts +0 -102
- package/src/components/builders/FreehandLineBuilder.test.ts +0 -25
- package/src/components/builders/FreehandLineBuilder.ts +0 -212
- package/src/components/builders/LineBuilder.ts +0 -77
- package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +0 -454
- package/src/components/builders/RectangleBuilder.ts +0 -74
- package/src/components/builders/types.ts +0 -15
- package/src/components/lib.ts +0 -31
- package/src/components/localization.ts +0 -24
- package/src/components/util/StrokeSmoother.ts +0 -302
- package/src/components/util/describeComponentList.ts +0 -18
- package/src/lib.ts +0 -69
- package/src/localization.ts +0 -34
- package/src/localizations/de.ts +0 -146
- package/src/localizations/en.ts +0 -8
- package/src/localizations/es.ts +0 -74
- package/src/localizations/getLocalizationTable.test.ts +0 -27
- package/src/localizations/getLocalizationTable.ts +0 -74
- package/src/math/Mat33.test.ts +0 -244
- package/src/math/Mat33.ts +0 -442
- package/src/math/Vec2.test.ts +0 -30
- package/src/math/Vec2.ts +0 -40
- package/src/math/Vec3.test.ts +0 -44
- package/src/math/Vec3.ts +0 -218
- package/src/math/lib.ts +0 -15
- package/src/math/polynomial/solveQuadratic.test.ts +0 -39
- package/src/math/polynomial/solveQuadratic.ts +0 -43
- package/src/math/rounding.test.ts +0 -65
- package/src/math/rounding.ts +0 -156
- package/src/math/shapes/Abstract2DShape.ts +0 -63
- package/src/math/shapes/BezierJSWrapper.ts +0 -93
- package/src/math/shapes/CubicBezier.ts +0 -35
- package/src/math/shapes/LineSegment2.test.ts +0 -99
- package/src/math/shapes/LineSegment2.ts +0 -231
- package/src/math/shapes/Path.fromString.test.ts +0 -223
- package/src/math/shapes/Path.test.ts +0 -309
- package/src/math/shapes/Path.toString.test.ts +0 -77
- package/src/math/shapes/Path.ts +0 -1027
- package/src/math/shapes/PointShape2D.ts +0 -33
- package/src/math/shapes/QuadraticBezier.test.ts +0 -31
- package/src/math/shapes/QuadraticBezier.ts +0 -141
- package/src/math/shapes/Rect2.test.ts +0 -209
- package/src/math/shapes/Rect2.ts +0 -344
- package/src/math/shapes/Triangle.test.ts +0 -61
- package/src/math/shapes/Triangle.ts +0 -139
- package/src/rendering/Display.ts +0 -248
- package/src/rendering/RenderingStyle.test.ts +0 -68
- package/src/rendering/RenderingStyle.ts +0 -55
- package/src/rendering/TextRenderingStyle.ts +0 -55
- package/src/rendering/caching/CacheRecord.test.ts +0 -49
- package/src/rendering/caching/CacheRecord.ts +0 -77
- package/src/rendering/caching/CacheRecordManager.ts +0 -71
- package/src/rendering/caching/RenderingCache.test.ts +0 -44
- package/src/rendering/caching/RenderingCache.ts +0 -66
- package/src/rendering/caching/RenderingCacheNode.ts +0 -405
- package/src/rendering/caching/testUtils.ts +0 -35
- package/src/rendering/caching/types.ts +0 -34
- package/src/rendering/lib.ts +0 -8
- package/src/rendering/localization.ts +0 -20
- package/src/rendering/renderers/AbstractRenderer.ts +0 -242
- package/src/rendering/renderers/CanvasRenderer.ts +0 -307
- package/src/rendering/renderers/DummyRenderer.test.ts +0 -42
- package/src/rendering/renderers/DummyRenderer.ts +0 -145
- package/src/rendering/renderers/SVGRenderer.ts +0 -377
- package/src/rendering/renderers/TextOnlyRenderer.test.ts +0 -34
- package/src/rendering/renderers/TextOnlyRenderer.ts +0 -71
- package/src/shortcuts/KeyBinding.test.ts +0 -51
- package/src/shortcuts/KeyBinding.ts +0 -218
- package/src/shortcuts/KeyboardShortcutManager.test.ts +0 -95
- package/src/shortcuts/KeyboardShortcutManager.ts +0 -163
- package/src/shortcuts/lib.ts +0 -3
- package/src/testing/createEditor.ts +0 -11
- package/src/testing/getUniquePointerId.ts +0 -18
- package/src/testing/lib.ts +0 -3
- package/src/testing/sendPenEvent.ts +0 -36
- package/src/testing/sendTouchEvent.ts +0 -71
- package/src/toolbar/HTMLToolbar.ts +0 -567
- package/src/toolbar/IconProvider.ts +0 -805
- package/src/toolbar/lib.ts +0 -4
- package/src/toolbar/localization.ts +0 -114
- package/src/toolbar/makeColorInput.ts +0 -159
- package/src/toolbar/types.ts +0 -5
- package/src/toolbar/widgets/ActionButtonWidget.ts +0 -39
- package/src/toolbar/widgets/BaseToolWidget.ts +0 -65
- package/src/toolbar/widgets/BaseWidget.ts +0 -428
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +0 -234
- package/src/toolbar/widgets/EraserToolWidget.ts +0 -85
- package/src/toolbar/widgets/HandToolWidget.ts +0 -250
- package/src/toolbar/widgets/InsertImageWidget.css +0 -44
- package/src/toolbar/widgets/InsertImageWidget.ts +0 -223
- package/src/toolbar/widgets/OverflowWidget.ts +0 -92
- package/src/toolbar/widgets/PenToolWidget.ts +0 -409
- package/src/toolbar/widgets/SelectionToolWidget.ts +0 -197
- package/src/toolbar/widgets/TextToolWidget.ts +0 -145
- package/src/toolbar/widgets/keybindings.ts +0 -21
- package/src/toolbar/widgets/lib.ts +0 -13
- package/src/tools/BaseTool.ts +0 -97
- package/src/tools/Eraser.test.ts +0 -103
- package/src/tools/Eraser.ts +0 -160
- package/src/tools/FindTool.ts +0 -153
- package/src/tools/PanZoom.test.ts +0 -349
- package/src/tools/PanZoom.ts +0 -502
- package/src/tools/PasteHandler.ts +0 -95
- package/src/tools/Pen.test.ts +0 -262
- package/src/tools/Pen.ts +0 -300
- package/src/tools/PipetteTool.ts +0 -55
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +0 -29
- package/src/tools/SelectionTool/Selection.ts +0 -611
- package/src/tools/SelectionTool/SelectionHandle.ts +0 -108
- package/src/tools/SelectionTool/SelectionTool.test.ts +0 -261
- package/src/tools/SelectionTool/SelectionTool.ts +0 -496
- package/src/tools/SelectionTool/TransformMode.ts +0 -114
- package/src/tools/SelectionTool/types.ts +0 -11
- package/src/tools/SoundUITool.ts +0 -212
- package/src/tools/TextTool.ts +0 -340
- package/src/tools/ToolController.ts +0 -200
- package/src/tools/ToolEnabledGroup.ts +0 -14
- package/src/tools/ToolSwitcherShortcut.ts +0 -39
- package/src/tools/ToolbarShortcutHandler.ts +0 -39
- package/src/tools/UndoRedoShortcut.test.ts +0 -56
- package/src/tools/UndoRedoShortcut.ts +0 -24
- package/src/tools/keybindings.ts +0 -85
- package/src/tools/lib.ts +0 -22
- package/src/tools/localization.ts +0 -74
- package/src/tools/tools.css +0 -4
- package/src/types.ts +0 -239
- package/src/util/assertions.ts +0 -55
- package/src/util/fileToBase64.ts +0 -18
- package/src/util/untilNextAnimationFrame.ts +0 -9
- package/src/util/waitForAll.ts +0 -18
- package/src/util/waitForTimeout.ts +0 -9
- /package/dist/{cjs/Color4.test.d.ts → mjs/toolbar/widgets/layout/types.mjs} +0 -0
@@ -1,865 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
4
|
-
if (ar || !(i in from)) {
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
6
|
-
ar[i] = from[i];
|
7
|
-
}
|
8
|
-
}
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.PathCommandType = void 0;
|
13
|
-
var rounding_1 = require("../rounding");
|
14
|
-
var LineSegment2_1 = require("./LineSegment2");
|
15
|
-
var Mat33_1 = require("../Mat33");
|
16
|
-
var Rect2_1 = require("./Rect2");
|
17
|
-
var Vec2_1 = require("../Vec2");
|
18
|
-
var CubicBezier_1 = require("./CubicBezier");
|
19
|
-
var QuadraticBezier_1 = require("./QuadraticBezier");
|
20
|
-
var PointShape2D_1 = require("./PointShape2D");
|
21
|
-
var PathCommandType;
|
22
|
-
(function (PathCommandType) {
|
23
|
-
PathCommandType[PathCommandType["LineTo"] = 0] = "LineTo";
|
24
|
-
PathCommandType[PathCommandType["MoveTo"] = 1] = "MoveTo";
|
25
|
-
PathCommandType[PathCommandType["CubicBezierTo"] = 2] = "CubicBezierTo";
|
26
|
-
PathCommandType[PathCommandType["QuadraticBezierTo"] = 3] = "QuadraticBezierTo";
|
27
|
-
})(PathCommandType || (exports.PathCommandType = PathCommandType = {}));
|
28
|
-
var Path = /** @class */ (function () {
|
29
|
-
function Path(startPoint, parts) {
|
30
|
-
this.startPoint = startPoint;
|
31
|
-
this.parts = parts;
|
32
|
-
this.cachedGeometry = null;
|
33
|
-
this.cachedPolylineApproximation = null;
|
34
|
-
this.cachedStringVersion = null;
|
35
|
-
// Initial bounding box contains one point: the start point.
|
36
|
-
this.bbox = Rect2_1.default.bboxOf([startPoint]);
|
37
|
-
// Convert into a representation of the geometry (cache for faster intersection
|
38
|
-
// calculation)
|
39
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
40
|
-
var part = parts_1[_i];
|
41
|
-
this.bbox = this.bbox.union(Path.computeBBoxForSegment(startPoint, part));
|
42
|
-
}
|
43
|
-
}
|
44
|
-
Path.prototype.getExactBBox = function () {
|
45
|
-
var bboxes = [];
|
46
|
-
for (var _i = 0, _a = this.geometry; _i < _a.length; _i++) {
|
47
|
-
var part = _a[_i];
|
48
|
-
bboxes.push(part.getTightBoundingBox());
|
49
|
-
}
|
50
|
-
return Rect2_1.default.union.apply(Rect2_1.default, bboxes);
|
51
|
-
};
|
52
|
-
Object.defineProperty(Path.prototype, "geometry", {
|
53
|
-
// Lazy-loads and returns this path's geometry
|
54
|
-
get: function () {
|
55
|
-
if (this.cachedGeometry) {
|
56
|
-
return this.cachedGeometry;
|
57
|
-
}
|
58
|
-
var startPoint = this.startPoint;
|
59
|
-
var geometry = [];
|
60
|
-
for (var _i = 0, _a = this.parts; _i < _a.length; _i++) {
|
61
|
-
var part = _a[_i];
|
62
|
-
switch (part.kind) {
|
63
|
-
case PathCommandType.CubicBezierTo:
|
64
|
-
geometry.push(new CubicBezier_1.default(startPoint, part.controlPoint1, part.controlPoint2, part.endPoint));
|
65
|
-
startPoint = part.endPoint;
|
66
|
-
break;
|
67
|
-
case PathCommandType.QuadraticBezierTo:
|
68
|
-
geometry.push(new QuadraticBezier_1.default(startPoint, part.controlPoint, part.endPoint));
|
69
|
-
startPoint = part.endPoint;
|
70
|
-
break;
|
71
|
-
case PathCommandType.LineTo:
|
72
|
-
geometry.push(new LineSegment2_1.default(startPoint, part.point));
|
73
|
-
startPoint = part.point;
|
74
|
-
break;
|
75
|
-
case PathCommandType.MoveTo:
|
76
|
-
geometry.push(new PointShape2D_1.default(part.point));
|
77
|
-
startPoint = part.point;
|
78
|
-
break;
|
79
|
-
}
|
80
|
-
}
|
81
|
-
this.cachedGeometry = geometry;
|
82
|
-
return this.cachedGeometry;
|
83
|
-
},
|
84
|
-
enumerable: false,
|
85
|
-
configurable: true
|
86
|
-
});
|
87
|
-
// Approximates this path with a group of line segments.
|
88
|
-
Path.prototype.polylineApproximation = function () {
|
89
|
-
if (this.cachedPolylineApproximation) {
|
90
|
-
return this.cachedPolylineApproximation;
|
91
|
-
}
|
92
|
-
var points = [];
|
93
|
-
for (var _i = 0, _a = this.parts; _i < _a.length; _i++) {
|
94
|
-
var part = _a[_i];
|
95
|
-
switch (part.kind) {
|
96
|
-
case PathCommandType.CubicBezierTo:
|
97
|
-
points.push(part.controlPoint1, part.controlPoint2, part.endPoint);
|
98
|
-
break;
|
99
|
-
case PathCommandType.QuadraticBezierTo:
|
100
|
-
points.push(part.controlPoint, part.endPoint);
|
101
|
-
break;
|
102
|
-
case PathCommandType.MoveTo:
|
103
|
-
case PathCommandType.LineTo:
|
104
|
-
points.push(part.point);
|
105
|
-
break;
|
106
|
-
}
|
107
|
-
}
|
108
|
-
var result = [];
|
109
|
-
var prevPoint = this.startPoint;
|
110
|
-
for (var _b = 0, points_1 = points; _b < points_1.length; _b++) {
|
111
|
-
var point = points_1[_b];
|
112
|
-
result.push(new LineSegment2_1.default(prevPoint, point));
|
113
|
-
prevPoint = point;
|
114
|
-
}
|
115
|
-
return result;
|
116
|
-
};
|
117
|
-
Path.computeBBoxForSegment = function (startPoint, part) {
|
118
|
-
var points = [startPoint];
|
119
|
-
var exhaustivenessCheck;
|
120
|
-
switch (part.kind) {
|
121
|
-
case PathCommandType.MoveTo:
|
122
|
-
case PathCommandType.LineTo:
|
123
|
-
points.push(part.point);
|
124
|
-
break;
|
125
|
-
case PathCommandType.CubicBezierTo:
|
126
|
-
points.push(part.controlPoint1, part.controlPoint2, part.endPoint);
|
127
|
-
break;
|
128
|
-
case PathCommandType.QuadraticBezierTo:
|
129
|
-
points.push(part.controlPoint, part.endPoint);
|
130
|
-
break;
|
131
|
-
default:
|
132
|
-
exhaustivenessCheck = part;
|
133
|
-
return exhaustivenessCheck;
|
134
|
-
}
|
135
|
-
return Rect2_1.default.bboxOf(points);
|
136
|
-
};
|
137
|
-
/**
|
138
|
-
* Let `S` be a closed path a distance `strokeRadius` from this path.
|
139
|
-
*
|
140
|
-
* @returns Approximate intersections of `line` with `S` using ray marching, starting from
|
141
|
-
* both end points of `line` and each point in `additionalRaymarchStartPoints`.
|
142
|
-
*/
|
143
|
-
Path.prototype.raymarchIntersectionWith = function (line, strokeRadius, additionalRaymarchStartPoints) {
|
144
|
-
var _a, _b;
|
145
|
-
if (additionalRaymarchStartPoints === void 0) { additionalRaymarchStartPoints = []; }
|
146
|
-
// No intersection between bounding boxes: No possible intersection
|
147
|
-
// of the interior.
|
148
|
-
if (!line.bbox.intersects(this.bbox.grownBy(strokeRadius))) {
|
149
|
-
return [];
|
150
|
-
}
|
151
|
-
var lineLength = line.length;
|
152
|
-
var partDistFunctionRecords = [];
|
153
|
-
var _loop_1 = function (part) {
|
154
|
-
var bbox = part.getTightBoundingBox().grownBy(strokeRadius);
|
155
|
-
if (!bbox.intersects(line.bbox)) {
|
156
|
-
return "continue";
|
157
|
-
}
|
158
|
-
// Signed distance function
|
159
|
-
var partDist = function (point) { return part.signedDistance(point); };
|
160
|
-
// Part signed distance function (negative result implies `point` is
|
161
|
-
// inside the shape).
|
162
|
-
var partSdf = function (point) { return partDist(point) - strokeRadius; };
|
163
|
-
// If the line can't possibly intersect the part,
|
164
|
-
if (partSdf(line.p1) > lineLength && partSdf(line.p2) > lineLength) {
|
165
|
-
return "continue";
|
166
|
-
}
|
167
|
-
partDistFunctionRecords.push({
|
168
|
-
part: part,
|
169
|
-
distFn: partDist,
|
170
|
-
bbox: bbox,
|
171
|
-
});
|
172
|
-
};
|
173
|
-
// Determine distance functions for all parts that the given line could possibly intersect with
|
174
|
-
for (var _i = 0, _c = this.geometry; _i < _c.length; _i++) {
|
175
|
-
var part = _c[_i];
|
176
|
-
_loop_1(part);
|
177
|
-
}
|
178
|
-
// If no distance functions, there are no intersections.
|
179
|
-
if (partDistFunctionRecords.length === 0) {
|
180
|
-
return [];
|
181
|
-
}
|
182
|
-
// Returns the minimum distance to a part in this stroke, where only parts that the given
|
183
|
-
// line could intersect are considered.
|
184
|
-
var sdf = function (point) {
|
185
|
-
var minDist = Infinity;
|
186
|
-
var minDistPart = null;
|
187
|
-
var uncheckedDistFunctions = [];
|
188
|
-
// First pass: only curves for which the current point is inside
|
189
|
-
// the bounding box.
|
190
|
-
for (var _i = 0, partDistFunctionRecords_1 = partDistFunctionRecords; _i < partDistFunctionRecords_1.length; _i++) {
|
191
|
-
var distFnRecord = partDistFunctionRecords_1[_i];
|
192
|
-
var part = distFnRecord.part, distFn = distFnRecord.distFn, bbox = distFnRecord.bbox;
|
193
|
-
// Check later if the current point isn't in the bounding box.
|
194
|
-
if (!bbox.containsPoint(point)) {
|
195
|
-
uncheckedDistFunctions.push(distFnRecord);
|
196
|
-
continue;
|
197
|
-
}
|
198
|
-
var currentDist = distFn(point);
|
199
|
-
if (currentDist <= minDist) {
|
200
|
-
minDist = currentDist;
|
201
|
-
minDistPart = part;
|
202
|
-
}
|
203
|
-
}
|
204
|
-
// Second pass: Everything else
|
205
|
-
for (var _a = 0, uncheckedDistFunctions_1 = uncheckedDistFunctions; _a < uncheckedDistFunctions_1.length; _a++) {
|
206
|
-
var _b = uncheckedDistFunctions_1[_a], part = _b.part, distFn = _b.distFn, bbox = _b.bbox;
|
207
|
-
// Skip if impossible for the distance to the target to be lesser than
|
208
|
-
// the current minimum.
|
209
|
-
if (!bbox.grownBy(minDist).containsPoint(point)) {
|
210
|
-
continue;
|
211
|
-
}
|
212
|
-
var currentDist = distFn(point);
|
213
|
-
if (currentDist <= minDist) {
|
214
|
-
minDist = currentDist;
|
215
|
-
minDistPart = part;
|
216
|
-
}
|
217
|
-
}
|
218
|
-
return [minDistPart, minDist - strokeRadius];
|
219
|
-
};
|
220
|
-
// Raymarch:
|
221
|
-
var maxRaymarchSteps = 7;
|
222
|
-
// Start raymarching from each of these points. This allows detection of multiple
|
223
|
-
// intersections.
|
224
|
-
var startPoints = __spreadArray(__spreadArray([
|
225
|
-
line.p1
|
226
|
-
], additionalRaymarchStartPoints, true), [
|
227
|
-
line.p2
|
228
|
-
], false);
|
229
|
-
// Converts a point ON THE LINE to a parameter
|
230
|
-
var pointToParameter = function (point) {
|
231
|
-
// Because line.direction is a unit vector, this computes the length
|
232
|
-
// of the projection of the vector(line.p1->point) onto line.direction.
|
233
|
-
//
|
234
|
-
// Note that this can be negative if the given point is outside of the given
|
235
|
-
// line segment.
|
236
|
-
return point.minus(line.p1).dot(line.direction);
|
237
|
-
};
|
238
|
-
// Sort start points by parameter on the line.
|
239
|
-
// This allows us to determine whether the current value of a parameter
|
240
|
-
// drops down to a value already tested.
|
241
|
-
startPoints.sort(function (a, b) {
|
242
|
-
var t_a = pointToParameter(a);
|
243
|
-
var t_b = pointToParameter(b);
|
244
|
-
// Sort in increasing order
|
245
|
-
return t_a - t_b;
|
246
|
-
});
|
247
|
-
var result = [];
|
248
|
-
var stoppingThreshold = strokeRadius / 1000;
|
249
|
-
// Returns the maximum x value explored
|
250
|
-
var raymarchFrom = function (startPoint,
|
251
|
-
// Direction to march in (multiplies line.direction)
|
252
|
-
directionMultiplier,
|
253
|
-
// Terminate if the current point corresponds to a parameter
|
254
|
-
// below this.
|
255
|
-
minimumLineParameter) {
|
256
|
-
var currentPoint = startPoint;
|
257
|
-
var _a = sdf(currentPoint), lastPart = _a[0], lastDist = _a[1];
|
258
|
-
var lastParameter = pointToParameter(currentPoint);
|
259
|
-
if (lastDist > lineLength) {
|
260
|
-
return lastParameter;
|
261
|
-
}
|
262
|
-
var direction = line.direction.times(directionMultiplier);
|
263
|
-
for (var i = 0; i < maxRaymarchSteps; i++) {
|
264
|
-
// Step in the direction of the edge of the shape.
|
265
|
-
var step = lastDist;
|
266
|
-
currentPoint = currentPoint.plus(direction.times(step));
|
267
|
-
lastParameter = pointToParameter(currentPoint);
|
268
|
-
// If we're below the minimum parameter, stop. We've already tried
|
269
|
-
// this.
|
270
|
-
if (lastParameter <= minimumLineParameter) {
|
271
|
-
return lastParameter;
|
272
|
-
}
|
273
|
-
var _b = sdf(currentPoint), currentPart = _b[0], signedDist = _b[1];
|
274
|
-
// Ensure we're stepping in the correct direction.
|
275
|
-
// Note that because we could start with a negative distance and work towards a
|
276
|
-
// positive distance, we need absolute values here.
|
277
|
-
if (Math.abs(signedDist) > Math.abs(lastDist)) {
|
278
|
-
// If not, stop.
|
279
|
-
return null;
|
280
|
-
}
|
281
|
-
lastDist = signedDist;
|
282
|
-
lastPart = currentPart;
|
283
|
-
// Is the distance close enough that we can stop early?
|
284
|
-
if (Math.abs(lastDist) < stoppingThreshold) {
|
285
|
-
break;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
// Ensure that the point we ended with is on the line.
|
289
|
-
var isOnLineSegment = lastParameter >= 0 && lastParameter <= lineLength;
|
290
|
-
if (lastPart && isOnLineSegment && Math.abs(lastDist) < stoppingThreshold) {
|
291
|
-
result.push({
|
292
|
-
point: currentPoint,
|
293
|
-
parameterValue: NaN,
|
294
|
-
curve: lastPart,
|
295
|
-
});
|
296
|
-
}
|
297
|
-
return lastParameter;
|
298
|
-
};
|
299
|
-
// The maximum value of the line's parameter explored so far (0 corresponds to
|
300
|
-
// line.p1)
|
301
|
-
var maxLineT = 0;
|
302
|
-
// Raymarch for each start point.
|
303
|
-
//
|
304
|
-
// Use a for (i from 0 to length) loop because startPoints may be added
|
305
|
-
// during iteration.
|
306
|
-
for (var i = 0; i < startPoints.length; i++) {
|
307
|
-
var startPoint = startPoints[i];
|
308
|
-
// Try raymarching in both directions.
|
309
|
-
maxLineT = Math.max(maxLineT, (_a = raymarchFrom(startPoint, 1, maxLineT)) !== null && _a !== void 0 ? _a : maxLineT);
|
310
|
-
maxLineT = Math.max(maxLineT, (_b = raymarchFrom(startPoint, -1, maxLineT)) !== null && _b !== void 0 ? _b : maxLineT);
|
311
|
-
}
|
312
|
-
return result;
|
313
|
-
};
|
314
|
-
/**
|
315
|
-
* Returns a list of intersections with this path. If `strokeRadius` is given,
|
316
|
-
* intersections are approximated with the surface `strokeRadius` away from this.
|
317
|
-
*
|
318
|
-
* If `strokeRadius > 0`, the resultant `parameterValue` has no defined value.
|
319
|
-
*/
|
320
|
-
Path.prototype.intersection = function (line, strokeRadius) {
|
321
|
-
var result = [];
|
322
|
-
// Is any intersection between shapes within the bounding boxes impossible?
|
323
|
-
if (!line.bbox.intersects(this.bbox.grownBy(strokeRadius !== null && strokeRadius !== void 0 ? strokeRadius : 0))) {
|
324
|
-
return [];
|
325
|
-
}
|
326
|
-
for (var _i = 0, _a = this.geometry; _i < _a.length; _i++) {
|
327
|
-
var part = _a[_i];
|
328
|
-
var intersection = part.intersectsLineSegment(line);
|
329
|
-
if (intersection.length > 0) {
|
330
|
-
result.push({
|
331
|
-
curve: part,
|
332
|
-
point: intersection[0],
|
333
|
-
});
|
334
|
-
}
|
335
|
-
}
|
336
|
-
// If given a non-zero strokeWidth, attempt to raymarch.
|
337
|
-
// Even if raymarching, we need to collect starting points.
|
338
|
-
// We use the above-calculated intersections for this.
|
339
|
-
var doRaymarching = strokeRadius && strokeRadius > 1e-8;
|
340
|
-
if (doRaymarching) {
|
341
|
-
// Starting points for raymarching (in addition to the end points of the line).
|
342
|
-
var startPoints = result.map(function (intersection) { return intersection.point; });
|
343
|
-
result = this.raymarchIntersectionWith(line, strokeRadius, startPoints);
|
344
|
-
}
|
345
|
-
return result;
|
346
|
-
};
|
347
|
-
Path.mapPathCommand = function (part, mapping) {
|
348
|
-
switch (part.kind) {
|
349
|
-
case PathCommandType.MoveTo:
|
350
|
-
case PathCommandType.LineTo:
|
351
|
-
return {
|
352
|
-
kind: part.kind,
|
353
|
-
point: mapping(part.point),
|
354
|
-
};
|
355
|
-
break;
|
356
|
-
case PathCommandType.CubicBezierTo:
|
357
|
-
return {
|
358
|
-
kind: part.kind,
|
359
|
-
controlPoint1: mapping(part.controlPoint1),
|
360
|
-
controlPoint2: mapping(part.controlPoint2),
|
361
|
-
endPoint: mapping(part.endPoint),
|
362
|
-
};
|
363
|
-
break;
|
364
|
-
case PathCommandType.QuadraticBezierTo:
|
365
|
-
return {
|
366
|
-
kind: part.kind,
|
367
|
-
controlPoint: mapping(part.controlPoint),
|
368
|
-
endPoint: mapping(part.endPoint),
|
369
|
-
};
|
370
|
-
break;
|
371
|
-
}
|
372
|
-
var exhaustivenessCheck = part;
|
373
|
-
return exhaustivenessCheck;
|
374
|
-
};
|
375
|
-
Path.prototype.mapPoints = function (mapping) {
|
376
|
-
var startPoint = mapping(this.startPoint);
|
377
|
-
var newParts = [];
|
378
|
-
for (var _i = 0, _a = this.parts; _i < _a.length; _i++) {
|
379
|
-
var part = _a[_i];
|
380
|
-
newParts.push(Path.mapPathCommand(part, mapping));
|
381
|
-
}
|
382
|
-
return new Path(startPoint, newParts);
|
383
|
-
};
|
384
|
-
Path.prototype.transformedBy = function (affineTransfm) {
|
385
|
-
if (affineTransfm.isIdentity()) {
|
386
|
-
return this;
|
387
|
-
}
|
388
|
-
return this.mapPoints(function (point) { return affineTransfm.transformVec2(point); });
|
389
|
-
};
|
390
|
-
// Creates a new path by joining [other] to the end of this path
|
391
|
-
Path.prototype.union = function (other) {
|
392
|
-
if (!other) {
|
393
|
-
return this;
|
394
|
-
}
|
395
|
-
return new Path(this.startPoint, __spreadArray(__spreadArray(__spreadArray([], this.parts, true), [
|
396
|
-
{
|
397
|
-
kind: PathCommandType.MoveTo,
|
398
|
-
point: other.startPoint,
|
399
|
-
}
|
400
|
-
], false), other.parts, true));
|
401
|
-
};
|
402
|
-
Path.prototype.getEndPoint = function () {
|
403
|
-
if (this.parts.length === 0) {
|
404
|
-
return this.startPoint;
|
405
|
-
}
|
406
|
-
var lastPart = this.parts[this.parts.length - 1];
|
407
|
-
if (lastPart.kind === PathCommandType.QuadraticBezierTo || lastPart.kind === PathCommandType.CubicBezierTo) {
|
408
|
-
return lastPart.endPoint;
|
409
|
-
}
|
410
|
-
else {
|
411
|
-
return lastPart.point;
|
412
|
-
}
|
413
|
-
};
|
414
|
-
Path.prototype.roughlyIntersects = function (rect, strokeWidth) {
|
415
|
-
if (strokeWidth === void 0) { strokeWidth = 0; }
|
416
|
-
if (this.parts.length === 0) {
|
417
|
-
return rect.containsPoint(this.startPoint);
|
418
|
-
}
|
419
|
-
var isClosed = this.startPoint.eq(this.getEndPoint());
|
420
|
-
if (isClosed && strokeWidth === 0) {
|
421
|
-
return this.closedRoughlyIntersects(rect);
|
422
|
-
}
|
423
|
-
if (rect.containsRect(this.bbox)) {
|
424
|
-
return true;
|
425
|
-
}
|
426
|
-
// Does the rectangle intersect the bounding boxes of any of this' parts?
|
427
|
-
var startPoint = this.startPoint;
|
428
|
-
for (var _i = 0, _a = this.parts; _i < _a.length; _i++) {
|
429
|
-
var part = _a[_i];
|
430
|
-
var bbox = Path.computeBBoxForSegment(startPoint, part).grownBy(strokeWidth);
|
431
|
-
if (part.kind === PathCommandType.LineTo || part.kind === PathCommandType.MoveTo) {
|
432
|
-
startPoint = part.point;
|
433
|
-
}
|
434
|
-
else {
|
435
|
-
startPoint = part.endPoint;
|
436
|
-
}
|
437
|
-
if (rect.intersects(bbox)) {
|
438
|
-
return true;
|
439
|
-
}
|
440
|
-
}
|
441
|
-
return false;
|
442
|
-
};
|
443
|
-
// Treats this as a closed path and returns true if part of `rect` is roughly within
|
444
|
-
// this path's interior.
|
445
|
-
//
|
446
|
-
// Note: Assumes that this is a closed, non-self-intersecting path.
|
447
|
-
Path.prototype.closedRoughlyIntersects = function (rect) {
|
448
|
-
if (rect.containsRect(this.bbox)) {
|
449
|
-
return true;
|
450
|
-
}
|
451
|
-
// Choose a point outside of the path.
|
452
|
-
var startPt = this.bbox.topLeft.minus(Vec2_1.Vec2.of(1, 1));
|
453
|
-
var testPts = rect.corners;
|
454
|
-
var polygon = this.polylineApproximation();
|
455
|
-
for (var _i = 0, testPts_1 = testPts; _i < testPts_1.length; _i++) {
|
456
|
-
var point = testPts_1[_i];
|
457
|
-
var testLine = new LineSegment2_1.default(point, startPt);
|
458
|
-
var intersectionCount = 0;
|
459
|
-
for (var _a = 0, polygon_1 = polygon; _a < polygon_1.length; _a++) {
|
460
|
-
var line = polygon_1[_a];
|
461
|
-
if (line.intersects(testLine)) {
|
462
|
-
intersectionCount++;
|
463
|
-
}
|
464
|
-
}
|
465
|
-
// Odd? The point is within the polygon!
|
466
|
-
if (intersectionCount % 2 === 1) {
|
467
|
-
return true;
|
468
|
-
}
|
469
|
-
}
|
470
|
-
// Grow the rectangle for possible additional precision.
|
471
|
-
var grownRect = rect.grownBy(Math.min(rect.size.x, rect.size.y));
|
472
|
-
var edges = [];
|
473
|
-
for (var _b = 0, _c = grownRect.divideIntoGrid(4, 4); _b < _c.length; _b++) {
|
474
|
-
var subrect = _c[_b];
|
475
|
-
edges.push.apply(edges, subrect.getEdges());
|
476
|
-
}
|
477
|
-
for (var _d = 0, edges_1 = edges; _d < edges_1.length; _d++) {
|
478
|
-
var edge = edges_1[_d];
|
479
|
-
for (var _e = 0, polygon_2 = polygon; _e < polygon_2.length; _e++) {
|
480
|
-
var line = polygon_2[_e];
|
481
|
-
if (edge.intersects(line)) {
|
482
|
-
return true;
|
483
|
-
}
|
484
|
-
}
|
485
|
-
}
|
486
|
-
// Even? Probably no intersection.
|
487
|
-
return false;
|
488
|
-
};
|
489
|
-
// Returns a path that outlines [rect]. If [lineWidth] is not given, the resultant path is
|
490
|
-
// the outline of [rect]. Otherwise, the resultant path represents a line of width [lineWidth]
|
491
|
-
// that traces [rect].
|
492
|
-
Path.fromRect = function (rect, lineWidth) {
|
493
|
-
if (lineWidth === void 0) { lineWidth = null; }
|
494
|
-
var commands = [];
|
495
|
-
var corners;
|
496
|
-
var startPoint;
|
497
|
-
if (lineWidth !== null) {
|
498
|
-
// Vector from the top left corner or bottom right corner to the edge of the
|
499
|
-
// stroked region.
|
500
|
-
var cornerToEdge = Vec2_1.Vec2.of(lineWidth, lineWidth).times(0.5);
|
501
|
-
var innerRect = Rect2_1.default.fromCorners(rect.topLeft.plus(cornerToEdge), rect.bottomRight.minus(cornerToEdge));
|
502
|
-
var outerRect = Rect2_1.default.fromCorners(rect.topLeft.minus(cornerToEdge), rect.bottomRight.plus(cornerToEdge));
|
503
|
-
corners = __spreadArray(__spreadArray([
|
504
|
-
innerRect.corners[3]
|
505
|
-
], innerRect.corners, true), outerRect.corners.reverse(), true);
|
506
|
-
startPoint = outerRect.corners[3];
|
507
|
-
}
|
508
|
-
else {
|
509
|
-
corners = rect.corners.slice(1);
|
510
|
-
startPoint = rect.corners[0];
|
511
|
-
}
|
512
|
-
for (var _i = 0, corners_1 = corners; _i < corners_1.length; _i++) {
|
513
|
-
var corner = corners_1[_i];
|
514
|
-
commands.push({
|
515
|
-
kind: PathCommandType.LineTo,
|
516
|
-
point: corner,
|
517
|
-
});
|
518
|
-
}
|
519
|
-
// Close the shape
|
520
|
-
commands.push({
|
521
|
-
kind: PathCommandType.LineTo,
|
522
|
-
point: startPoint,
|
523
|
-
});
|
524
|
-
return new Path(startPoint, commands);
|
525
|
-
};
|
526
|
-
Path.fromRenderable = function (renderable) {
|
527
|
-
if (renderable.path) {
|
528
|
-
return renderable.path;
|
529
|
-
}
|
530
|
-
return new Path(renderable.startPoint, renderable.commands);
|
531
|
-
};
|
532
|
-
Path.prototype.toRenderable = function (fill) {
|
533
|
-
return {
|
534
|
-
startPoint: this.startPoint,
|
535
|
-
style: fill,
|
536
|
-
commands: this.parts,
|
537
|
-
path: this,
|
538
|
-
};
|
539
|
-
};
|
540
|
-
/**
|
541
|
-
* @returns a Path that, when rendered, looks roughly equivalent to the given path.
|
542
|
-
*/
|
543
|
-
Path.visualEquivalent = function (renderablePath, visibleRect) {
|
544
|
-
var _a, _b;
|
545
|
-
var path = Path.fromRenderable(renderablePath);
|
546
|
-
var strokeWidth = (_b = (_a = renderablePath.style.stroke) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0;
|
547
|
-
var onlyStroked = strokeWidth > 0 && renderablePath.style.fill.a === 0;
|
548
|
-
// Scale the expanded rect --- the visual equivalent is only close for huge strokes.
|
549
|
-
var expandedRect = visibleRect.grownBy(strokeWidth)
|
550
|
-
.transformedBoundingBox(Mat33_1.default.scaling2D(4, visibleRect.center));
|
551
|
-
// TODO: Handle simplifying very small paths.
|
552
|
-
if (expandedRect.containsRect(path.bbox.grownBy(strokeWidth))) {
|
553
|
-
return renderablePath;
|
554
|
-
}
|
555
|
-
var parts = [];
|
556
|
-
var startPoint = path.startPoint;
|
557
|
-
for (var _i = 0, _c = path.parts; _i < _c.length; _i++) {
|
558
|
-
var part = _c[_i];
|
559
|
-
var partBBox = Path.computeBBoxForSegment(startPoint, part).grownBy(strokeWidth);
|
560
|
-
var endPoint = void 0;
|
561
|
-
if (part.kind === PathCommandType.LineTo || part.kind === PathCommandType.MoveTo) {
|
562
|
-
endPoint = part.point;
|
563
|
-
}
|
564
|
-
else {
|
565
|
-
endPoint = part.endPoint;
|
566
|
-
}
|
567
|
-
var intersectsVisible = partBBox.intersects(visibleRect);
|
568
|
-
if (intersectsVisible) {
|
569
|
-
// TODO: Can we trim parts of paths that intersect the visible rectangle?
|
570
|
-
parts.push(part);
|
571
|
-
}
|
572
|
-
else if (onlyStroked || part.kind === PathCommandType.MoveTo) {
|
573
|
-
// We're stroking (not filling) and the path doesn't intersect the bounding box.
|
574
|
-
// Don't draw it, but preserve the endpoints.
|
575
|
-
parts.push({
|
576
|
-
kind: PathCommandType.MoveTo,
|
577
|
-
point: endPoint,
|
578
|
-
});
|
579
|
-
}
|
580
|
-
else {
|
581
|
-
// Otherwise, we may be filling. Try to roughly preserve the filled region.
|
582
|
-
parts.push({
|
583
|
-
kind: PathCommandType.LineTo,
|
584
|
-
point: endPoint,
|
585
|
-
});
|
586
|
-
}
|
587
|
-
startPoint = endPoint;
|
588
|
-
}
|
589
|
-
return new Path(path.startPoint, parts).toRenderable(renderablePath.style);
|
590
|
-
};
|
591
|
-
Path.prototype.toString = function (useNonAbsCommands) {
|
592
|
-
if (this.cachedStringVersion) {
|
593
|
-
return this.cachedStringVersion;
|
594
|
-
}
|
595
|
-
if (useNonAbsCommands === undefined) {
|
596
|
-
// Hueristic: Try to determine whether converting absolute to relative commands is worth it.
|
597
|
-
useNonAbsCommands = Math.abs(this.bbox.topLeft.x) > 10 && Math.abs(this.bbox.topLeft.y) > 10;
|
598
|
-
}
|
599
|
-
var result = Path.toString(this.startPoint, this.parts, !useNonAbsCommands);
|
600
|
-
this.cachedStringVersion = result;
|
601
|
-
return result;
|
602
|
-
};
|
603
|
-
Path.prototype.serialize = function () {
|
604
|
-
return this.toString();
|
605
|
-
};
|
606
|
-
// @param onlyAbsCommands - True if we should avoid converting absolute coordinates to relative offsets -- such
|
607
|
-
// conversions can lead to smaller output strings, but also take time.
|
608
|
-
Path.toString = function (startPoint, parts, onlyAbsCommands) {
|
609
|
-
var _a;
|
610
|
-
var result = [];
|
611
|
-
var prevPoint;
|
612
|
-
var addCommand = function (command) {
|
613
|
-
var points = [];
|
614
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
615
|
-
points[_i - 1] = arguments[_i];
|
616
|
-
}
|
617
|
-
var absoluteCommandParts = [];
|
618
|
-
var relativeCommandParts = [];
|
619
|
-
var makeAbsCommand = !prevPoint || onlyAbsCommands;
|
620
|
-
var roundedPrevX = prevPoint ? (0, rounding_1.toRoundedString)(prevPoint.x) : '';
|
621
|
-
var roundedPrevY = prevPoint ? (0, rounding_1.toRoundedString)(prevPoint.y) : '';
|
622
|
-
for (var _a = 0, points_2 = points; _a < points_2.length; _a++) {
|
623
|
-
var point = points_2[_a];
|
624
|
-
var xComponent = (0, rounding_1.toRoundedString)(point.x);
|
625
|
-
var yComponent = (0, rounding_1.toRoundedString)(point.y);
|
626
|
-
// Relative commands are often shorter as strings than absolute commands.
|
627
|
-
if (!makeAbsCommand) {
|
628
|
-
var xComponentRelative = (0, rounding_1.toStringOfSamePrecision)(point.x - prevPoint.x, xComponent, roundedPrevX, roundedPrevY);
|
629
|
-
var yComponentRelative = (0, rounding_1.toStringOfSamePrecision)(point.y - prevPoint.y, yComponent, roundedPrevX, roundedPrevY);
|
630
|
-
// No need for an additional separator if it starts with a '-'
|
631
|
-
if (yComponentRelative.charAt(0) === '-') {
|
632
|
-
relativeCommandParts.push("".concat(xComponentRelative).concat(yComponentRelative));
|
633
|
-
}
|
634
|
-
else {
|
635
|
-
relativeCommandParts.push("".concat(xComponentRelative, ",").concat(yComponentRelative));
|
636
|
-
}
|
637
|
-
}
|
638
|
-
else {
|
639
|
-
absoluteCommandParts.push("".concat(xComponent, ",").concat(yComponent));
|
640
|
-
}
|
641
|
-
}
|
642
|
-
var commandString;
|
643
|
-
if (makeAbsCommand) {
|
644
|
-
commandString = "".concat(command).concat(absoluteCommandParts.join(' '));
|
645
|
-
}
|
646
|
-
else {
|
647
|
-
commandString = "".concat(command.toLowerCase()).concat(relativeCommandParts.join(' '));
|
648
|
-
}
|
649
|
-
// Don't add no-ops.
|
650
|
-
if (commandString === 'l0,0' || commandString === 'm0,0') {
|
651
|
-
return;
|
652
|
-
}
|
653
|
-
result.push(commandString);
|
654
|
-
if (points.length > 0) {
|
655
|
-
prevPoint = points[points.length - 1];
|
656
|
-
}
|
657
|
-
};
|
658
|
-
// Don't add two moveTos in a row (this can happen if
|
659
|
-
// the start point corresponds to a moveTo _and_ the first command is
|
660
|
-
// also a moveTo)
|
661
|
-
if (((_a = parts[0]) === null || _a === void 0 ? void 0 : _a.kind) !== PathCommandType.MoveTo) {
|
662
|
-
addCommand('M', startPoint);
|
663
|
-
}
|
664
|
-
var exhaustivenessCheck;
|
665
|
-
for (var i = 0; i < parts.length; i++) {
|
666
|
-
var part = parts[i];
|
667
|
-
switch (part.kind) {
|
668
|
-
case PathCommandType.MoveTo:
|
669
|
-
addCommand('M', part.point);
|
670
|
-
break;
|
671
|
-
case PathCommandType.LineTo:
|
672
|
-
addCommand('L', part.point);
|
673
|
-
break;
|
674
|
-
case PathCommandType.CubicBezierTo:
|
675
|
-
addCommand('C', part.controlPoint1, part.controlPoint2, part.endPoint);
|
676
|
-
break;
|
677
|
-
case PathCommandType.QuadraticBezierTo:
|
678
|
-
addCommand('Q', part.controlPoint, part.endPoint);
|
679
|
-
break;
|
680
|
-
default:
|
681
|
-
exhaustivenessCheck = part;
|
682
|
-
return exhaustivenessCheck;
|
683
|
-
}
|
684
|
-
}
|
685
|
-
return result.join('');
|
686
|
-
};
|
687
|
-
// Create a Path from a SVG path specification.
|
688
|
-
// TODO: Support a larger subset of SVG paths.
|
689
|
-
// TODO: Support `s`,`t` commands shorthands.
|
690
|
-
Path.fromString = function (pathString) {
|
691
|
-
// See the MDN reference:
|
692
|
-
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
|
693
|
-
// and
|
694
|
-
// https://www.w3.org/TR/SVG2/paths.html
|
695
|
-
var _a;
|
696
|
-
// Remove linebreaks
|
697
|
-
pathString = pathString.split('\n').join(' ');
|
698
|
-
var lastPos = Vec2_1.Vec2.zero;
|
699
|
-
var firstPos = null;
|
700
|
-
var startPos = null;
|
701
|
-
var isFirstCommand = true;
|
702
|
-
var commands = [];
|
703
|
-
var moveTo = function (point) {
|
704
|
-
// The first moveTo/lineTo is already handled by the [startPoint] parameter of the Path constructor.
|
705
|
-
if (isFirstCommand) {
|
706
|
-
isFirstCommand = false;
|
707
|
-
return;
|
708
|
-
}
|
709
|
-
commands.push({
|
710
|
-
kind: PathCommandType.MoveTo,
|
711
|
-
point: point,
|
712
|
-
});
|
713
|
-
};
|
714
|
-
var lineTo = function (point) {
|
715
|
-
if (isFirstCommand) {
|
716
|
-
isFirstCommand = false;
|
717
|
-
return;
|
718
|
-
}
|
719
|
-
commands.push({
|
720
|
-
kind: PathCommandType.LineTo,
|
721
|
-
point: point,
|
722
|
-
});
|
723
|
-
};
|
724
|
-
var cubicBezierTo = function (cp1, cp2, end) {
|
725
|
-
commands.push({
|
726
|
-
kind: PathCommandType.CubicBezierTo,
|
727
|
-
controlPoint1: cp1,
|
728
|
-
controlPoint2: cp2,
|
729
|
-
endPoint: end,
|
730
|
-
});
|
731
|
-
};
|
732
|
-
var quadraticBeierTo = function (controlPoint, endPoint) {
|
733
|
-
commands.push({
|
734
|
-
kind: PathCommandType.QuadraticBezierTo,
|
735
|
-
controlPoint: controlPoint,
|
736
|
-
endPoint: endPoint,
|
737
|
-
});
|
738
|
-
};
|
739
|
-
var commandArgCounts = {
|
740
|
-
'm': 1,
|
741
|
-
'l': 1,
|
742
|
-
'c': 3,
|
743
|
-
'q': 2,
|
744
|
-
'z': 0,
|
745
|
-
'h': 1,
|
746
|
-
'v': 1,
|
747
|
-
};
|
748
|
-
// Each command: Command character followed by anything that isn't a command character
|
749
|
-
var commandExp = /([MZLHVCSQTA])\s*([^MZLHVCSQTA]*)/ig;
|
750
|
-
var current;
|
751
|
-
var _loop_2 = function () {
|
752
|
-
var argParts = current[2].trim().split(/[^0-9Ee.-]/).filter(function (part) { return part.length > 0; }).reduce(function (accumualtor, current) {
|
753
|
-
// As of 09/2022, iOS Safari doesn't support support lookbehind in regular
|
754
|
-
// expressions. As such, we need an alternative.
|
755
|
-
// Because '-' can be used as a path separator, unless preceeded by an 'e' (as in 1e-5),
|
756
|
-
// we need special cases:
|
757
|
-
current = current.replace(/([^eE])[-]/g, '$1 -');
|
758
|
-
var parts = current.split(' -');
|
759
|
-
if (parts[0] !== '') {
|
760
|
-
accumualtor.push(parts[0]);
|
761
|
-
}
|
762
|
-
accumualtor.push.apply(accumualtor, parts.slice(1).map(function (part) { return "-".concat(part); }));
|
763
|
-
return accumualtor;
|
764
|
-
}, []);
|
765
|
-
var numericArgs = argParts.map(function (arg) { return parseFloat(arg); });
|
766
|
-
var commandChar = current[1].toLowerCase();
|
767
|
-
var uppercaseCommand = current[1] !== commandChar;
|
768
|
-
// Convert commands that don't take points into commands that do.
|
769
|
-
if (commandChar === 'v' || commandChar === 'h') {
|
770
|
-
numericArgs = numericArgs.reduce(function (accumulator, current) {
|
771
|
-
if (commandChar === 'v') {
|
772
|
-
return accumulator.concat(uppercaseCommand ? lastPos.x : 0, current);
|
773
|
-
}
|
774
|
-
else {
|
775
|
-
return accumulator.concat(current, uppercaseCommand ? lastPos.y : 0);
|
776
|
-
}
|
777
|
-
}, []);
|
778
|
-
commandChar = 'l';
|
779
|
-
}
|
780
|
-
else if (commandChar === 'z') {
|
781
|
-
if (firstPos) {
|
782
|
-
numericArgs = [firstPos.x, firstPos.y];
|
783
|
-
firstPos = lastPos;
|
784
|
-
}
|
785
|
-
else {
|
786
|
-
return "continue";
|
787
|
-
}
|
788
|
-
// 'z' always acts like an uppercase lineTo(startPos)
|
789
|
-
uppercaseCommand = true;
|
790
|
-
commandChar = 'l';
|
791
|
-
}
|
792
|
-
var commandArgCount = (_a = commandArgCounts[commandChar]) !== null && _a !== void 0 ? _a : 0;
|
793
|
-
var allArgs = numericArgs.reduce(function (accumulator, current, index, parts) {
|
794
|
-
if (index % 2 !== 0) {
|
795
|
-
var currentAsFloat = current;
|
796
|
-
var prevAsFloat = parts[index - 1];
|
797
|
-
return accumulator.concat(Vec2_1.Vec2.of(prevAsFloat, currentAsFloat));
|
798
|
-
}
|
799
|
-
else {
|
800
|
-
return accumulator;
|
801
|
-
}
|
802
|
-
}, []).map(function (coordinate, index) {
|
803
|
-
// Lowercase commands are relative, uppercase commands use absolute
|
804
|
-
// positioning
|
805
|
-
var newPos;
|
806
|
-
if (uppercaseCommand) {
|
807
|
-
newPos = coordinate;
|
808
|
-
}
|
809
|
-
else {
|
810
|
-
newPos = lastPos.plus(coordinate);
|
811
|
-
}
|
812
|
-
if ((index + 1) % commandArgCount === 0) {
|
813
|
-
lastPos = newPos;
|
814
|
-
}
|
815
|
-
return newPos;
|
816
|
-
});
|
817
|
-
if (allArgs.length % commandArgCount !== 0) {
|
818
|
-
throw new Error([
|
819
|
-
"Incorrect number of arguments: got ".concat(JSON.stringify(allArgs), " with a length of ").concat(allArgs.length, " \u2260 ").concat(commandArgCount, "k, k \u2208 \u2124."),
|
820
|
-
"The number of arguments to ".concat(commandChar, " must be a multiple of ").concat(commandArgCount, "!"),
|
821
|
-
"Command: ".concat(current[0]),
|
822
|
-
].join('\n'));
|
823
|
-
}
|
824
|
-
for (var argPos = 0; argPos < allArgs.length; argPos += commandArgCount) {
|
825
|
-
var args = allArgs.slice(argPos, argPos + commandArgCount);
|
826
|
-
switch (commandChar.toLowerCase()) {
|
827
|
-
case 'm':
|
828
|
-
if (argPos === 0) {
|
829
|
-
moveTo(args[0]);
|
830
|
-
}
|
831
|
-
else {
|
832
|
-
lineTo(args[0]);
|
833
|
-
}
|
834
|
-
break;
|
835
|
-
case 'l':
|
836
|
-
lineTo(args[0]);
|
837
|
-
break;
|
838
|
-
case 'c':
|
839
|
-
cubicBezierTo(args[0], args[1], args[2]);
|
840
|
-
break;
|
841
|
-
case 'q':
|
842
|
-
quadraticBeierTo(args[0], args[1]);
|
843
|
-
break;
|
844
|
-
default:
|
845
|
-
throw new Error("Unknown path command ".concat(commandChar));
|
846
|
-
}
|
847
|
-
isFirstCommand = false;
|
848
|
-
}
|
849
|
-
if (allArgs.length > 0) {
|
850
|
-
firstPos !== null && firstPos !== void 0 ? firstPos : (firstPos = allArgs[0]);
|
851
|
-
startPos !== null && startPos !== void 0 ? startPos : (startPos = firstPos);
|
852
|
-
lastPos = allArgs[allArgs.length - 1];
|
853
|
-
}
|
854
|
-
};
|
855
|
-
while ((current = commandExp.exec(pathString)) !== null) {
|
856
|
-
_loop_2();
|
857
|
-
}
|
858
|
-
var result = new Path(startPos !== null && startPos !== void 0 ? startPos : Vec2_1.Vec2.zero, commands);
|
859
|
-
result.cachedStringVersion = pathString;
|
860
|
-
return result;
|
861
|
-
};
|
862
|
-
Path.empty = new Path(Vec2_1.Vec2.zero, []);
|
863
|
-
return Path;
|
864
|
-
}());
|
865
|
-
exports.default = Path;
|