js-draw 0.25.0 → 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 +44 -45
- 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 +43 -45
- 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 -167
- 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
package/dist/mjs/math/lib.d.ts
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import LineSegment2 from './shapes/LineSegment2';
|
2
|
-
import Mat33 from './Mat33';
|
3
|
-
import Path from './shapes/Path';
|
4
|
-
import Rect2 from './shapes/Rect2';
|
5
|
-
import { Vec2 } from './Vec2';
|
6
|
-
import Vec3 from './Vec3';
|
7
|
-
export { LineSegment2, Mat33, Path, Rect2, Vec3, Vec2, };
|
package/dist/mjs/math/lib.mjs
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import LineSegment2 from './shapes/LineSegment2.mjs';
|
2
|
-
import Mat33 from './Mat33.mjs';
|
3
|
-
import Path from './shapes/Path.mjs';
|
4
|
-
import Rect2 from './shapes/Rect2.mjs';
|
5
|
-
import { Vec2 } from './Vec2.mjs';
|
6
|
-
import Vec3 from './Vec3.mjs';
|
7
|
-
export { LineSegment2, Mat33, Path, Rect2, Vec3, Vec2, };
|
@@ -1,9 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Solves an equation of the form ax² + bx + c = 0.
|
3
|
-
* The larger solution is returned first.
|
4
|
-
*
|
5
|
-
* If there are no solutions, returns `[NaN, NaN]`. If there is one solution,
|
6
|
-
* repeats the solution twice in the result.
|
7
|
-
*/
|
8
|
-
declare const solveQuadratic: (a: number, b: number, c: number) => [number, number];
|
9
|
-
export default solveQuadratic;
|
@@ -1,37 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Solves an equation of the form ax² + bx + c = 0.
|
3
|
-
* The larger solution is returned first.
|
4
|
-
*
|
5
|
-
* If there are no solutions, returns `[NaN, NaN]`. If there is one solution,
|
6
|
-
* repeats the solution twice in the result.
|
7
|
-
*/
|
8
|
-
var solveQuadratic = function (a, b, c) {
|
9
|
-
// See also https://en.wikipedia.org/wiki/Quadratic_formula
|
10
|
-
if (a === 0) {
|
11
|
-
var solution = void 0;
|
12
|
-
if (b === 0) {
|
13
|
-
solution = c === 0 ? 0 : NaN;
|
14
|
-
}
|
15
|
-
else {
|
16
|
-
// Then we have bx + c = 0
|
17
|
-
// which implies bx = -c.
|
18
|
-
// Thus, x = -c/b
|
19
|
-
solution = -c / b;
|
20
|
-
}
|
21
|
-
return [solution, solution];
|
22
|
-
}
|
23
|
-
var discriminant = b * b - 4 * a * c;
|
24
|
-
if (discriminant < 0) {
|
25
|
-
return [NaN, NaN];
|
26
|
-
}
|
27
|
-
var rootDiscriminant = Math.sqrt(discriminant);
|
28
|
-
var solution1 = (-b + rootDiscriminant) / (2 * a);
|
29
|
-
var solution2 = (-b - rootDiscriminant) / (2 * a);
|
30
|
-
if (solution1 > solution2) {
|
31
|
-
return [solution1, solution2];
|
32
|
-
}
|
33
|
-
else {
|
34
|
-
return [solution2, solution1];
|
35
|
-
}
|
36
|
-
};
|
37
|
-
export default solveQuadratic;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,4 +0,0 @@
|
|
1
|
-
export declare const cleanUpNumber: (text: string) => string;
|
2
|
-
export declare const toRoundedString: (num: number) => string;
|
3
|
-
export declare const getLenAfterDecimal: (numberAsString: string) => number;
|
4
|
-
export declare const toStringOfSamePrecision: (num: number, ...references: string[]) => string;
|
@@ -1,133 +0,0 @@
|
|
1
|
-
// @packageDocumentation @internal
|
2
|
-
// Clean up stringified numbers
|
3
|
-
export var cleanUpNumber = function (text) {
|
4
|
-
// Regular expression substitions can be somewhat expensive. Only do them
|
5
|
-
// if necessary.
|
6
|
-
if (text.indexOf('e') > 0) {
|
7
|
-
// Round to zero.
|
8
|
-
if (text.match(/[eE][-]\d{2,}$/)) {
|
9
|
-
return '0';
|
10
|
-
}
|
11
|
-
}
|
12
|
-
var lastChar = text.charAt(text.length - 1);
|
13
|
-
if (lastChar === '0' || lastChar === '.') {
|
14
|
-
// Remove trailing zeroes
|
15
|
-
text = text.replace(/([.]\d*[^0]+)0+$/, '$1');
|
16
|
-
text = text.replace(/[.]0+$/, '.');
|
17
|
-
// Remove trailing period
|
18
|
-
text = text.replace(/[.]$/, '');
|
19
|
-
}
|
20
|
-
var firstChar = text.charAt(0);
|
21
|
-
if (firstChar === '0' || firstChar === '-') {
|
22
|
-
// Remove unnecessary leading zeroes.
|
23
|
-
text = text.replace(/^(0+)[.]/, '.');
|
24
|
-
text = text.replace(/^-(0+)[.]/, '-.');
|
25
|
-
text = text.replace(/^(-?)0+$/, '$10');
|
26
|
-
}
|
27
|
-
if (text === '-0') {
|
28
|
-
return '0';
|
29
|
-
}
|
30
|
-
return text;
|
31
|
-
};
|
32
|
-
export var toRoundedString = function (num) {
|
33
|
-
// Try to remove rounding errors. If the number ends in at least three/four zeroes
|
34
|
-
// (or nines) just one or two digits, it's probably a rounding error.
|
35
|
-
var fixRoundingUpExp = /^([-]?\d*\.\d{3,})0{4,}\d{1,4}$/;
|
36
|
-
var hasRoundingDownExp = /^([-]?)(\d*)\.(\d{3,}9{4,})\d{1,4}$/;
|
37
|
-
var text = num.toString(10);
|
38
|
-
if (text.indexOf('.') === -1) {
|
39
|
-
return text;
|
40
|
-
}
|
41
|
-
var roundingDownMatch = hasRoundingDownExp.exec(text);
|
42
|
-
if (roundingDownMatch) {
|
43
|
-
var negativeSign = roundingDownMatch[1];
|
44
|
-
var postDecimalString = roundingDownMatch[3];
|
45
|
-
var lastDigit = parseInt(postDecimalString.charAt(postDecimalString.length - 1), 10);
|
46
|
-
var postDecimal = parseInt(postDecimalString, 10);
|
47
|
-
var preDecimal = parseInt(roundingDownMatch[2], 10);
|
48
|
-
var origPostDecimalString = roundingDownMatch[3];
|
49
|
-
var newPostDecimal = (postDecimal + 10 - lastDigit).toString();
|
50
|
-
var carry = 0;
|
51
|
-
if (newPostDecimal.length > postDecimal.toString().length) {
|
52
|
-
// Left-shift
|
53
|
-
newPostDecimal = newPostDecimal.substring(1);
|
54
|
-
carry = 1;
|
55
|
-
}
|
56
|
-
// parseInt(...).toString() removes leading zeroes. Add them back.
|
57
|
-
while (newPostDecimal.length < origPostDecimalString.length) {
|
58
|
-
newPostDecimal = carry.toString(10) + newPostDecimal;
|
59
|
-
carry = 0;
|
60
|
-
}
|
61
|
-
text = "".concat(negativeSign + (preDecimal + carry).toString(), ".").concat(newPostDecimal);
|
62
|
-
}
|
63
|
-
text = text.replace(fixRoundingUpExp, '$1');
|
64
|
-
return cleanUpNumber(text);
|
65
|
-
};
|
66
|
-
var numberExp = /^([-]?)(\d*)[.](\d+)$/;
|
67
|
-
export var getLenAfterDecimal = function (numberAsString) {
|
68
|
-
var numberMatch = numberExp.exec(numberAsString);
|
69
|
-
if (!numberMatch) {
|
70
|
-
// If not a match, either the number is exponential notation (or is something
|
71
|
-
// like NaN or Infinity)
|
72
|
-
if (numberAsString.search(/[eE]/) !== -1 || /^[a-zA-Z]+$/.exec(numberAsString)) {
|
73
|
-
return -1;
|
74
|
-
// Or it has no decimal point
|
75
|
-
}
|
76
|
-
else {
|
77
|
-
return 0;
|
78
|
-
}
|
79
|
-
}
|
80
|
-
var afterDecimalLen = numberMatch[3].length;
|
81
|
-
return afterDecimalLen;
|
82
|
-
};
|
83
|
-
// [reference] should be a string representation of a base-10 number (no exponential (e.g. 10e10))
|
84
|
-
export var toStringOfSamePrecision = function (num) {
|
85
|
-
var references = [];
|
86
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
87
|
-
references[_i - 1] = arguments[_i];
|
88
|
-
}
|
89
|
-
var text = num.toString(10);
|
90
|
-
var textMatch = numberExp.exec(text);
|
91
|
-
if (!textMatch) {
|
92
|
-
return text;
|
93
|
-
}
|
94
|
-
var decimalPlaces = -1;
|
95
|
-
for (var _a = 0, references_1 = references; _a < references_1.length; _a++) {
|
96
|
-
var reference = references_1[_a];
|
97
|
-
decimalPlaces = Math.max(getLenAfterDecimal(reference), decimalPlaces);
|
98
|
-
}
|
99
|
-
if (decimalPlaces === -1) {
|
100
|
-
return toRoundedString(num);
|
101
|
-
}
|
102
|
-
// Make text's after decimal length match [afterDecimalLen].
|
103
|
-
var postDecimal = textMatch[3].substring(0, decimalPlaces);
|
104
|
-
var preDecimal = textMatch[2];
|
105
|
-
var nextDigit = textMatch[3].charAt(decimalPlaces);
|
106
|
-
if (nextDigit !== '') {
|
107
|
-
var asNumber = parseInt(nextDigit, 10);
|
108
|
-
if (asNumber >= 5) {
|
109
|
-
// Don't attempt to parseInt() an empty string.
|
110
|
-
if (postDecimal.length > 0) {
|
111
|
-
var leadingZeroMatch = /^(0+)(\d*)$/.exec(postDecimal);
|
112
|
-
var leadingZeroes = '';
|
113
|
-
var postLeading = postDecimal;
|
114
|
-
if (leadingZeroMatch) {
|
115
|
-
leadingZeroes = leadingZeroMatch[1];
|
116
|
-
postLeading = leadingZeroMatch[2];
|
117
|
-
}
|
118
|
-
postDecimal = (parseInt(postDecimal) + 1).toString();
|
119
|
-
// If postDecimal got longer, remove leading zeroes if possible
|
120
|
-
if (postDecimal.length > postLeading.length && leadingZeroes.length > 0) {
|
121
|
-
leadingZeroes = leadingZeroes.substring(1);
|
122
|
-
}
|
123
|
-
postDecimal = leadingZeroes + postDecimal;
|
124
|
-
}
|
125
|
-
if (postDecimal.length === 0 || postDecimal.length > decimalPlaces) {
|
126
|
-
preDecimal = (parseInt(preDecimal) + 1).toString();
|
127
|
-
postDecimal = postDecimal.substring(1);
|
128
|
-
}
|
129
|
-
}
|
130
|
-
}
|
131
|
-
var negativeSign = textMatch[1];
|
132
|
-
return cleanUpNumber("".concat(negativeSign).concat(preDecimal, ".").concat(postDecimal));
|
133
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import LineSegment2 from './LineSegment2';
|
2
|
-
import { Point2 } from '../Vec2';
|
3
|
-
import Rect2 from './Rect2';
|
4
|
-
declare abstract class Abstract2DShape {
|
5
|
-
protected static readonly smallValue = 1e-12;
|
6
|
-
/**
|
7
|
-
* @returns the distance from `point` to this shape. If `point` is within this shape,
|
8
|
-
* this returns the distance from `point` to the edge of this shape.
|
9
|
-
*
|
10
|
-
* @see {@link signedDistance}
|
11
|
-
*/
|
12
|
-
distance(point: Point2): number;
|
13
|
-
/**
|
14
|
-
* Computes the [signed distance function](https://en.wikipedia.org/wiki/Signed_distance_function)
|
15
|
-
* for this shape.
|
16
|
-
*/
|
17
|
-
abstract signedDistance(point: Point2): number;
|
18
|
-
/**
|
19
|
-
* @returns points at which this shape intersects the given `lineSegment`.
|
20
|
-
*
|
21
|
-
* If this is a closed shape, returns points where the given `lineSegment` intersects
|
22
|
-
* the **boundary** of this.
|
23
|
-
*/
|
24
|
-
abstract intersectsLineSegment(lineSegment: LineSegment2): Point2[];
|
25
|
-
/**
|
26
|
-
* Returns `true` if and only if the given `point` is contained within this shape.
|
27
|
-
*
|
28
|
-
* `epsilon` is a small number used to counteract floating point error. Thus, if
|
29
|
-
* `point` is within `epsilon` of the inside of this shape, `containsPoint` may also
|
30
|
-
* return `true`.
|
31
|
-
*
|
32
|
-
* The default implementation relies on `signedDistance`.
|
33
|
-
* Subclasses may override this method to provide a more efficient implementation.
|
34
|
-
*/
|
35
|
-
containsPoint(point: Point2, epsilon?: number): boolean;
|
36
|
-
/**
|
37
|
-
* Returns a bounding box that precisely fits the content of this shape.
|
38
|
-
*/
|
39
|
-
abstract getTightBoundingBox(): Rect2;
|
40
|
-
/**
|
41
|
-
* Returns a bounding box that **loosely** fits the content of this shape.
|
42
|
-
*
|
43
|
-
* The result of this call can be larger than the result of {@link getTightBoundingBox},
|
44
|
-
* **but should not be smaller**. Thus, a call to `getLooseBoundingBox` can be significantly
|
45
|
-
* faster than a call to {@link getTightBoundingBox} for some shapes.
|
46
|
-
*/
|
47
|
-
getLooseBoundingBox(): Rect2;
|
48
|
-
}
|
49
|
-
export default Abstract2DShape;
|
@@ -1,40 +0,0 @@
|
|
1
|
-
var Abstract2DShape = /** @class */ (function () {
|
2
|
-
function Abstract2DShape() {
|
3
|
-
}
|
4
|
-
/**
|
5
|
-
* @returns the distance from `point` to this shape. If `point` is within this shape,
|
6
|
-
* this returns the distance from `point` to the edge of this shape.
|
7
|
-
*
|
8
|
-
* @see {@link signedDistance}
|
9
|
-
*/
|
10
|
-
Abstract2DShape.prototype.distance = function (point) {
|
11
|
-
return Math.abs(this.signedDistance(point));
|
12
|
-
};
|
13
|
-
/**
|
14
|
-
* Returns `true` if and only if the given `point` is contained within this shape.
|
15
|
-
*
|
16
|
-
* `epsilon` is a small number used to counteract floating point error. Thus, if
|
17
|
-
* `point` is within `epsilon` of the inside of this shape, `containsPoint` may also
|
18
|
-
* return `true`.
|
19
|
-
*
|
20
|
-
* The default implementation relies on `signedDistance`.
|
21
|
-
* Subclasses may override this method to provide a more efficient implementation.
|
22
|
-
*/
|
23
|
-
Abstract2DShape.prototype.containsPoint = function (point, epsilon) {
|
24
|
-
if (epsilon === void 0) { epsilon = Abstract2DShape.smallValue; }
|
25
|
-
return this.signedDistance(point) < epsilon;
|
26
|
-
};
|
27
|
-
/**
|
28
|
-
* Returns a bounding box that **loosely** fits the content of this shape.
|
29
|
-
*
|
30
|
-
* The result of this call can be larger than the result of {@link getTightBoundingBox},
|
31
|
-
* **but should not be smaller**. Thus, a call to `getLooseBoundingBox` can be significantly
|
32
|
-
* faster than a call to {@link getTightBoundingBox} for some shapes.
|
33
|
-
*/
|
34
|
-
Abstract2DShape.prototype.getLooseBoundingBox = function () {
|
35
|
-
return this.getTightBoundingBox();
|
36
|
-
};
|
37
|
-
Abstract2DShape.smallValue = 1e-12;
|
38
|
-
return Abstract2DShape;
|
39
|
-
}());
|
40
|
-
export default Abstract2DShape;
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import { Bezier } from 'bezier-js';
|
2
|
-
import { Point2, Vec2 } from '../Vec2';
|
3
|
-
import Abstract2DShape from './Abstract2DShape';
|
4
|
-
import LineSegment2 from './LineSegment2';
|
5
|
-
import Rect2 from './Rect2';
|
6
|
-
/**
|
7
|
-
* A lazy-initializing wrapper around Bezier-js.
|
8
|
-
*
|
9
|
-
* Subclasses may override `at`, `derivativeAt`, and `normal` with functions
|
10
|
-
* that do not initialize a `bezier-js` `Bezier`.
|
11
|
-
*
|
12
|
-
* Do not use this class directly. It may be removed/replaced in a future release.
|
13
|
-
* @internal
|
14
|
-
*/
|
15
|
-
declare abstract class BezierJSWrapper extends Abstract2DShape {
|
16
|
-
#private;
|
17
|
-
/** Returns the start, control points, and end point of this Bézier. */
|
18
|
-
abstract getPoints(): Point2[];
|
19
|
-
protected getBezier(): Bezier;
|
20
|
-
signedDistance(point: Point2): number;
|
21
|
-
/**
|
22
|
-
* @returns the (more) exact distance from `point` to this.
|
23
|
-
*
|
24
|
-
* @see {@link approximateDistance}
|
25
|
-
*/
|
26
|
-
distance(point: Point2): number;
|
27
|
-
/**
|
28
|
-
* @returns the curve evaluated at `t`.
|
29
|
-
*/
|
30
|
-
at(t: number): Point2;
|
31
|
-
derivativeAt(t: number): Point2;
|
32
|
-
normal(t: number): Vec2;
|
33
|
-
getTightBoundingBox(): Rect2;
|
34
|
-
intersectsLineSegment(line: LineSegment2): Point2[];
|
35
|
-
}
|
36
|
-
export default BezierJSWrapper;
|
@@ -1,107 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
17
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
18
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
19
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
20
|
-
};
|
21
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
22
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
23
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
24
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
25
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
26
|
-
};
|
27
|
-
var _BezierJSWrapper_bezierJs;
|
28
|
-
import { Bezier } from 'bezier-js';
|
29
|
-
import { Vec2 } from '../Vec2.mjs';
|
30
|
-
import Abstract2DShape from './Abstract2DShape.mjs';
|
31
|
-
import Rect2 from './Rect2.mjs';
|
32
|
-
/**
|
33
|
-
* A lazy-initializing wrapper around Bezier-js.
|
34
|
-
*
|
35
|
-
* Subclasses may override `at`, `derivativeAt`, and `normal` with functions
|
36
|
-
* that do not initialize a `bezier-js` `Bezier`.
|
37
|
-
*
|
38
|
-
* Do not use this class directly. It may be removed/replaced in a future release.
|
39
|
-
* @internal
|
40
|
-
*/
|
41
|
-
var BezierJSWrapper = /** @class */ (function (_super) {
|
42
|
-
__extends(BezierJSWrapper, _super);
|
43
|
-
function BezierJSWrapper() {
|
44
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
45
|
-
_BezierJSWrapper_bezierJs.set(_this, null);
|
46
|
-
return _this;
|
47
|
-
}
|
48
|
-
BezierJSWrapper.prototype.getBezier = function () {
|
49
|
-
if (!__classPrivateFieldGet(this, _BezierJSWrapper_bezierJs, "f")) {
|
50
|
-
__classPrivateFieldSet(this, _BezierJSWrapper_bezierJs, new Bezier(this.getPoints().map(function (p) { return p.xy; })), "f");
|
51
|
-
}
|
52
|
-
return __classPrivateFieldGet(this, _BezierJSWrapper_bezierJs, "f");
|
53
|
-
};
|
54
|
-
BezierJSWrapper.prototype.signedDistance = function (point) {
|
55
|
-
// .d: Distance
|
56
|
-
return this.getBezier().project(point.xy).d;
|
57
|
-
};
|
58
|
-
/**
|
59
|
-
* @returns the (more) exact distance from `point` to this.
|
60
|
-
*
|
61
|
-
* @see {@link approximateDistance}
|
62
|
-
*/
|
63
|
-
BezierJSWrapper.prototype.distance = function (point) {
|
64
|
-
// A Bézier curve has no interior, thus, signed distance is the same as distance.
|
65
|
-
return this.signedDistance(point);
|
66
|
-
};
|
67
|
-
/**
|
68
|
-
* @returns the curve evaluated at `t`.
|
69
|
-
*/
|
70
|
-
BezierJSWrapper.prototype.at = function (t) {
|
71
|
-
return Vec2.ofXY(this.getBezier().get(t));
|
72
|
-
};
|
73
|
-
BezierJSWrapper.prototype.derivativeAt = function (t) {
|
74
|
-
return Vec2.ofXY(this.getBezier().derivative(t));
|
75
|
-
};
|
76
|
-
BezierJSWrapper.prototype.normal = function (t) {
|
77
|
-
return Vec2.ofXY(this.getBezier().normal(t));
|
78
|
-
};
|
79
|
-
BezierJSWrapper.prototype.getTightBoundingBox = function () {
|
80
|
-
var bbox = this.getBezier().bbox();
|
81
|
-
var width = bbox.x.max - bbox.x.min;
|
82
|
-
var height = bbox.y.max - bbox.y.min;
|
83
|
-
return new Rect2(bbox.x.min, bbox.y.min, width, height);
|
84
|
-
};
|
85
|
-
BezierJSWrapper.prototype.intersectsLineSegment = function (line) {
|
86
|
-
var bezier = this.getBezier();
|
87
|
-
var intersectionPoints = bezier.intersects(line).map(function (t) {
|
88
|
-
// We're using the .intersects(line) function, which is documented
|
89
|
-
// to always return numbers. However, to satisfy the type checker (and
|
90
|
-
// possibly improperly-defined types),
|
91
|
-
if (typeof t === 'string') {
|
92
|
-
t = parseFloat(t);
|
93
|
-
}
|
94
|
-
var point = Vec2.ofXY(bezier.get(t));
|
95
|
-
// Ensure that the intersection is on the line segment
|
96
|
-
if (point.minus(line.p1).magnitude() > line.length
|
97
|
-
|| point.minus(line.p2).magnitude() > line.length) {
|
98
|
-
return null;
|
99
|
-
}
|
100
|
-
return point;
|
101
|
-
}).filter(function (entry) { return entry !== null; });
|
102
|
-
return intersectionPoints;
|
103
|
-
};
|
104
|
-
return BezierJSWrapper;
|
105
|
-
}(Abstract2DShape));
|
106
|
-
_BezierJSWrapper_bezierJs = new WeakMap();
|
107
|
-
export default BezierJSWrapper;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { Point2 } from '../Vec2';
|
2
|
-
import BezierJSWrapper from './BezierJSWrapper';
|
3
|
-
import Rect2 from './Rect2';
|
4
|
-
/**
|
5
|
-
* A wrapper around [`bezier-js`](https://github.com/Pomax/bezierjs)'s cubic Bezier.
|
6
|
-
*/
|
7
|
-
declare class CubicBezier extends BezierJSWrapper {
|
8
|
-
readonly p0: Point2;
|
9
|
-
readonly p1: Point2;
|
10
|
-
readonly p2: Point2;
|
11
|
-
readonly p3: Point2;
|
12
|
-
constructor(p0: Point2, p1: Point2, p2: Point2, p3: Point2);
|
13
|
-
getPoints(): import("../Vec3").default[];
|
14
|
-
/** Returns an overestimate of this shape's bounding box. */
|
15
|
-
getLooseBoundingBox(): Rect2;
|
16
|
-
}
|
17
|
-
export default CubicBezier;
|
@@ -1,48 +0,0 @@
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
2
|
-
var extendStatics = function (d, b) {
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
6
|
-
return extendStatics(d, b);
|
7
|
-
};
|
8
|
-
return function (d, b) {
|
9
|
-
if (typeof b !== "function" && b !== null)
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
11
|
-
extendStatics(d, b);
|
12
|
-
function __() { this.constructor = d; }
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14
|
-
};
|
15
|
-
})();
|
16
|
-
import BezierJSWrapper from './BezierJSWrapper.mjs';
|
17
|
-
import Rect2 from './Rect2.mjs';
|
18
|
-
/**
|
19
|
-
* A wrapper around [`bezier-js`](https://github.com/Pomax/bezierjs)'s cubic Bezier.
|
20
|
-
*/
|
21
|
-
var CubicBezier = /** @class */ (function (_super) {
|
22
|
-
__extends(CubicBezier, _super);
|
23
|
-
function CubicBezier(
|
24
|
-
// Start point
|
25
|
-
p0,
|
26
|
-
// Control point 1
|
27
|
-
p1,
|
28
|
-
// Control point 2
|
29
|
-
p2,
|
30
|
-
// End point
|
31
|
-
p3) {
|
32
|
-
var _this = _super.call(this) || this;
|
33
|
-
_this.p0 = p0;
|
34
|
-
_this.p1 = p1;
|
35
|
-
_this.p2 = p2;
|
36
|
-
_this.p3 = p3;
|
37
|
-
return _this;
|
38
|
-
}
|
39
|
-
CubicBezier.prototype.getPoints = function () {
|
40
|
-
return [this.p0, this.p1, this.p2, this.p3];
|
41
|
-
};
|
42
|
-
/** Returns an overestimate of this shape's bounding box. */
|
43
|
-
CubicBezier.prototype.getLooseBoundingBox = function () {
|
44
|
-
return Rect2.bboxOf([this.p0, this.p1, this.p2, this.p3]);
|
45
|
-
};
|
46
|
-
return CubicBezier;
|
47
|
-
}(BezierJSWrapper));
|
48
|
-
export default CubicBezier;
|
@@ -1,70 +0,0 @@
|
|
1
|
-
import Mat33 from '../Mat33';
|
2
|
-
import Rect2 from './Rect2';
|
3
|
-
import { Vec2, Point2 } from '../Vec2';
|
4
|
-
import Abstract2DShape from './Abstract2DShape';
|
5
|
-
interface IntersectionResult {
|
6
|
-
point: Point2;
|
7
|
-
t: number;
|
8
|
-
}
|
9
|
-
/** Represents a line segment. A `LineSegment2` is immutable. */
|
10
|
-
export default class LineSegment2 extends Abstract2DShape {
|
11
|
-
private readonly point1;
|
12
|
-
private readonly point2;
|
13
|
-
/**
|
14
|
-
* The **unit** direction vector of this line segment, from
|
15
|
-
* `point1` to `point2`.
|
16
|
-
*
|
17
|
-
* In other words, `direction` is `point2.minus(point1).normalized()`
|
18
|
-
* (perhaps except when `point1` is equal to `point2`).
|
19
|
-
*/
|
20
|
-
readonly direction: Vec2;
|
21
|
-
/** The distance between `point1` and `point2`. */
|
22
|
-
readonly length: number;
|
23
|
-
/** The bounding box of this line segment. */
|
24
|
-
readonly bbox: any;
|
25
|
-
/** Creates a new `LineSegment2` from its endpoints. */
|
26
|
-
constructor(point1: Point2, point2: Point2);
|
27
|
-
/** Alias for `point1`. */
|
28
|
-
get p1(): Point2;
|
29
|
-
/** Alias for `point2`. */
|
30
|
-
get p2(): Point2;
|
31
|
-
/**
|
32
|
-
* Gets a point a distance `t` along this line.
|
33
|
-
*
|
34
|
-
* @deprecated
|
35
|
-
*/
|
36
|
-
get(t: number): Point2;
|
37
|
-
/**
|
38
|
-
* Returns a point a fraction, `t`, along this line segment.
|
39
|
-
* Thus, `segment.at(0)` returns `segment.p1` and `segment.at(1)` returns
|
40
|
-
* `segment.p2`.
|
41
|
-
*
|
42
|
-
* `t` should be in `[0, 1]`.
|
43
|
-
*/
|
44
|
-
at(t: number): Point2;
|
45
|
-
intersection(other: LineSegment2): IntersectionResult | null;
|
46
|
-
intersects(other: LineSegment2): boolean;
|
47
|
-
/**
|
48
|
-
* Returns the points at which this line segment intersects the
|
49
|
-
* given line segment.
|
50
|
-
*
|
51
|
-
* Note that {@link intersects} returns *whether* this line segment intersects another
|
52
|
-
* line segment. This method, by contrast, returns **the point** at which the intersection
|
53
|
-
* occurs, if such a point exists.
|
54
|
-
*/
|
55
|
-
intersectsLineSegment(lineSegment: LineSegment2): import("../Vec3").default[];
|
56
|
-
closestPointTo(target: Point2): import("../Vec3").default;
|
57
|
-
/**
|
58
|
-
* Returns the distance from this line segment to `target`.
|
59
|
-
*
|
60
|
-
* Because a line segment has no interior, this signed distance is equivalent to
|
61
|
-
* the full distance between `target` and this line segment.
|
62
|
-
*/
|
63
|
-
signedDistance(target: Point2): number;
|
64
|
-
/** Returns a copy of this line segment transformed by the given `affineTransfm`. */
|
65
|
-
transformedBy(affineTransfm: Mat33): LineSegment2;
|
66
|
-
/** @inheritdoc */
|
67
|
-
getTightBoundingBox(): Rect2;
|
68
|
-
toString(): string;
|
69
|
-
}
|
70
|
-
export {};
|