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
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { Point2 } from '../Vec2';
|
2
|
-
import Vec3 from '../Vec3';
|
3
|
-
import Abstract2DShape from './Abstract2DShape';
|
4
|
-
import LineSegment2 from './LineSegment2';
|
5
|
-
import Rect2 from './Rect2';
|
6
|
-
/**
|
7
|
-
* Like a {@link Point2}, but with additional functionality (e.g. SDF).
|
8
|
-
*
|
9
|
-
* Access the internal `Point2` using the `p` property.
|
10
|
-
*/
|
11
|
-
declare class PointShape2D extends Abstract2DShape {
|
12
|
-
readonly p: Point2;
|
13
|
-
constructor(p: Point2);
|
14
|
-
signedDistance(point: Vec3): number;
|
15
|
-
intersectsLineSegment(lineSegment: LineSegment2, epsilon?: number): Vec3[];
|
16
|
-
getTightBoundingBox(): Rect2;
|
17
|
-
}
|
18
|
-
export default PointShape2D;
|
@@ -1,46 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
-
var Abstract2DShape_1 = require("./Abstract2DShape");
|
19
|
-
var Rect2_1 = require("./Rect2");
|
20
|
-
/**
|
21
|
-
* Like a {@link Point2}, but with additional functionality (e.g. SDF).
|
22
|
-
*
|
23
|
-
* Access the internal `Point2` using the `p` property.
|
24
|
-
*/
|
25
|
-
var PointShape2D = /** @class */ (function (_super) {
|
26
|
-
__extends(PointShape2D, _super);
|
27
|
-
function PointShape2D(p) {
|
28
|
-
var _this = _super.call(this) || this;
|
29
|
-
_this.p = p;
|
30
|
-
return _this;
|
31
|
-
}
|
32
|
-
PointShape2D.prototype.signedDistance = function (point) {
|
33
|
-
return this.p.minus(point).magnitude();
|
34
|
-
};
|
35
|
-
PointShape2D.prototype.intersectsLineSegment = function (lineSegment, epsilon) {
|
36
|
-
if (lineSegment.containsPoint(this.p, epsilon)) {
|
37
|
-
return [this.p];
|
38
|
-
}
|
39
|
-
return [];
|
40
|
-
};
|
41
|
-
PointShape2D.prototype.getTightBoundingBox = function () {
|
42
|
-
return new Rect2_1.default(this.p.x, this.p.y, 0, 0);
|
43
|
-
};
|
44
|
-
return PointShape2D;
|
45
|
-
}(Abstract2DShape_1.default));
|
46
|
-
exports.default = PointShape2D;
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { Point2, Vec2 } from '../Vec2';
|
2
|
-
import BezierJSWrapper from './BezierJSWrapper';
|
3
|
-
import Rect2 from './Rect2';
|
4
|
-
/**
|
5
|
-
* A wrapper around `bezier-js`'s quadratic Bézier.
|
6
|
-
*
|
7
|
-
* This wrappper lazy-loads `bezier-js`'s Bézier and can perform some operations
|
8
|
-
* without loading it at all (e.g. `normal`, `at`, and `approximateDistance`).
|
9
|
-
*/
|
10
|
-
export default class QuadraticBezier extends BezierJSWrapper {
|
11
|
-
readonly p0: Point2;
|
12
|
-
readonly p1: Point2;
|
13
|
-
readonly p2: Point2;
|
14
|
-
constructor(p0: Point2, p1: Point2, p2: Point2);
|
15
|
-
/**
|
16
|
-
* Returns a component of a quadratic Bézier curve at t, where p0,p1,p2 are either all x or
|
17
|
-
* all y components of the target curve.
|
18
|
-
*/
|
19
|
-
private static componentAt;
|
20
|
-
private static derivativeComponentAt;
|
21
|
-
/**
|
22
|
-
* @returns the curve evaluated at `t`.
|
23
|
-
*/
|
24
|
-
at(t: number): Point2;
|
25
|
-
derivativeAt(t: number): Point2;
|
26
|
-
normal(t: number): Vec2;
|
27
|
-
/** @returns an overestimate of this shape's bounding box. */
|
28
|
-
getLooseBoundingBox(): Rect2;
|
29
|
-
/**
|
30
|
-
* @returns the *approximate* distance from `point` to this curve.
|
31
|
-
*/
|
32
|
-
approximateDistance(point: Point2): number;
|
33
|
-
getPoints(): import("../Vec3").default[];
|
34
|
-
}
|
@@ -1,133 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
-
var Vec2_1 = require("../Vec2");
|
19
|
-
var solveQuadratic_1 = require("../polynomial/solveQuadratic");
|
20
|
-
var BezierJSWrapper_1 = require("./BezierJSWrapper");
|
21
|
-
var Rect2_1 = require("./Rect2");
|
22
|
-
/**
|
23
|
-
* A wrapper around `bezier-js`'s quadratic Bézier.
|
24
|
-
*
|
25
|
-
* This wrappper lazy-loads `bezier-js`'s Bézier and can perform some operations
|
26
|
-
* without loading it at all (e.g. `normal`, `at`, and `approximateDistance`).
|
27
|
-
*/
|
28
|
-
var QuadraticBezier = /** @class */ (function (_super) {
|
29
|
-
__extends(QuadraticBezier, _super);
|
30
|
-
function QuadraticBezier(p0, p1, p2) {
|
31
|
-
var _this = _super.call(this) || this;
|
32
|
-
_this.p0 = p0;
|
33
|
-
_this.p1 = p1;
|
34
|
-
_this.p2 = p2;
|
35
|
-
return _this;
|
36
|
-
}
|
37
|
-
/**
|
38
|
-
* Returns a component of a quadratic Bézier curve at t, where p0,p1,p2 are either all x or
|
39
|
-
* all y components of the target curve.
|
40
|
-
*/
|
41
|
-
QuadraticBezier.componentAt = function (t, p0, p1, p2) {
|
42
|
-
return p0 + t * (-2 * p0 + 2 * p1) + t * t * (p0 - 2 * p1 + p2);
|
43
|
-
};
|
44
|
-
QuadraticBezier.derivativeComponentAt = function (t, p0, p1, p2) {
|
45
|
-
return -2 * p0 + 2 * p1 + 2 * t * (p0 - 2 * p1 + p2);
|
46
|
-
};
|
47
|
-
/**
|
48
|
-
* @returns the curve evaluated at `t`.
|
49
|
-
*/
|
50
|
-
QuadraticBezier.prototype.at = function (t) {
|
51
|
-
var p0 = this.p0;
|
52
|
-
var p1 = this.p1;
|
53
|
-
var p2 = this.p2;
|
54
|
-
return Vec2_1.Vec2.of(QuadraticBezier.componentAt(t, p0.x, p1.x, p2.x), QuadraticBezier.componentAt(t, p0.y, p1.y, p2.y));
|
55
|
-
};
|
56
|
-
QuadraticBezier.prototype.derivativeAt = function (t) {
|
57
|
-
var p0 = this.p0;
|
58
|
-
var p1 = this.p1;
|
59
|
-
var p2 = this.p2;
|
60
|
-
return Vec2_1.Vec2.of(QuadraticBezier.derivativeComponentAt(t, p0.x, p1.x, p2.x), QuadraticBezier.derivativeComponentAt(t, p0.y, p1.y, p2.y));
|
61
|
-
};
|
62
|
-
QuadraticBezier.prototype.normal = function (t) {
|
63
|
-
var tangent = this.derivativeAt(t);
|
64
|
-
return tangent.orthog().normalized();
|
65
|
-
};
|
66
|
-
/** @returns an overestimate of this shape's bounding box. */
|
67
|
-
QuadraticBezier.prototype.getLooseBoundingBox = function () {
|
68
|
-
return Rect2_1.default.bboxOf([this.p0, this.p1, this.p2]);
|
69
|
-
};
|
70
|
-
/**
|
71
|
-
* @returns the *approximate* distance from `point` to this curve.
|
72
|
-
*/
|
73
|
-
QuadraticBezier.prototype.approximateDistance = function (point) {
|
74
|
-
// We want to minimize f(t) = |B(t) - p|².
|
75
|
-
// Expanding,
|
76
|
-
// f(t) = (Bₓ(t) - pₓ)² + (Bᵧ(t) - pᵧ)²
|
77
|
-
// ⇒ f'(t) = Dₜ(Bₓ(t) - pₓ)² + Dₜ(Bᵧ(t) - pᵧ)²
|
78
|
-
//
|
79
|
-
// Considering just one component,
|
80
|
-
// Dₜ(Bₓ(t) - pₓ)² = 2(Bₓ(t) - pₓ)(DₜBₓ(t))
|
81
|
-
// = 2(Bₓ(t)DₜBₓ(t) - pₓBₓ(t))
|
82
|
-
// = 2(p0ₓ + (t)(-2p0ₓ + 2p1ₓ) + (t²)(p0ₓ - 2p1ₓ + p2ₓ) - pₓ)((-2p0ₓ + 2p1ₓ) + 2(t)(p0ₓ - 2p1ₓ + p2ₓ))
|
83
|
-
// - (pₓ)((-2p0ₓ + 2p1ₓ) + (t)(p0ₓ - 2p1ₓ + p2ₓ))
|
84
|
-
var A = this.p0.x - point.x;
|
85
|
-
var B = -2 * this.p0.x + 2 * this.p1.x;
|
86
|
-
var C = this.p0.x - 2 * this.p1.x + this.p2.x;
|
87
|
-
// Let A = p0ₓ - pₓ, B = -2p0ₓ + 2p1ₓ, C = p0ₓ - 2p1ₓ + p2ₓ. We then have,
|
88
|
-
// Dₜ(Bₓ(t) - pₓ)²
|
89
|
-
// = 2(A + tB + t²C)(B + 2tC) - (pₓ)(B + 2tC)
|
90
|
-
// = 2(AB + tB² + t²BC + 2tCA + 2tCtB + 2tCt²C) - pₓB - pₓ2tC
|
91
|
-
// = 2(AB + tB² + 2tCA + t²BC + 2t²CB + 2C²t³) - pₓB - pₓ2tC
|
92
|
-
// = 2AB + 2t(B² + 2CA) + 2t²(BC + 2CB) + 4C²t³ - pₓB - pₓ2tC
|
93
|
-
// = 2AB + 2t(B² + 2CA - pₓC) + 2t²(BC + 2CB) + 4C²t³ - pₓB
|
94
|
-
//
|
95
|
-
var D = this.p0.y - point.y;
|
96
|
-
var E = -2 * this.p0.y + 2 * this.p1.y;
|
97
|
-
var F = this.p0.y - 2 * this.p1.y + this.p2.y;
|
98
|
-
// Using D = p0ᵧ - pᵧ, E = -2p0ᵧ + 2p1ᵧ, F = p0ᵧ - 2p1ᵧ + p2ᵧ, we thus have,
|
99
|
-
// f'(t) = 2AB + 2t(B² + 2CA - pₓC) + 2t²(BC + 2CB) + 4C²t³ - pₓB
|
100
|
-
// + 2DE + 2t(E² + 2FD - pᵧF) + 2t²(EF + 2FE) + 4F²t³ - pᵧE
|
101
|
-
var a = 2 * A * B + 2 * D * E - point.x * B - point.y * E;
|
102
|
-
var b = 2 * B * B + 2 * E * E + 2 * C * A + 2 * F * D - point.x * C - point.y * F;
|
103
|
-
var c = 2 * E * F + 2 * B * C + 2 * C * B + 2 * F * E;
|
104
|
-
//const d = 4 * C * C + 4 * F * F;
|
105
|
-
// Thus,
|
106
|
-
// f'(t) = a + bt + ct² + dt³
|
107
|
-
var fDerivAtZero = a;
|
108
|
-
var f2ndDerivAtZero = b;
|
109
|
-
var f3rdDerivAtZero = 2 * c;
|
110
|
-
// Using the first few terms of a Maclaurin series to approximate f'(t),
|
111
|
-
// f'(t) ≈ f'(0) + t f''(0) + t² f'''(0) / 2
|
112
|
-
var _a = (0, solveQuadratic_1.default)(f3rdDerivAtZero / 2, f2ndDerivAtZero, fDerivAtZero), min1 = _a[0], min2 = _a[1];
|
113
|
-
// If the quadratic has no solutions, approximate.
|
114
|
-
if (isNaN(min1)) {
|
115
|
-
min1 = 0.25;
|
116
|
-
}
|
117
|
-
if (isNaN(min2)) {
|
118
|
-
min2 = 0.75;
|
119
|
-
}
|
120
|
-
var at1 = this.at(min1);
|
121
|
-
var at2 = this.at(min2);
|
122
|
-
var sqrDist1 = at1.minus(point).magnitudeSquared();
|
123
|
-
var sqrDist2 = at2.minus(point).magnitudeSquared();
|
124
|
-
var sqrDist3 = this.at(0).minus(point).magnitudeSquared();
|
125
|
-
var sqrDist4 = this.at(1).minus(point).magnitudeSquared();
|
126
|
-
return Math.sqrt(Math.min(sqrDist1, sqrDist2, sqrDist3, sqrDist4));
|
127
|
-
};
|
128
|
-
QuadraticBezier.prototype.getPoints = function () {
|
129
|
-
return [this.p0, this.p1, this.p2];
|
130
|
-
};
|
131
|
-
return QuadraticBezier;
|
132
|
-
}(BezierJSWrapper_1.default));
|
133
|
-
exports.default = QuadraticBezier;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import LineSegment2 from './LineSegment2';
|
2
|
-
import Mat33 from '../Mat33';
|
3
|
-
import { Point2, Vec2 } from '../Vec2';
|
4
|
-
import Abstract2DShape from './Abstract2DShape';
|
5
|
-
import Vec3 from '../Vec3';
|
6
|
-
/** An object that can be converted to a Rect2. */
|
7
|
-
export interface RectTemplate {
|
8
|
-
x: number;
|
9
|
-
y: number;
|
10
|
-
w?: number;
|
11
|
-
h?: number;
|
12
|
-
width?: number;
|
13
|
-
height?: number;
|
14
|
-
}
|
15
|
-
export default class Rect2 extends Abstract2DShape {
|
16
|
-
readonly x: number;
|
17
|
-
readonly y: number;
|
18
|
-
readonly w: number;
|
19
|
-
readonly h: number;
|
20
|
-
readonly topLeft: Point2;
|
21
|
-
readonly size: Vec2;
|
22
|
-
readonly bottomRight: Point2;
|
23
|
-
readonly area: number;
|
24
|
-
constructor(x: number, y: number, w: number, h: number);
|
25
|
-
translatedBy(vec: Vec2): Rect2;
|
26
|
-
resizedTo(size: Vec2): Rect2;
|
27
|
-
containsPoint(other: Point2): boolean;
|
28
|
-
containsRect(other: Rect2): boolean;
|
29
|
-
intersects(other: Rect2): boolean;
|
30
|
-
intersection(other: Rect2): Rect2 | null;
|
31
|
-
union(other: Rect2): Rect2;
|
32
|
-
divideIntoGrid(columns: number, rows: number): Rect2[];
|
33
|
-
grownToPoint(point: Point2, margin?: number): Rect2;
|
34
|
-
grownBy(margin: number): Rect2;
|
35
|
-
getClosestPointOnBoundaryTo(target: Point2): Vec3;
|
36
|
-
get corners(): Point2[];
|
37
|
-
get maxDimension(): number;
|
38
|
-
get topRight(): Vec3;
|
39
|
-
get bottomLeft(): Vec3;
|
40
|
-
get width(): number;
|
41
|
-
get height(): number;
|
42
|
-
get center(): Vec3;
|
43
|
-
getEdges(): LineSegment2[];
|
44
|
-
intersectsLineSegment(lineSegment: LineSegment2): Point2[];
|
45
|
-
signedDistance(point: Vec3): number;
|
46
|
-
getTightBoundingBox(): Rect2;
|
47
|
-
transformedBoundingBox(affineTransform: Mat33): Rect2;
|
48
|
-
/** @return true iff this is equal to [other] ± fuzz */
|
49
|
-
eq(other: Rect2, fuzz?: number): boolean;
|
50
|
-
toString(): string;
|
51
|
-
static fromCorners(corner1: Point2, corner2: Point2): Rect2;
|
52
|
-
static bboxOf(points: Point2[], margin?: number): Rect2;
|
53
|
-
static union(...rects: Rect2[]): Rect2;
|
54
|
-
static of(template: RectTemplate): Rect2;
|
55
|
-
static empty: Rect2;
|
56
|
-
static unitSquare: Rect2;
|
57
|
-
}
|
@@ -1,311 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
-
var LineSegment2_1 = require("./LineSegment2");
|
19
|
-
var Vec2_1 = require("../Vec2");
|
20
|
-
var Abstract2DShape_1 = require("./Abstract2DShape");
|
21
|
-
// invariant: w ≥ 0, h ≥ 0, immutable
|
22
|
-
var Rect2 = /** @class */ (function (_super) {
|
23
|
-
__extends(Rect2, _super);
|
24
|
-
function Rect2(x, y, w, h) {
|
25
|
-
var _this = _super.call(this) || this;
|
26
|
-
_this.x = x;
|
27
|
-
_this.y = y;
|
28
|
-
_this.w = w;
|
29
|
-
_this.h = h;
|
30
|
-
if (w < 0) {
|
31
|
-
_this.x += w;
|
32
|
-
_this.w = Math.abs(w);
|
33
|
-
}
|
34
|
-
if (h < 0) {
|
35
|
-
_this.y += h;
|
36
|
-
_this.h = Math.abs(h);
|
37
|
-
}
|
38
|
-
// Precompute/store vector forms.
|
39
|
-
_this.topLeft = Vec2_1.Vec2.of(_this.x, _this.y);
|
40
|
-
_this.size = Vec2_1.Vec2.of(_this.w, _this.h);
|
41
|
-
_this.bottomRight = _this.topLeft.plus(_this.size);
|
42
|
-
_this.area = _this.w * _this.h;
|
43
|
-
return _this;
|
44
|
-
}
|
45
|
-
Rect2.prototype.translatedBy = function (vec) {
|
46
|
-
return new Rect2(vec.x + this.x, vec.y + this.y, this.w, this.h);
|
47
|
-
};
|
48
|
-
// Returns a copy of this with the given size (but same top-left).
|
49
|
-
Rect2.prototype.resizedTo = function (size) {
|
50
|
-
return new Rect2(this.x, this.y, size.x, size.y);
|
51
|
-
};
|
52
|
-
Rect2.prototype.containsPoint = function (other) {
|
53
|
-
return this.x <= other.x && this.y <= other.y
|
54
|
-
&& this.x + this.w >= other.x && this.y + this.h >= other.y;
|
55
|
-
};
|
56
|
-
Rect2.prototype.containsRect = function (other) {
|
57
|
-
return this.x <= other.x && this.y <= other.y
|
58
|
-
&& this.bottomRight.x >= other.bottomRight.x
|
59
|
-
&& this.bottomRight.y >= other.bottomRight.y;
|
60
|
-
};
|
61
|
-
Rect2.prototype.intersects = function (other) {
|
62
|
-
// Project along x/y axes.
|
63
|
-
var thisMinX = this.x;
|
64
|
-
var thisMaxX = thisMinX + this.w;
|
65
|
-
var otherMinX = other.x;
|
66
|
-
var otherMaxX = other.x + other.w;
|
67
|
-
if (thisMaxX < otherMinX || thisMinX > otherMaxX) {
|
68
|
-
return false;
|
69
|
-
}
|
70
|
-
var thisMinY = this.y;
|
71
|
-
var thisMaxY = thisMinY + this.h;
|
72
|
-
var otherMinY = other.y;
|
73
|
-
var otherMaxY = other.y + other.h;
|
74
|
-
if (thisMaxY < otherMinY || thisMinY > otherMaxY) {
|
75
|
-
return false;
|
76
|
-
}
|
77
|
-
return true;
|
78
|
-
};
|
79
|
-
// Returns the overlap of this and [other], or null, if no such
|
80
|
-
// overlap exists
|
81
|
-
Rect2.prototype.intersection = function (other) {
|
82
|
-
if (!this.intersects(other)) {
|
83
|
-
return null;
|
84
|
-
}
|
85
|
-
var topLeft = this.topLeft.zip(other.topLeft, Math.max);
|
86
|
-
var bottomRight = this.bottomRight.zip(other.bottomRight, Math.min);
|
87
|
-
return Rect2.fromCorners(topLeft, bottomRight);
|
88
|
-
};
|
89
|
-
// Returns a new rectangle containing both [this] and [other].
|
90
|
-
Rect2.prototype.union = function (other) {
|
91
|
-
return Rect2.union(this, other);
|
92
|
-
};
|
93
|
-
// Returns a the subdivision of this into [columns] columns
|
94
|
-
// and [rows] rows. For example,
|
95
|
-
// Rect2.unitSquare.divideIntoGrid(2, 2)
|
96
|
-
// -> [ Rect2(0, 0, 0.5, 0.5), Rect2(0.5, 0, 0.5, 0.5), Rect2(0, 0.5, 0.5, 0.5), Rect2(0.5, 0.5, 0.5, 0.5) ]
|
97
|
-
// The rectangles are ordered in row-major order.
|
98
|
-
Rect2.prototype.divideIntoGrid = function (columns, rows) {
|
99
|
-
var result = [];
|
100
|
-
if (columns <= 0 || rows <= 0) {
|
101
|
-
return result;
|
102
|
-
}
|
103
|
-
var eachRectWidth = this.w / columns;
|
104
|
-
var eachRectHeight = this.h / rows;
|
105
|
-
if (eachRectWidth === 0) {
|
106
|
-
columns = 1;
|
107
|
-
}
|
108
|
-
if (eachRectHeight === 0) {
|
109
|
-
rows = 1;
|
110
|
-
}
|
111
|
-
for (var j = 0; j < rows; j++) {
|
112
|
-
for (var i = 0; i < columns; i++) {
|
113
|
-
var x = eachRectWidth * i + this.x;
|
114
|
-
var y = eachRectHeight * j + this.y;
|
115
|
-
result.push(new Rect2(x, y, eachRectWidth, eachRectHeight));
|
116
|
-
}
|
117
|
-
}
|
118
|
-
return result;
|
119
|
-
};
|
120
|
-
// Returns a rectangle containing this and [point].
|
121
|
-
// [margin] is the minimum distance between the new point and the edge
|
122
|
-
// of the resultant rectangle.
|
123
|
-
Rect2.prototype.grownToPoint = function (point, margin) {
|
124
|
-
if (margin === void 0) { margin = 0; }
|
125
|
-
var otherRect = new Rect2(point.x - margin, point.y - margin, margin * 2, margin * 2);
|
126
|
-
return this.union(otherRect);
|
127
|
-
};
|
128
|
-
// Returns this grown by [margin] in both the x and y directions.
|
129
|
-
Rect2.prototype.grownBy = function (margin) {
|
130
|
-
if (margin === 0) {
|
131
|
-
return this;
|
132
|
-
}
|
133
|
-
return new Rect2(this.x - margin, this.y - margin, this.w + margin * 2, this.h + margin * 2);
|
134
|
-
};
|
135
|
-
Rect2.prototype.getClosestPointOnBoundaryTo = function (target) {
|
136
|
-
var closestEdgePoints = this.getEdges().map(function (edge) {
|
137
|
-
return edge.closestPointTo(target);
|
138
|
-
});
|
139
|
-
var closest = null;
|
140
|
-
var closestDist = null;
|
141
|
-
for (var _i = 0, closestEdgePoints_1 = closestEdgePoints; _i < closestEdgePoints_1.length; _i++) {
|
142
|
-
var point = closestEdgePoints_1[_i];
|
143
|
-
var dist = point.minus(target).length();
|
144
|
-
if (closestDist === null || dist < closestDist) {
|
145
|
-
closest = point;
|
146
|
-
closestDist = dist;
|
147
|
-
}
|
148
|
-
}
|
149
|
-
return closest;
|
150
|
-
};
|
151
|
-
Object.defineProperty(Rect2.prototype, "corners", {
|
152
|
-
get: function () {
|
153
|
-
return [
|
154
|
-
this.bottomRight,
|
155
|
-
this.topRight,
|
156
|
-
this.topLeft,
|
157
|
-
this.bottomLeft,
|
158
|
-
];
|
159
|
-
},
|
160
|
-
enumerable: false,
|
161
|
-
configurable: true
|
162
|
-
});
|
163
|
-
Object.defineProperty(Rect2.prototype, "maxDimension", {
|
164
|
-
get: function () {
|
165
|
-
return Math.max(this.w, this.h);
|
166
|
-
},
|
167
|
-
enumerable: false,
|
168
|
-
configurable: true
|
169
|
-
});
|
170
|
-
Object.defineProperty(Rect2.prototype, "topRight", {
|
171
|
-
get: function () {
|
172
|
-
return this.bottomRight.plus(Vec2_1.Vec2.of(0, -this.h));
|
173
|
-
},
|
174
|
-
enumerable: false,
|
175
|
-
configurable: true
|
176
|
-
});
|
177
|
-
Object.defineProperty(Rect2.prototype, "bottomLeft", {
|
178
|
-
get: function () {
|
179
|
-
return this.topLeft.plus(Vec2_1.Vec2.of(0, this.h));
|
180
|
-
},
|
181
|
-
enumerable: false,
|
182
|
-
configurable: true
|
183
|
-
});
|
184
|
-
Object.defineProperty(Rect2.prototype, "width", {
|
185
|
-
get: function () {
|
186
|
-
return this.w;
|
187
|
-
},
|
188
|
-
enumerable: false,
|
189
|
-
configurable: true
|
190
|
-
});
|
191
|
-
Object.defineProperty(Rect2.prototype, "height", {
|
192
|
-
get: function () {
|
193
|
-
return this.h;
|
194
|
-
},
|
195
|
-
enumerable: false,
|
196
|
-
configurable: true
|
197
|
-
});
|
198
|
-
Object.defineProperty(Rect2.prototype, "center", {
|
199
|
-
get: function () {
|
200
|
-
return this.topLeft.plus(this.size.times(0.5));
|
201
|
-
},
|
202
|
-
enumerable: false,
|
203
|
-
configurable: true
|
204
|
-
});
|
205
|
-
// Returns edges in the order
|
206
|
-
// [ rightEdge, topEdge, leftEdge, bottomEdge ]
|
207
|
-
Rect2.prototype.getEdges = function () {
|
208
|
-
var corners = this.corners;
|
209
|
-
return [
|
210
|
-
new LineSegment2_1.default(corners[0], corners[1]),
|
211
|
-
new LineSegment2_1.default(corners[1], corners[2]),
|
212
|
-
new LineSegment2_1.default(corners[2], corners[3]),
|
213
|
-
new LineSegment2_1.default(corners[3], corners[0]),
|
214
|
-
];
|
215
|
-
};
|
216
|
-
Rect2.prototype.intersectsLineSegment = function (lineSegment) {
|
217
|
-
var result = [];
|
218
|
-
for (var _i = 0, _a = this.getEdges(); _i < _a.length; _i++) {
|
219
|
-
var edge = _a[_i];
|
220
|
-
var intersection = edge.intersectsLineSegment(lineSegment);
|
221
|
-
intersection.forEach(function (point) { return result.push(point); });
|
222
|
-
}
|
223
|
-
return result;
|
224
|
-
};
|
225
|
-
Rect2.prototype.signedDistance = function (point) {
|
226
|
-
var closestBoundaryPoint = this.getClosestPointOnBoundaryTo(point);
|
227
|
-
var dist = point.minus(closestBoundaryPoint).magnitude();
|
228
|
-
if (this.containsPoint(point)) {
|
229
|
-
return -dist;
|
230
|
-
}
|
231
|
-
return dist;
|
232
|
-
};
|
233
|
-
Rect2.prototype.getTightBoundingBox = function () {
|
234
|
-
return this;
|
235
|
-
};
|
236
|
-
// [affineTransform] is a transformation matrix that both scales and **translates**.
|
237
|
-
// the bounding box of this' four corners after transformed by the given affine transformation.
|
238
|
-
Rect2.prototype.transformedBoundingBox = function (affineTransform) {
|
239
|
-
return Rect2.bboxOf(this.corners.map(function (corner) { return affineTransform.transformVec2(corner); }));
|
240
|
-
};
|
241
|
-
/** @return true iff this is equal to [other] ± fuzz */
|
242
|
-
Rect2.prototype.eq = function (other, fuzz) {
|
243
|
-
if (fuzz === void 0) { fuzz = 0; }
|
244
|
-
return this.topLeft.eq(other.topLeft, fuzz) && this.size.eq(other.size, fuzz);
|
245
|
-
};
|
246
|
-
Rect2.prototype.toString = function () {
|
247
|
-
return "Rect(point(".concat(this.x, ", ").concat(this.y, "), size(").concat(this.w, ", ").concat(this.h, "))");
|
248
|
-
};
|
249
|
-
Rect2.fromCorners = function (corner1, corner2) {
|
250
|
-
return new Rect2(Math.min(corner1.x, corner2.x), Math.min(corner1.y, corner2.y), Math.abs(corner1.x - corner2.x), Math.abs(corner1.y - corner2.y));
|
251
|
-
};
|
252
|
-
// Returns a box that contains all points in [points] with at least [margin]
|
253
|
-
// between each point and the edge of the box.
|
254
|
-
Rect2.bboxOf = function (points, margin) {
|
255
|
-
if (margin === void 0) { margin = 0; }
|
256
|
-
var minX = 0;
|
257
|
-
var minY = 0;
|
258
|
-
var maxX = 0;
|
259
|
-
var maxY = 0;
|
260
|
-
var isFirst = true;
|
261
|
-
for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
|
262
|
-
var point = points_1[_i];
|
263
|
-
if (isFirst) {
|
264
|
-
minX = point.x;
|
265
|
-
minY = point.y;
|
266
|
-
maxX = point.x;
|
267
|
-
maxY = point.y;
|
268
|
-
isFirst = false;
|
269
|
-
}
|
270
|
-
minX = Math.min(minX, point.x);
|
271
|
-
minY = Math.min(minY, point.y);
|
272
|
-
maxX = Math.max(maxX, point.x);
|
273
|
-
maxY = Math.max(maxY, point.y);
|
274
|
-
}
|
275
|
-
return Rect2.fromCorners(Vec2_1.Vec2.of(minX - margin, minY - margin), Vec2_1.Vec2.of(maxX + margin, maxY + margin));
|
276
|
-
};
|
277
|
-
// @returns a rectangle that contains all of the given rectangles, the bounding box
|
278
|
-
// of the given rectangles.
|
279
|
-
Rect2.union = function () {
|
280
|
-
var rects = [];
|
281
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
282
|
-
rects[_i] = arguments[_i];
|
283
|
-
}
|
284
|
-
if (rects.length === 0) {
|
285
|
-
return Rect2.empty;
|
286
|
-
}
|
287
|
-
var firstRect = rects[0];
|
288
|
-
var minX = firstRect.topLeft.x;
|
289
|
-
var minY = firstRect.topLeft.y;
|
290
|
-
var maxX = firstRect.bottomRight.x;
|
291
|
-
var maxY = firstRect.bottomRight.y;
|
292
|
-
for (var i = 1; i < rects.length; i++) {
|
293
|
-
var rect = rects[i];
|
294
|
-
minX = Math.min(minX, rect.topLeft.x);
|
295
|
-
minY = Math.min(minY, rect.topLeft.y);
|
296
|
-
maxX = Math.max(maxX, rect.bottomRight.x);
|
297
|
-
maxY = Math.max(maxY, rect.bottomRight.y);
|
298
|
-
}
|
299
|
-
return new Rect2(minX, minY, maxX - minX, maxY - minY);
|
300
|
-
};
|
301
|
-
Rect2.of = function (template) {
|
302
|
-
var _a, _b, _c, _d;
|
303
|
-
var width = (_b = (_a = template.width) !== null && _a !== void 0 ? _a : template.w) !== null && _b !== void 0 ? _b : 0;
|
304
|
-
var height = (_d = (_c = template.height) !== null && _c !== void 0 ? _c : template.h) !== null && _d !== void 0 ? _d : 0;
|
305
|
-
return new Rect2(template.x, template.y, width, height);
|
306
|
-
};
|
307
|
-
Rect2.empty = new Rect2(0, 0, 0, 0);
|
308
|
-
Rect2.unitSquare = new Rect2(0, 0, 1, 1);
|
309
|
-
return Rect2;
|
310
|
-
}(Abstract2DShape_1.default));
|
311
|
-
exports.default = Rect2;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import Mat33 from '../Mat33';
|
2
|
-
import { Point2 } from '../Vec2';
|
3
|
-
import Vec3 from '../Vec3';
|
4
|
-
import Abstract2DShape from './Abstract2DShape';
|
5
|
-
import LineSegment2 from './LineSegment2';
|
6
|
-
import Rect2 from './Rect2';
|
7
|
-
type TriangleBoundary = [LineSegment2, LineSegment2, LineSegment2];
|
8
|
-
export default class Triangle extends Abstract2DShape {
|
9
|
-
#private;
|
10
|
-
readonly vertex1: Vec3;
|
11
|
-
readonly vertex2: Vec3;
|
12
|
-
readonly vertex3: Vec3;
|
13
|
-
/**
|
14
|
-
* @see {@link fromVertices}
|
15
|
-
*/
|
16
|
-
protected constructor(vertex1: Vec3, vertex2: Vec3, vertex3: Vec3);
|
17
|
-
/**
|
18
|
-
* Creates a triangle from its three corners. Corners may be stored in a different
|
19
|
-
* order than given.
|
20
|
-
*/
|
21
|
-
static fromVertices(vertex1: Vec3, vertex2: Vec3, vertex3: Vec3): Triangle;
|
22
|
-
get vertices(): [Point2, Point2, Point2];
|
23
|
-
map(mapping: (vertex: Vec3) => Vec3): Triangle;
|
24
|
-
transformed2DBy(affineTransform: Mat33): Triangle;
|
25
|
-
transformedBy(linearTransform: Mat33): Triangle;
|
26
|
-
/**
|
27
|
-
* Returns the sides of this triangle, as an array of `LineSegment2`s.
|
28
|
-
*
|
29
|
-
* The first side is from `vertex1` to `vertex2`, the next from `vertex2` to `vertex3`,
|
30
|
-
* and the last from `vertex3` to `vertex1`.
|
31
|
-
*/
|
32
|
-
getEdges(): TriangleBoundary;
|
33
|
-
intersectsLineSegment(lineSegment: LineSegment2): Vec3[];
|
34
|
-
/** @inheritdoc */
|
35
|
-
containsPoint(point: Vec3, epsilon?: number): boolean;
|
36
|
-
/**
|
37
|
-
* @returns the signed distance from `point` to the closest edge of this triangle.
|
38
|
-
*
|
39
|
-
* If `point` is inside `this`, the result is negative, otherwise, the result is
|
40
|
-
* positive.
|
41
|
-
*/
|
42
|
-
signedDistance(point: Vec3): number;
|
43
|
-
/** @inheritdoc */
|
44
|
-
getTightBoundingBox(): Rect2;
|
45
|
-
}
|
46
|
-
export {};
|