js-draw 0.25.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -26
- package/build-config.json +22 -21
- package/dist/Editor.css +1281 -0
- package/dist/bundle.js +3 -3
- package/dist/bundledStyles.js +1 -1
- package/dist/cjs/Editor.d.ts +91 -12
- package/dist/cjs/Editor.js +619 -590
- package/dist/cjs/EditorImage.d.ts +5 -2
- package/dist/cjs/EditorImage.js +258 -297
- package/dist/cjs/EventDispatcher.js +17 -19
- package/dist/cjs/Pointer.d.ts +3 -1
- package/dist/cjs/Pointer.js +41 -44
- package/dist/cjs/SVGLoader.d.ts +7 -1
- package/dist/cjs/SVGLoader.js +373 -474
- package/dist/cjs/UndoRedoHistory.js +28 -40
- package/dist/cjs/Viewport.d.ts +1 -4
- package/dist/cjs/Viewport.js +150 -193
- package/dist/cjs/bundle/bundled.js +4 -1
- package/dist/cjs/commands/Command.js +22 -49
- package/dist/cjs/commands/Duplicate.js +28 -44
- package/dist/cjs/commands/Erase.js +36 -54
- package/dist/cjs/commands/SerializableCommand.js +20 -35
- package/dist/cjs/commands/UnresolvedCommand.js +14 -29
- package/dist/cjs/commands/invertCommand.js +29 -51
- package/dist/cjs/commands/lib.js +9 -6
- package/dist/cjs/commands/localization.d.ts +1 -1
- package/dist/cjs/commands/localization.js +9 -9
- package/dist/cjs/commands/uniteCommands.js +57 -87
- package/dist/cjs/components/AbstractComponent.d.ts +11 -3
- package/dist/cjs/components/AbstractComponent.js +141 -169
- package/dist/cjs/components/BackgroundComponent.d.ts +3 -6
- package/dist/cjs/components/BackgroundComponent.js +124 -149
- package/dist/cjs/components/ImageComponent.d.ts +3 -5
- package/dist/cjs/components/ImageComponent.js +95 -175
- package/dist/cjs/components/RestylableComponent.d.ts +1 -1
- package/dist/cjs/components/RestylableComponent.js +41 -56
- package/dist/cjs/components/SVGGlobalAttributesObject.d.ts +1 -3
- package/dist/cjs/components/SVGGlobalAttributesObject.js +34 -51
- package/dist/cjs/components/Stroke.d.ts +4 -6
- package/dist/cjs/components/Stroke.js +95 -121
- package/dist/cjs/components/TextComponent.d.ts +2 -4
- package/dist/cjs/components/TextComponent.js +189 -234
- package/dist/cjs/components/UnknownSVGObject.d.ts +1 -3
- package/dist/cjs/components/UnknownSVGObject.js +30 -43
- package/dist/cjs/components/builders/ArrowBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/ArrowBuilder.js +43 -42
- package/dist/cjs/components/builders/CircleBuilder.js +43 -43
- package/dist/cjs/components/builders/FreehandLineBuilder.d.ts +3 -2
- package/dist/cjs/components/builders/FreehandLineBuilder.js +73 -86
- package/dist/cjs/components/builders/LineBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/LineBuilder.js +38 -36
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/PressureSensitiveFreehandLineBuilder.js +131 -139
- package/dist/cjs/components/builders/RectangleBuilder.d.ts +1 -1
- package/dist/cjs/components/builders/RectangleBuilder.js +31 -31
- package/dist/cjs/components/builders/types.d.ts +1 -1
- package/dist/cjs/components/lib.d.ts +3 -1
- package/dist/cjs/components/lib.js +10 -7
- package/dist/cjs/components/localization.js +4 -4
- package/dist/cjs/components/util/StrokeSmoother.d.ts +1 -2
- package/dist/cjs/components/util/StrokeSmoother.js +67 -72
- package/dist/cjs/components/util/describeComponentList.d.ts +1 -1
- package/dist/cjs/components/util/describeComponentList.js +4 -5
- package/dist/cjs/dialogs/makeAboutDialog.d.ts +15 -0
- package/dist/cjs/dialogs/makeAboutDialog.js +54 -0
- package/dist/cjs/inputEvents.d.ts +84 -0
- package/dist/cjs/inputEvents.js +40 -0
- package/dist/cjs/lib.d.ts +29 -13
- package/dist/cjs/lib.js +38 -23
- package/dist/cjs/localization.js +19 -18
- package/dist/cjs/localizations/de.js +117 -13
- package/dist/cjs/localizations/en.js +4 -13
- package/dist/cjs/localizations/es.js +62 -23
- package/dist/cjs/localizations/getLocalizationTable.js +15 -13
- package/dist/cjs/rendering/Display.d.ts +1 -2
- package/dist/cjs/rendering/Display.js +70 -83
- package/dist/cjs/rendering/RenderablePathSpec.d.ts +15 -0
- package/dist/cjs/rendering/RenderablePathSpec.js +70 -0
- package/dist/cjs/rendering/RenderingStyle.d.ts +4 -4
- package/dist/cjs/rendering/RenderingStyle.js +18 -28
- package/dist/cjs/rendering/TextRenderingStyle.d.ts +10 -10
- package/dist/cjs/rendering/TextRenderingStyle.js +13 -18
- package/dist/cjs/rendering/caching/CacheRecord.d.ts +1 -2
- package/dist/cjs/rendering/caching/CacheRecord.js +20 -22
- package/dist/cjs/rendering/caching/CacheRecordManager.d.ts +1 -1
- package/dist/cjs/rendering/caching/CacheRecordManager.js +17 -15
- package/dist/cjs/rendering/caching/RenderingCache.js +19 -19
- package/dist/cjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
- package/dist/cjs/rendering/caching/RenderingCacheNode.js +98 -118
- package/dist/cjs/rendering/caching/testUtils.js +24 -23
- package/dist/cjs/rendering/caching/types.d.ts +3 -3
- package/dist/cjs/rendering/lib.js +8 -5
- package/dist/cjs/rendering/localization.js +5 -5
- package/dist/cjs/rendering/renderers/AbstractRenderer.d.ts +2 -11
- package/dist/cjs/rendering/renderers/AbstractRenderer.js +53 -57
- package/dist/cjs/rendering/renderers/CanvasRenderer.d.ts +3 -5
- package/dist/cjs/rendering/renderers/CanvasRenderer.js +91 -106
- package/dist/cjs/rendering/renderers/DummyRenderer.d.ts +1 -4
- package/dist/cjs/rendering/renderers/DummyRenderer.js +56 -76
- package/dist/cjs/rendering/renderers/SVGRenderer.d.ts +5 -5
- package/dist/cjs/rendering/renderers/SVGRenderer.js +194 -176
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.d.ts +1 -3
- package/dist/cjs/rendering/renderers/TextOnlyRenderer.js +47 -72
- package/dist/cjs/shortcuts/KeyBinding.d.ts +5 -0
- package/dist/cjs/shortcuts/KeyBinding.js +94 -70
- package/dist/cjs/shortcuts/KeyboardShortcutManager.d.ts +1 -1
- package/dist/cjs/shortcuts/KeyboardShortcutManager.js +36 -45
- package/dist/cjs/shortcuts/lib.js +5 -2
- package/dist/cjs/testing/createEditor.js +7 -4
- package/dist/cjs/testing/getUniquePointerId.js +4 -5
- package/dist/cjs/testing/lib.js +5 -2
- package/dist/cjs/testing/sendPenEvent.d.ts +2 -2
- package/dist/cjs/testing/sendPenEvent.js +10 -7
- package/dist/cjs/testing/sendTouchEvent.d.ts +2 -2
- package/dist/cjs/testing/sendTouchEvent.js +34 -16
- package/dist/cjs/toolbar/AbstractToolbar.d.ts +166 -0
- package/dist/cjs/toolbar/AbstractToolbar.js +410 -0
- package/dist/cjs/toolbar/DropdownToolbar.d.ts +43 -0
- package/dist/cjs/toolbar/DropdownToolbar.js +176 -0
- package/dist/cjs/toolbar/EdgeToolbar.d.ts +47 -0
- package/dist/cjs/toolbar/EdgeToolbar.js +422 -0
- package/dist/cjs/toolbar/IconProvider.d.ts +54 -30
- package/dist/cjs/toolbar/IconProvider.js +652 -224
- package/dist/cjs/toolbar/constants.d.ts +1 -0
- package/dist/cjs/toolbar/constants.js +4 -0
- package/dist/cjs/toolbar/lib.d.ts +4 -2
- package/dist/cjs/toolbar/lib.js +10 -3
- package/dist/cjs/toolbar/localization.d.ts +9 -2
- package/dist/cjs/toolbar/localization.js +26 -19
- package/dist/cjs/toolbar/types.d.ts +7 -0
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/ActionButtonWidget.js +23 -39
- package/dist/cjs/toolbar/widgets/BaseToolWidget.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/BaseToolWidget.js +35 -37
- package/dist/cjs/toolbar/widgets/BaseWidget.d.ts +60 -5
- package/dist/cjs/toolbar/widgets/BaseWidget.js +232 -177
- package/dist/cjs/toolbar/widgets/DocumentPropertiesWidget.js +130 -117
- package/dist/cjs/toolbar/widgets/EraserToolWidget.d.ts +1 -3
- package/dist/cjs/toolbar/widgets/EraserToolWidget.js +45 -73
- package/dist/cjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
- package/dist/cjs/toolbar/widgets/HandToolWidget.js +126 -141
- package/dist/cjs/toolbar/widgets/InsertImageWidget.d.ts +9 -7
- package/dist/cjs/toolbar/widgets/InsertImageWidget.js +147 -212
- package/dist/cjs/toolbar/widgets/OverflowWidget.js +33 -61
- package/dist/cjs/toolbar/widgets/PenToolWidget.d.ts +8 -1
- package/dist/cjs/toolbar/widgets/PenToolWidget.js +162 -234
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.d.ts +3 -1
- package/dist/cjs/toolbar/widgets/SelectionToolWidget.js +105 -177
- package/dist/cjs/toolbar/widgets/TextToolWidget.js +64 -87
- package/dist/cjs/toolbar/widgets/components/makeColorInput.d.ts +10 -0
- package/dist/cjs/toolbar/{makeColorInput.js → widgets/components/makeColorInput.js} +57 -34
- package/dist/cjs/toolbar/widgets/components/makeFileInput.d.ts +12 -0
- package/dist/cjs/toolbar/widgets/components/makeFileInput.js +111 -0
- package/dist/cjs/toolbar/widgets/components/makeGridSelector.d.ts +24 -0
- package/dist/cjs/toolbar/widgets/components/makeGridSelector.js +127 -0
- package/dist/cjs/toolbar/widgets/components/makeSeparator.d.ts +7 -0
- package/dist/cjs/toolbar/widgets/components/makeSeparator.js +16 -0
- package/dist/cjs/toolbar/widgets/components/makeThicknessSlider.d.ts +8 -0
- package/dist/cjs/toolbar/widgets/components/makeThicknessSlider.js +47 -0
- package/dist/cjs/toolbar/widgets/keybindings.js +8 -5
- package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.d.ts +21 -0
- package/dist/cjs/toolbar/widgets/layout/DropdownLayoutManager.js +199 -0
- package/dist/cjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.d.ts +14 -0
- package/dist/cjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.js +60 -0
- package/dist/cjs/toolbar/widgets/layout/types.d.ts +63 -0
- package/dist/cjs/toolbar/widgets/layout/types.js +2 -0
- package/dist/cjs/toolbar/widgets/lib.d.ts +1 -1
- package/dist/cjs/toolbar/widgets/lib.js +15 -11
- package/dist/cjs/tools/BaseTool.d.ts +28 -9
- package/dist/cjs/tools/BaseTool.js +128 -51
- package/dist/cjs/tools/Eraser.d.ts +8 -1
- package/dist/cjs/tools/Eraser.js +82 -92
- package/dist/cjs/tools/FindTool.d.ts +1 -1
- package/dist/cjs/tools/FindTool.js +61 -77
- package/dist/cjs/tools/InputFilter/FunctionMapper.d.ts +12 -0
- package/dist/cjs/tools/InputFilter/FunctionMapper.js +21 -0
- package/dist/cjs/tools/InputFilter/InputMapper.d.ts +23 -0
- package/dist/cjs/tools/InputFilter/InputMapper.js +38 -0
- package/dist/cjs/tools/InputFilter/InputPipeline.d.ts +15 -0
- package/dist/cjs/tools/InputFilter/InputPipeline.js +54 -0
- package/dist/cjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
- package/dist/cjs/tools/InputFilter/InputStabilizer.js +181 -0
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
- package/dist/cjs/tools/InputFilter/StrokeKeyboardControl.js +84 -0
- package/dist/cjs/tools/PanZoom.d.ts +4 -2
- package/dist/cjs/tools/PanZoom.js +186 -248
- package/dist/cjs/tools/PasteHandler.d.ts +1 -1
- package/dist/cjs/tools/PasteHandler.js +49 -148
- package/dist/cjs/tools/Pen.d.ts +12 -11
- package/dist/cjs/tools/Pen.js +123 -158
- package/dist/cjs/tools/PipetteTool.d.ts +11 -2
- package/dist/cjs/tools/PipetteTool.js +51 -48
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -1
- package/dist/cjs/tools/SelectionTool/SelectAllShortcutHandler.js +15 -30
- package/dist/cjs/tools/SelectionTool/Selection.d.ts +5 -5
- package/dist/cjs/tools/SelectionTool/Selection.js +308 -415
- package/dist/cjs/tools/SelectionTool/SelectionHandle.d.ts +15 -5
- package/dist/cjs/tools/SelectionTool/SelectionHandle.js +63 -37
- package/dist/cjs/tools/SelectionTool/SelectionTool.d.ts +4 -4
- package/dist/cjs/tools/SelectionTool/SelectionTool.js +164 -187
- package/dist/cjs/tools/SelectionTool/TransformMode.d.ts +1 -1
- package/dist/cjs/tools/SelectionTool/TransformMode.js +65 -66
- package/dist/cjs/tools/SoundUITool.d.ts +2 -1
- package/dist/cjs/tools/SoundUITool.js +70 -84
- package/dist/cjs/tools/TextTool.d.ts +5 -3
- package/dist/cjs/tools/TextTool.js +169 -173
- package/dist/cjs/tools/ToolController.d.ts +16 -2
- package/dist/cjs/tools/ToolController.js +124 -100
- package/dist/cjs/tools/ToolEnabledGroup.js +6 -9
- package/dist/cjs/tools/ToolSwitcherShortcut.d.ts +1 -1
- package/dist/cjs/tools/ToolSwitcherShortcut.js +16 -32
- package/dist/cjs/tools/ToolbarShortcutHandler.d.ts +1 -1
- package/dist/cjs/tools/ToolbarShortcutHandler.js +17 -33
- package/dist/cjs/tools/UndoRedoShortcut.d.ts +1 -1
- package/dist/cjs/tools/UndoRedoShortcut.js +12 -27
- package/dist/cjs/tools/keybindings.js +21 -18
- package/dist/cjs/tools/lib.js +17 -14
- package/dist/cjs/tools/localization.d.ts +2 -1
- package/dist/cjs/tools/localization.js +8 -7
- package/dist/cjs/types.d.ts +22 -80
- package/dist/cjs/types.js +8 -16
- package/dist/cjs/util/ReactiveValue.d.ts +65 -0
- package/dist/cjs/util/ReactiveValue.js +166 -0
- package/dist/cjs/util/assertions.js +5 -8
- package/dist/cjs/util/fileToBase64.js +6 -6
- package/dist/cjs/util/guessKeyCodeFromKey.d.ts +9 -0
- package/dist/cjs/util/guessKeyCodeFromKey.js +32 -0
- package/dist/cjs/util/listPrefixMatch.d.ts +6 -0
- package/dist/cjs/util/listPrefixMatch.js +17 -0
- package/dist/cjs/util/stopPropagationOfScrollingWheelEvents.d.ts +2 -0
- package/dist/cjs/util/stopPropagationOfScrollingWheelEvents.js +17 -0
- package/dist/cjs/util/untilNextAnimationFrame.js +3 -3
- package/dist/cjs/util/waitForAll.js +3 -3
- package/dist/cjs/util/waitForTimeout.js +3 -3
- package/dist/cjs/version.d.ts +4 -0
- package/dist/cjs/version.js +5 -0
- package/dist/mjs/Editor.d.ts +91 -12
- package/dist/mjs/Editor.mjs +565 -563
- package/dist/mjs/EditorImage.d.ts +5 -2
- package/dist/mjs/EditorImage.mjs +248 -291
- package/dist/mjs/EventDispatcher.mjs +17 -20
- package/dist/mjs/Pointer.d.ts +3 -1
- package/dist/mjs/Pointer.mjs +40 -44
- package/dist/mjs/SVGLoader.d.ts +7 -1
- package/dist/mjs/SVGLoader.mjs +338 -466
- package/dist/mjs/UndoRedoHistory.mjs +27 -39
- package/dist/mjs/Viewport.d.ts +1 -4
- package/dist/mjs/Viewport.mjs +139 -187
- package/dist/mjs/commands/Command.mjs +21 -49
- package/dist/mjs/commands/Duplicate.mjs +22 -41
- package/dist/mjs/commands/Erase.mjs +30 -51
- package/dist/mjs/commands/SerializableCommand.mjs +16 -34
- package/dist/mjs/commands/UnresolvedCommand.mjs +10 -29
- package/dist/mjs/commands/invertCommand.mjs +24 -49
- package/dist/mjs/commands/localization.d.ts +1 -1
- package/dist/mjs/commands/localization.mjs +10 -10
- package/dist/mjs/commands/uniteCommands.mjs +52 -85
- package/dist/mjs/components/AbstractComponent.d.ts +11 -3
- package/dist/mjs/components/AbstractComponent.mjs +135 -166
- package/dist/mjs/components/BackgroundComponent.d.ts +3 -6
- package/dist/mjs/components/BackgroundComponent.mjs +107 -136
- package/dist/mjs/components/ImageComponent.d.ts +3 -5
- package/dist/mjs/components/ImageComponent.mjs +90 -174
- package/dist/mjs/components/RestylableComponent.d.ts +1 -1
- package/dist/mjs/components/RestylableComponent.mjs +35 -53
- package/dist/mjs/components/SVGGlobalAttributesObject.d.ts +1 -3
- package/dist/mjs/components/SVGGlobalAttributesObject.mjs +29 -50
- package/dist/mjs/components/Stroke.d.ts +4 -6
- package/dist/mjs/components/Stroke.mjs +89 -119
- package/dist/mjs/components/TextComponent.d.ts +2 -4
- package/dist/mjs/components/TextComponent.mjs +180 -228
- package/dist/mjs/components/UnknownSVGObject.d.ts +1 -3
- package/dist/mjs/components/UnknownSVGObject.mjs +26 -43
- package/dist/mjs/components/builders/ArrowBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/ArrowBuilder.mjs +32 -35
- package/dist/mjs/components/builders/CircleBuilder.mjs +35 -38
- package/dist/mjs/components/builders/FreehandLineBuilder.d.ts +3 -2
- package/dist/mjs/components/builders/FreehandLineBuilder.mjs +52 -69
- package/dist/mjs/components/builders/LineBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/LineBuilder.mjs +30 -32
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/PressureSensitiveFreehandLineBuilder.mjs +103 -115
- package/dist/mjs/components/builders/RectangleBuilder.d.ts +1 -1
- package/dist/mjs/components/builders/RectangleBuilder.mjs +27 -31
- package/dist/mjs/components/builders/types.d.ts +1 -1
- package/dist/mjs/components/lib.d.ts +3 -1
- package/dist/mjs/components/lib.mjs +1 -1
- package/dist/mjs/components/localization.mjs +5 -5
- package/dist/mjs/components/util/StrokeSmoother.d.ts +1 -2
- package/dist/mjs/components/util/StrokeSmoother.mjs +63 -69
- package/dist/mjs/components/util/describeComponentList.d.ts +1 -1
- package/dist/mjs/components/util/describeComponentList.mjs +4 -5
- package/dist/mjs/dialogs/makeAboutDialog.d.ts +15 -0
- package/dist/mjs/dialogs/makeAboutDialog.mjs +52 -0
- package/dist/mjs/inputEvents.d.ts +84 -0
- package/dist/mjs/inputEvents.mjs +34 -0
- package/dist/mjs/lib.d.ts +29 -13
- package/dist/mjs/lib.mjs +30 -13
- package/dist/mjs/localization.mjs +14 -13
- package/dist/mjs/localizations/de.mjs +116 -12
- package/dist/mjs/localizations/en.mjs +3 -12
- package/dist/mjs/localizations/es.mjs +61 -22
- package/dist/mjs/localizations/getLocalizationTable.mjs +12 -13
- package/dist/mjs/rendering/Display.d.ts +1 -2
- package/dist/mjs/rendering/Display.mjs +62 -79
- package/dist/mjs/rendering/RenderablePathSpec.d.ts +15 -0
- package/dist/mjs/rendering/RenderablePathSpec.mjs +64 -0
- package/dist/mjs/rendering/RenderingStyle.d.ts +4 -4
- package/dist/mjs/rendering/RenderingStyle.mjs +16 -26
- package/dist/mjs/rendering/TextRenderingStyle.d.ts +10 -10
- package/dist/mjs/rendering/TextRenderingStyle.mjs +12 -17
- package/dist/mjs/rendering/caching/CacheRecord.d.ts +1 -2
- package/dist/mjs/rendering/caching/CacheRecord.mjs +20 -23
- package/dist/mjs/rendering/caching/CacheRecordManager.d.ts +1 -1
- package/dist/mjs/rendering/caching/CacheRecordManager.mjs +13 -15
- package/dist/mjs/rendering/caching/RenderingCache.mjs +13 -17
- package/dist/mjs/rendering/caching/RenderingCacheNode.d.ts +1 -1
- package/dist/mjs/rendering/caching/RenderingCacheNode.mjs +94 -115
- package/dist/mjs/rendering/caching/testUtils.mjs +19 -21
- package/dist/mjs/rendering/caching/types.d.ts +3 -3
- package/dist/mjs/rendering/localization.mjs +6 -6
- package/dist/mjs/rendering/renderers/AbstractRenderer.d.ts +2 -11
- package/dist/mjs/rendering/renderers/AbstractRenderer.mjs +47 -52
- package/dist/mjs/rendering/renderers/CanvasRenderer.d.ts +3 -5
- package/dist/mjs/rendering/renderers/CanvasRenderer.mjs +84 -103
- package/dist/mjs/rendering/renderers/DummyRenderer.d.ts +1 -4
- package/dist/mjs/rendering/renderers/DummyRenderer.mjs +51 -75
- package/dist/mjs/rendering/renderers/SVGRenderer.d.ts +5 -5
- package/dist/mjs/rendering/renderers/SVGRenderer.mjs +185 -171
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.d.ts +1 -3
- package/dist/mjs/rendering/renderers/TextOnlyRenderer.mjs +43 -72
- package/dist/mjs/shortcuts/KeyBinding.d.ts +5 -0
- package/dist/mjs/shortcuts/KeyBinding.mjs +94 -71
- package/dist/mjs/shortcuts/KeyboardShortcutManager.d.ts +1 -1
- package/dist/mjs/shortcuts/KeyboardShortcutManager.mjs +32 -44
- package/dist/mjs/testing/createEditor.mjs +2 -2
- package/dist/mjs/testing/getUniquePointerId.mjs +4 -5
- package/dist/mjs/testing/sendPenEvent.d.ts +2 -2
- package/dist/mjs/testing/sendPenEvent.mjs +5 -5
- package/dist/mjs/testing/sendTouchEvent.d.ts +2 -2
- package/dist/mjs/testing/sendTouchEvent.mjs +8 -16
- package/dist/mjs/toolbar/AbstractToolbar.d.ts +166 -0
- package/dist/mjs/toolbar/AbstractToolbar.mjs +405 -0
- package/dist/mjs/toolbar/DropdownToolbar.d.ts +43 -0
- package/dist/mjs/toolbar/DropdownToolbar.mjs +168 -0
- package/dist/mjs/toolbar/EdgeToolbar.d.ts +47 -0
- package/dist/mjs/toolbar/EdgeToolbar.mjs +414 -0
- package/dist/mjs/toolbar/IconProvider.d.ts +54 -30
- package/dist/mjs/toolbar/IconProvider.mjs +644 -219
- package/dist/mjs/toolbar/constants.d.ts +1 -0
- package/dist/mjs/toolbar/constants.mjs +1 -0
- package/dist/mjs/toolbar/lib.d.ts +4 -2
- package/dist/mjs/toolbar/lib.mjs +3 -1
- package/dist/mjs/toolbar/localization.d.ts +9 -2
- package/dist/mjs/toolbar/localization.mjs +27 -20
- package/dist/mjs/toolbar/types.d.ts +7 -0
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/ActionButtonWidget.mjs +19 -39
- package/dist/mjs/toolbar/widgets/BaseToolWidget.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/BaseToolWidget.mjs +30 -36
- package/dist/mjs/toolbar/widgets/BaseWidget.d.ts +60 -5
- package/dist/mjs/toolbar/widgets/BaseWidget.mjs +227 -176
- package/dist/mjs/toolbar/widgets/DocumentPropertiesWidget.mjs +98 -111
- package/dist/mjs/toolbar/widgets/EraserToolWidget.d.ts +1 -3
- package/dist/mjs/toolbar/widgets/EraserToolWidget.mjs +41 -73
- package/dist/mjs/toolbar/widgets/HandToolWidget.d.ts +1 -0
- package/dist/mjs/toolbar/widgets/HandToolWidget.mjs +94 -136
- package/dist/mjs/toolbar/widgets/InsertImageWidget.d.ts +9 -7
- package/dist/mjs/toolbar/widgets/InsertImageWidget.mjs +140 -208
- package/dist/mjs/toolbar/widgets/OverflowWidget.mjs +30 -62
- package/dist/mjs/toolbar/widgets/PenToolWidget.d.ts +8 -1
- package/dist/mjs/toolbar/widgets/PenToolWidget.mjs +150 -225
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.d.ts +3 -1
- package/dist/mjs/toolbar/widgets/SelectionToolWidget.mjs +97 -173
- package/dist/mjs/toolbar/widgets/TextToolWidget.mjs +59 -85
- package/dist/mjs/toolbar/widgets/components/makeColorInput.d.ts +10 -0
- package/dist/mjs/toolbar/{makeColorInput.mjs → widgets/components/makeColorInput.mjs} +53 -33
- package/dist/mjs/toolbar/widgets/components/makeFileInput.d.ts +12 -0
- package/dist/mjs/toolbar/widgets/components/makeFileInput.mjs +106 -0
- package/dist/mjs/toolbar/widgets/components/makeGridSelector.d.ts +24 -0
- package/dist/mjs/toolbar/widgets/components/makeGridSelector.mjs +122 -0
- package/dist/mjs/toolbar/widgets/components/makeSeparator.d.ts +7 -0
- package/dist/mjs/toolbar/widgets/components/makeSeparator.mjs +14 -0
- package/dist/mjs/toolbar/widgets/components/makeThicknessSlider.d.ts +8 -0
- package/dist/mjs/toolbar/widgets/components/makeThicknessSlider.mjs +45 -0
- package/dist/mjs/toolbar/widgets/keybindings.mjs +5 -5
- package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.d.ts +21 -0
- package/dist/mjs/toolbar/widgets/layout/DropdownLayoutManager.mjs +193 -0
- package/dist/mjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.d.ts +14 -0
- package/dist/mjs/toolbar/widgets/layout/EdgeToolbarLayoutManager.mjs +57 -0
- package/dist/mjs/toolbar/widgets/layout/types.d.ts +63 -0
- package/dist/mjs/toolbar/widgets/lib.d.ts +1 -1
- package/dist/mjs/toolbar/widgets/lib.mjs +1 -1
- package/dist/mjs/tools/BaseTool.d.ts +28 -9
- package/dist/mjs/tools/BaseTool.mjs +127 -50
- package/dist/mjs/tools/Eraser.d.ts +8 -1
- package/dist/mjs/tools/Eraser.mjs +72 -86
- package/dist/mjs/tools/FindTool.d.ts +1 -1
- package/dist/mjs/tools/FindTool.mjs +55 -75
- package/dist/mjs/tools/InputFilter/FunctionMapper.d.ts +12 -0
- package/dist/mjs/tools/InputFilter/FunctionMapper.mjs +15 -0
- package/dist/mjs/tools/InputFilter/InputMapper.d.ts +23 -0
- package/dist/mjs/tools/InputFilter/InputMapper.mjs +36 -0
- package/dist/mjs/tools/InputFilter/InputPipeline.d.ts +15 -0
- package/dist/mjs/tools/InputFilter/InputPipeline.mjs +49 -0
- package/dist/mjs/tools/InputFilter/InputStabilizer.d.ts +29 -0
- package/dist/mjs/tools/InputFilter/InputStabilizer.mjs +175 -0
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.d.ts +21 -0
- package/dist/mjs/tools/InputFilter/StrokeKeyboardControl.mjs +78 -0
- package/dist/mjs/tools/PanZoom.d.ts +4 -2
- package/dist/mjs/tools/PanZoom.mjs +169 -235
- package/dist/mjs/tools/PasteHandler.d.ts +1 -1
- package/dist/mjs/tools/PasteHandler.mjs +42 -145
- package/dist/mjs/tools/Pen.d.ts +12 -11
- package/dist/mjs/tools/Pen.mjs +115 -154
- package/dist/mjs/tools/PipetteTool.d.ts +11 -2
- package/dist/mjs/tools/PipetteTool.mjs +47 -48
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.d.ts +1 -1
- package/dist/mjs/tools/SelectionTool/SelectAllShortcutHandler.mjs +9 -28
- package/dist/mjs/tools/SelectionTool/Selection.d.ts +5 -5
- package/dist/mjs/tools/SelectionTool/Selection.mjs +268 -401
- package/dist/mjs/tools/SelectionTool/SelectionHandle.d.ts +15 -5
- package/dist/mjs/tools/SelectionTool/SelectionHandle.mjs +62 -37
- package/dist/mjs/tools/SelectionTool/SelectionTool.d.ts +4 -4
- package/dist/mjs/tools/SelectionTool/SelectionTool.mjs +153 -179
- package/dist/mjs/tools/SelectionTool/TransformMode.d.ts +1 -1
- package/dist/mjs/tools/SelectionTool/TransformMode.mjs +52 -59
- package/dist/mjs/tools/SoundUITool.d.ts +2 -1
- package/dist/mjs/tools/SoundUITool.mjs +66 -84
- package/dist/mjs/tools/TextTool.d.ts +5 -3
- package/dist/mjs/tools/TextTool.mjs +155 -163
- package/dist/mjs/tools/ToolController.d.ts +16 -2
- package/dist/mjs/tools/ToolController.mjs +81 -84
- package/dist/mjs/tools/ToolEnabledGroup.mjs +6 -10
- package/dist/mjs/tools/ToolSwitcherShortcut.d.ts +1 -1
- package/dist/mjs/tools/ToolSwitcherShortcut.mjs +12 -32
- package/dist/mjs/tools/ToolbarShortcutHandler.d.ts +1 -1
- package/dist/mjs/tools/ToolbarShortcutHandler.mjs +13 -33
- package/dist/mjs/tools/UndoRedoShortcut.d.ts +1 -1
- package/dist/mjs/tools/UndoRedoShortcut.mjs +7 -26
- package/dist/mjs/tools/keybindings.mjs +34 -34
- package/dist/mjs/tools/localization.d.ts +2 -1
- package/dist/mjs/tools/localization.mjs +9 -8
- package/dist/mjs/types.d.ts +22 -80
- package/dist/mjs/types.mjs +7 -15
- package/dist/mjs/util/ReactiveValue.d.ts +65 -0
- package/dist/mjs/util/ReactiveValue.mjs +161 -0
- package/dist/mjs/util/assertions.mjs +5 -8
- package/dist/mjs/util/fileToBase64.mjs +6 -6
- package/dist/mjs/util/guessKeyCodeFromKey.d.ts +9 -0
- package/dist/mjs/util/guessKeyCodeFromKey.mjs +30 -0
- package/dist/mjs/util/listPrefixMatch.d.ts +6 -0
- package/dist/mjs/util/listPrefixMatch.mjs +15 -0
- package/dist/mjs/util/stopPropagationOfScrollingWheelEvents.d.ts +2 -0
- package/dist/mjs/util/stopPropagationOfScrollingWheelEvents.mjs +15 -0
- package/dist/mjs/util/untilNextAnimationFrame.mjs +3 -3
- package/dist/mjs/util/waitForAll.mjs +3 -3
- package/dist/mjs/util/waitForTimeout.mjs +3 -3
- package/dist/mjs/version.d.ts +4 -0
- package/dist/mjs/version.mjs +3 -0
- package/dist-test/test_imports/package.json +1 -1
- package/dist-test/test_imports/test-imports.js +5 -11
- package/dist-test/test_imports/test-require.cjs +6 -11
- package/package.json +11 -22
- package/src/Coloris.css +8 -8
- package/src/Editor.loadFrom.test.ts +1 -1
- package/src/Editor.scss +148 -0
- package/src/Editor.test.ts +107 -0
- package/src/Editor.toSVG.test.ts +184 -1
- package/src/Editor.ts +325 -53
- package/src/EditorImage.test.ts +4 -7
- package/src/EditorImage.ts +10 -4
- package/src/Pointer.ts +18 -5
- package/src/SVGLoader.ts +77 -15
- package/src/UndoRedoHistory.test.ts +2 -1
- package/src/Viewport.ts +1 -4
- package/src/commands/Erase.ts +1 -0
- package/src/commands/localization.ts +1 -1
- package/src/commands/uniteCommands.test.ts +3 -3
- package/src/components/AbstractComponent.transformBy.test.ts +2 -1
- package/src/components/AbstractComponent.ts +12 -3
- package/src/components/BackgroundComponent.test.ts +1 -2
- package/src/components/BackgroundComponent.ts +3 -8
- package/src/components/ImageComponent.ts +1 -3
- package/src/components/RestylableComponent.ts +1 -1
- package/src/components/SVGGlobalAttributesObject.ts +1 -3
- package/src/components/Stroke.test.ts +4 -6
- package/src/components/Stroke.ts +5 -7
- package/src/components/TextComponent.test.ts +1 -3
- package/src/components/TextComponent.ts +1 -4
- package/src/components/UnknownSVGObject.ts +3 -3
- package/src/components/builders/ArrowBuilder.ts +1 -2
- package/src/components/builders/CircleBuilder.ts +3 -5
- package/src/components/builders/FreehandLineBuilder.test.ts +2 -3
- package/src/components/builders/FreehandLineBuilder.ts +3 -5
- package/src/components/builders/LineBuilder.ts +3 -3
- package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +3 -4
- package/src/components/builders/RectangleBuilder.ts +3 -4
- package/src/components/builders/types.ts +1 -1
- package/src/components/lib.ts +1 -1
- package/src/components/util/StrokeSmoother.ts +7 -7
- package/src/dialogs/dialogs.scss +36 -0
- package/src/dialogs/makeAboutDialog.scss +41 -0
- package/src/dialogs/makeAboutDialog.ts +82 -0
- package/src/inputEvents.ts +143 -0
- package/src/lib.ts +35 -13
- package/src/localizations/de.ts +2 -2
- package/src/localizations/es.ts +5 -5
- package/src/rendering/Display.ts +1 -2
- package/src/rendering/RenderablePathSpec.ts +88 -0
- package/src/rendering/RenderingStyle.test.ts +1 -1
- package/src/rendering/RenderingStyle.ts +1 -1
- package/src/rendering/caching/CacheRecord.test.ts +1 -2
- package/src/rendering/caching/CacheRecord.ts +1 -2
- package/src/rendering/caching/CacheRecordManager.ts +1 -1
- package/src/rendering/caching/RenderingCache.test.ts +3 -4
- package/src/rendering/caching/RenderingCache.ts +1 -1
- package/src/rendering/caching/RenderingCacheNode.ts +1 -2
- package/src/rendering/caching/testUtils.ts +1 -1
- package/src/rendering/caching/types.ts +3 -3
- package/src/rendering/renderers/AbstractRenderer.ts +4 -14
- package/src/rendering/renderers/CanvasRenderer.ts +17 -12
- package/src/rendering/renderers/DummyRenderer.test.ts +1 -2
- package/src/rendering/renderers/DummyRenderer.ts +1 -4
- package/src/rendering/renderers/SVGRenderer.ts +68 -11
- package/src/rendering/renderers/TextOnlyRenderer.ts +1 -4
- package/src/shortcuts/KeyBinding.test.ts +10 -0
- package/src/shortcuts/KeyBinding.ts +74 -35
- package/src/shortcuts/KeyboardShortcutManager.test.ts +1 -1
- package/src/styles.js +1 -1
- package/src/testing/sendPenEvent.ts +2 -2
- package/src/testing/sendTouchEvent.ts +2 -2
- package/src/toolbar/{toolbar.css → AbstractToolbar.scss} +47 -85
- package/src/toolbar/AbstractToolbar.ts +542 -0
- package/src/toolbar/DropdownToolbar.scss +46 -0
- package/src/toolbar/DropdownToolbar.ts +220 -0
- package/src/toolbar/EdgeToolbar.scss +511 -0
- package/src/toolbar/EdgeToolbar.test.ts +54 -0
- package/src/toolbar/EdgeToolbar.ts +543 -0
- package/src/toolbar/IconProvider.ts +189 -133
- package/src/toolbar/constants.ts +1 -0
- package/src/toolbar/lib.ts +4 -2
- package/src/toolbar/localization.ts +39 -17
- package/src/toolbar/toolbar.scss +11 -0
- package/src/toolbar/types.ts +8 -0
- package/src/toolbar/widgets/ActionButtonWidget.ts +2 -2
- package/src/toolbar/widgets/BaseToolWidget.ts +17 -1
- package/src/toolbar/widgets/BaseWidget.ts +179 -112
- package/src/toolbar/widgets/DocumentPropertiesWidget.scss +7 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +26 -10
- package/src/toolbar/widgets/EraserToolWidget.ts +21 -22
- package/src/toolbar/widgets/HandToolWidget.scss +14 -0
- package/src/toolbar/widgets/HandToolWidget.ts +21 -32
- package/src/toolbar/widgets/InsertImageWidget.scss +41 -0
- package/src/toolbar/widgets/InsertImageWidget.ts +90 -65
- package/src/toolbar/widgets/PenToolWidget.css +0 -51
- package/src/toolbar/widgets/PenToolWidget.ts +106 -146
- package/src/toolbar/widgets/SelectionToolWidget.scss +6 -0
- package/src/toolbar/widgets/SelectionToolWidget.ts +83 -85
- package/src/toolbar/widgets/TextToolWidget.ts +9 -5
- package/src/toolbar/widgets/components/components.scss +5 -0
- package/src/toolbar/widgets/components/makeColorInput.scss +82 -0
- package/src/toolbar/{makeColorInput.ts → widgets/components/makeColorInput.ts} +39 -14
- package/src/toolbar/widgets/components/makeFileInput.scss +77 -0
- package/src/toolbar/widgets/components/makeFileInput.ts +128 -0
- package/src/toolbar/widgets/components/makeGridSelector.scss +60 -0
- package/src/toolbar/widgets/components/makeGridSelector.ts +179 -0
- package/src/toolbar/widgets/components/makeSeparator.scss +14 -0
- package/src/toolbar/widgets/components/makeSeparator.ts +17 -0
- package/src/toolbar/widgets/components/makeThicknessSlider.scss +9 -0
- package/src/toolbar/widgets/components/makeThicknessSlider.ts +62 -0
- package/src/toolbar/widgets/keybindings.ts +1 -3
- package/src/toolbar/widgets/layout/DropdownLayoutManager.ts +262 -0
- package/src/toolbar/widgets/layout/EdgeToolbarLayoutManager.ts +71 -0
- package/src/toolbar/widgets/layout/types.ts +74 -0
- package/src/toolbar/widgets/lib.ts +2 -2
- package/src/tools/BaseTool.ts +102 -30
- package/src/tools/Eraser.test.ts +2 -2
- package/src/tools/Eraser.ts +24 -11
- package/src/tools/FindTool.css +3 -3
- package/src/tools/FindTool.test.ts +67 -0
- package/src/tools/FindTool.ts +3 -3
- package/src/tools/InputFilter/FunctionMapper.ts +17 -0
- package/src/tools/InputFilter/InputMapper.ts +41 -0
- package/src/tools/InputFilter/InputPipeline.test.ts +41 -0
- package/src/tools/InputFilter/InputPipeline.ts +34 -0
- package/src/tools/InputFilter/InputStabilizer.ts +254 -0
- package/src/tools/InputFilter/StrokeKeyboardControl.ts +104 -0
- package/src/tools/PanZoom.test.ts +3 -13
- package/src/tools/PanZoom.ts +33 -10
- package/src/tools/PasteHandler.ts +2 -3
- package/src/tools/Pen.test.ts +2 -4
- package/src/tools/Pen.ts +54 -70
- package/src/tools/PipetteTool.ts +31 -2
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +1 -1
- package/src/tools/SelectionTool/Selection.ts +52 -16
- package/src/tools/SelectionTool/SelectionHandle.ts +46 -12
- package/src/tools/SelectionTool/SelectionTool.css +23 -11
- package/src/tools/SelectionTool/SelectionTool.test.ts +130 -21
- package/src/tools/SelectionTool/SelectionTool.ts +62 -48
- package/src/tools/SelectionTool/TransformMode.ts +1 -3
- package/src/tools/SoundUITool.ts +13 -4
- package/src/tools/TextTool.ts +29 -30
- package/src/tools/ToolController.ts +60 -36
- package/src/tools/ToolSwitcherShortcut.ts +1 -1
- package/src/tools/ToolbarShortcutHandler.ts +1 -1
- package/src/tools/UndoRedoShortcut.test.ts +10 -4
- package/src/tools/UndoRedoShortcut.ts +1 -1
- package/src/tools/keybindings.ts +17 -17
- package/src/tools/localization.ts +4 -2
- package/src/tools/tools.scss +4 -0
- package/src/types.ts +25 -113
- package/src/util/ReactiveValue.test.ts +168 -0
- package/src/util/ReactiveValue.ts +241 -0
- package/src/util/guessKeyCodeFromKey.ts +36 -0
- package/src/util/listPrefixMatch.ts +19 -0
- package/src/util/stopPropagationOfScrollingWheelEvents.ts +20 -0
- package/src/version.test.ts +12 -0
- package/src/version.ts +3 -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/math/Mat33.d.ts +0 -123
- package/dist/cjs/math/Mat33.js +0 -340
- package/dist/cjs/math/Vec2.d.ts +0 -33
- package/dist/cjs/math/Vec2.js +0 -37
- package/dist/cjs/math/Vec3.d.ts +0 -106
- package/dist/cjs/math/Vec3.js +0 -183
- 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/rounding.d.ts +0 -4
- package/dist/cjs/math/rounding.js +0 -140
- 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/Path.d.ts +0 -93
- package/dist/cjs/math/shapes/Path.js +0 -865
- 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/Rect2.d.ts +0 -57
- package/dist/cjs/math/shapes/Rect2.js +0 -311
- package/dist/cjs/math/shapes/Triangle.d.ts +0 -46
- package/dist/cjs/math/shapes/Triangle.js +0 -148
- 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/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/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/toolbar/HTMLToolbar.d.ts +0 -105
- package/dist/mjs/toolbar/HTMLToolbar.mjs +0 -462
- package/dist/mjs/toolbar/makeColorInput.d.ts +0 -6
- package/src/Color4.test.ts +0 -47
- package/src/Color4.ts +0 -304
- package/src/Editor.css +0 -98
- 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/toolbar/HTMLToolbar.ts +0 -567
- package/src/toolbar/widgets/InsertImageWidget.css +0 -44
- package/src/tools/tools.css +0 -4
- /package/dist/cjs/{Color4.test.d.ts → Editor.test.d.ts} +0 -0
- /package/dist/cjs/{math/Mat33.test.d.ts → toolbar/EdgeToolbar.test.d.ts} +0 -0
- /package/dist/cjs/{math/Vec2.test.d.ts → tools/FindTool.test.d.ts} +0 -0
- /package/dist/cjs/{math/Vec3.test.d.ts → tools/InputFilter/InputPipeline.test.d.ts} +0 -0
- /package/dist/cjs/{math/polynomial/solveQuadratic.test.d.ts → util/ReactiveValue.test.d.ts} +0 -0
- /package/dist/cjs/{math/rounding.test.d.ts → version.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/LineSegment2.test.d.ts → mjs/Editor.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/Path.fromString.test.d.ts → mjs/toolbar/EdgeToolbar.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/Path.test.d.ts → mjs/toolbar/widgets/layout/types.mjs} +0 -0
- /package/dist/{cjs/math/shapes/Path.toString.test.d.ts → mjs/tools/FindTool.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/QuadraticBezier.test.d.ts → mjs/tools/InputFilter/InputPipeline.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/Rect2.test.d.ts → mjs/util/ReactiveValue.test.d.ts} +0 -0
- /package/dist/{cjs/math/shapes/Triangle.test.d.ts → mjs/version.test.d.ts} +0 -0
package/dist/mjs/math/Mat33.mjs
DELETED
@@ -1,338 +0,0 @@
|
|
1
|
-
import { Vec2 } from './Vec2.mjs';
|
2
|
-
import Vec3 from './Vec3.mjs';
|
3
|
-
/**
|
4
|
-
* Represents a three dimensional linear transformation or
|
5
|
-
* a two-dimensional affine transformation. (An affine transformation scales/rotates/shears
|
6
|
-
* **and** translates while a linear transformation just scales/rotates/shears).
|
7
|
-
*/
|
8
|
-
var Mat33 = /** @class */ (function () {
|
9
|
-
/**
|
10
|
-
* Creates a matrix from inputs in the form,
|
11
|
-
* ```
|
12
|
-
* ⎡ a1 a2 a3 ⎤
|
13
|
-
* ⎢ b1 b2 b3 ⎥
|
14
|
-
* ⎣ c1 c2 c3 ⎦
|
15
|
-
* ```
|
16
|
-
*/
|
17
|
-
function Mat33(a1, a2, a3, b1, b2, b3, c1, c2, c3) {
|
18
|
-
this.a1 = a1;
|
19
|
-
this.a2 = a2;
|
20
|
-
this.a3 = a3;
|
21
|
-
this.b1 = b1;
|
22
|
-
this.b2 = b2;
|
23
|
-
this.b3 = b3;
|
24
|
-
this.c1 = c1;
|
25
|
-
this.c2 = c2;
|
26
|
-
this.c3 = c3;
|
27
|
-
this.cachedInverse = undefined;
|
28
|
-
this.rows = [
|
29
|
-
Vec3.of(a1, a2, a3),
|
30
|
-
Vec3.of(b1, b2, b3),
|
31
|
-
Vec3.of(c1, c2, c3),
|
32
|
-
];
|
33
|
-
}
|
34
|
-
/**
|
35
|
-
* Creates a matrix from the given rows:
|
36
|
-
* ```
|
37
|
-
* ⎡ r1.x r1.y r1.z ⎤
|
38
|
-
* ⎢ r2.x r2.y r2.z ⎥
|
39
|
-
* ⎣ r3.x r3.y r3.z ⎦
|
40
|
-
* ```
|
41
|
-
*/
|
42
|
-
Mat33.ofRows = function (r1, r2, r3) {
|
43
|
-
return new Mat33(r1.x, r1.y, r1.z, r2.x, r2.y, r2.z, r3.x, r3.y, r3.z);
|
44
|
-
};
|
45
|
-
/**
|
46
|
-
* Either returns the inverse of this, or, if this matrix is singular/uninvertable,
|
47
|
-
* returns Mat33.identity.
|
48
|
-
*
|
49
|
-
* This may cache the computed inverse and return the cached version instead of recomputing
|
50
|
-
* it.
|
51
|
-
*/
|
52
|
-
Mat33.prototype.inverse = function () {
|
53
|
-
var _a;
|
54
|
-
return (_a = this.computeInverse()) !== null && _a !== void 0 ? _a : Mat33.identity;
|
55
|
-
};
|
56
|
-
Mat33.prototype.invertable = function () {
|
57
|
-
return this.computeInverse() !== null;
|
58
|
-
};
|
59
|
-
Mat33.prototype.computeInverse = function () {
|
60
|
-
if (this.cachedInverse !== undefined) {
|
61
|
-
return this.cachedInverse;
|
62
|
-
}
|
63
|
-
var toIdentity = [
|
64
|
-
this.rows[0],
|
65
|
-
this.rows[1],
|
66
|
-
this.rows[2],
|
67
|
-
];
|
68
|
-
var toResult = [
|
69
|
-
Vec3.unitX,
|
70
|
-
Vec3.unitY,
|
71
|
-
Vec3.unitZ,
|
72
|
-
];
|
73
|
-
// Convert toIdentity to the identity matrix and
|
74
|
-
// toResult to the inverse through elementary row operations
|
75
|
-
for (var cursor = 0; cursor < 3; cursor++) {
|
76
|
-
// Select the [cursor]th diagonal entry
|
77
|
-
var pivot = toIdentity[cursor].at(cursor);
|
78
|
-
// Don't divide by zero (treat very small numbers as zero).
|
79
|
-
var minDivideBy = 1e-10;
|
80
|
-
if (Math.abs(pivot) < minDivideBy) {
|
81
|
-
var swapIndex = -1;
|
82
|
-
// For all other rows,
|
83
|
-
for (var i = 1; i <= 2; i++) {
|
84
|
-
var otherRowIdx = (cursor + i) % 3;
|
85
|
-
if (Math.abs(toIdentity[otherRowIdx].at(cursor)) >= minDivideBy) {
|
86
|
-
swapIndex = otherRowIdx;
|
87
|
-
break;
|
88
|
-
}
|
89
|
-
}
|
90
|
-
// Can't swap with another row?
|
91
|
-
if (swapIndex === -1) {
|
92
|
-
this.cachedInverse = null;
|
93
|
-
return null;
|
94
|
-
}
|
95
|
-
var tmpIdentityRow = toIdentity[cursor];
|
96
|
-
var tmpResultRow = toResult[cursor];
|
97
|
-
// Swap!
|
98
|
-
toIdentity[cursor] = toIdentity[swapIndex];
|
99
|
-
toResult[cursor] = toResult[swapIndex];
|
100
|
-
toIdentity[swapIndex] = tmpIdentityRow;
|
101
|
-
toResult[swapIndex] = tmpResultRow;
|
102
|
-
pivot = toIdentity[cursor].at(cursor);
|
103
|
-
}
|
104
|
-
// Make toIdentity[k = cursor] = 1
|
105
|
-
var scale = 1.0 / pivot;
|
106
|
-
toIdentity[cursor] = toIdentity[cursor].times(scale);
|
107
|
-
toResult[cursor] = toResult[cursor].times(scale);
|
108
|
-
var cursorToIdentityRow = toIdentity[cursor];
|
109
|
-
var cursorToResultRow = toResult[cursor];
|
110
|
-
// Make toIdentity[k ≠ cursor] = 0
|
111
|
-
for (var i = 1; i <= 2; i++) {
|
112
|
-
var otherRowIdx = (cursor + i) % 3;
|
113
|
-
scale = -toIdentity[otherRowIdx].at(cursor);
|
114
|
-
toIdentity[otherRowIdx] = toIdentity[otherRowIdx].plus(cursorToIdentityRow.times(scale));
|
115
|
-
toResult[otherRowIdx] = toResult[otherRowIdx].plus(cursorToResultRow.times(scale));
|
116
|
-
}
|
117
|
-
}
|
118
|
-
var inverse = Mat33.ofRows(toResult[0], toResult[1], toResult[2]);
|
119
|
-
this.cachedInverse = inverse;
|
120
|
-
return inverse;
|
121
|
-
};
|
122
|
-
Mat33.prototype.transposed = function () {
|
123
|
-
return new Mat33(this.a1, this.b1, this.c1, this.a2, this.b2, this.c2, this.a3, this.b3, this.c3);
|
124
|
-
};
|
125
|
-
Mat33.prototype.rightMul = function (other) {
|
126
|
-
var _this = this;
|
127
|
-
other = other.transposed();
|
128
|
-
var at = function (row, col) {
|
129
|
-
return _this.rows[row].dot(other.rows[col]);
|
130
|
-
};
|
131
|
-
return new Mat33(at(0, 0), at(0, 1), at(0, 2), at(1, 0), at(1, 1), at(1, 2), at(2, 0), at(2, 1), at(2, 2));
|
132
|
-
};
|
133
|
-
/**
|
134
|
-
* Applies this as an **affine** transformation to the given vector.
|
135
|
-
* Returns a transformed version of `other`.
|
136
|
-
*
|
137
|
-
* Unlike {@link transformVec3}, this **does** translate the given vector.
|
138
|
-
*/
|
139
|
-
Mat33.prototype.transformVec2 = function (other) {
|
140
|
-
// When transforming a Vec2, we want to use the z transformation
|
141
|
-
// components of this for translation:
|
142
|
-
// ⎡ . . tX ⎤
|
143
|
-
// ⎢ . . tY ⎥
|
144
|
-
// ⎣ 0 0 1 ⎦
|
145
|
-
// For this, we need other's z component to be 1 (so that tX and tY
|
146
|
-
// are scaled by 1):
|
147
|
-
var intermediate = Vec3.of(other.x, other.y, 1);
|
148
|
-
intermediate = this.transformVec3(intermediate);
|
149
|
-
// Drop the z=1 to allow magnitude to work as expected
|
150
|
-
return Vec2.of(intermediate.x, intermediate.y);
|
151
|
-
};
|
152
|
-
/**
|
153
|
-
* Applies this as a linear transformation to the given vector (doesn't translate).
|
154
|
-
* This is the standard way of transforming vectors in ℝ³.
|
155
|
-
*/
|
156
|
-
Mat33.prototype.transformVec3 = function (other) {
|
157
|
-
return Vec3.of(this.rows[0].dot(other), this.rows[1].dot(other), this.rows[2].dot(other));
|
158
|
-
};
|
159
|
-
/** @returns true iff this is the identity matrix. */
|
160
|
-
Mat33.prototype.isIdentity = function () {
|
161
|
-
if (this === Mat33.identity) {
|
162
|
-
return true;
|
163
|
-
}
|
164
|
-
return this.eq(Mat33.identity);
|
165
|
-
};
|
166
|
-
/** Returns true iff this = other ± fuzz */
|
167
|
-
Mat33.prototype.eq = function (other, fuzz) {
|
168
|
-
if (fuzz === void 0) { fuzz = 0; }
|
169
|
-
for (var i = 0; i < 3; i++) {
|
170
|
-
if (!this.rows[i].eq(other.rows[i], fuzz)) {
|
171
|
-
return false;
|
172
|
-
}
|
173
|
-
}
|
174
|
-
return true;
|
175
|
-
};
|
176
|
-
Mat33.prototype.toString = function () {
|
177
|
-
var result = '';
|
178
|
-
var maxColumnLens = [0, 0, 0];
|
179
|
-
// Determine the longest item in each column so we can pad the others to that
|
180
|
-
// length.
|
181
|
-
for (var _i = 0, _a = this.rows; _i < _a.length; _i++) {
|
182
|
-
var row = _a[_i];
|
183
|
-
for (var i = 0; i < 3; i++) {
|
184
|
-
maxColumnLens[i] = Math.max(maxColumnLens[0], "".concat(row.at(i)).length);
|
185
|
-
}
|
186
|
-
}
|
187
|
-
for (var i = 0; i < 3; i++) {
|
188
|
-
if (i === 0) {
|
189
|
-
result += '⎡ ';
|
190
|
-
}
|
191
|
-
else if (i === 1) {
|
192
|
-
result += '⎢ ';
|
193
|
-
}
|
194
|
-
else {
|
195
|
-
result += '⎣ ';
|
196
|
-
}
|
197
|
-
// Add each component of the ith row (after padding it)
|
198
|
-
for (var j = 0; j < 3; j++) {
|
199
|
-
var val = this.rows[i].at(j).toString();
|
200
|
-
var padding = '';
|
201
|
-
for (var i_1 = val.length; i_1 < maxColumnLens[j]; i_1++) {
|
202
|
-
padding += ' ';
|
203
|
-
}
|
204
|
-
result += val + ', ' + padding;
|
205
|
-
}
|
206
|
-
if (i === 0) {
|
207
|
-
result += ' ⎤';
|
208
|
-
}
|
209
|
-
else if (i === 1) {
|
210
|
-
result += ' ⎥';
|
211
|
-
}
|
212
|
-
else {
|
213
|
-
result += ' ⎦';
|
214
|
-
}
|
215
|
-
result += '\n';
|
216
|
-
}
|
217
|
-
return result.trimEnd();
|
218
|
-
};
|
219
|
-
/**
|
220
|
-
* ```
|
221
|
-
* result[0] = top left element
|
222
|
-
* result[1] = element at row zero, column 1
|
223
|
-
* ...
|
224
|
-
* ```
|
225
|
-
*/
|
226
|
-
Mat33.prototype.toArray = function () {
|
227
|
-
return [
|
228
|
-
this.a1, this.a2, this.a3,
|
229
|
-
this.b1, this.b2, this.b3,
|
230
|
-
this.c1, this.c2, this.c3,
|
231
|
-
];
|
232
|
-
};
|
233
|
-
/**
|
234
|
-
* Returns a new `Mat33` where each entry is the output of the function
|
235
|
-
* `mapping`.
|
236
|
-
*
|
237
|
-
* @example
|
238
|
-
* ```
|
239
|
-
* new Mat33(
|
240
|
-
* 1, 2, 3,
|
241
|
-
* 4, 5, 6,
|
242
|
-
* 7, 8, 9,
|
243
|
-
* ).mapEntries(component => component - 1);
|
244
|
-
* // → ⎡ 0, 1, 2 ⎤
|
245
|
-
* // ⎢ 3, 4, 5 ⎥
|
246
|
-
* // ⎣ 6, 7, 8 ⎦
|
247
|
-
* ```
|
248
|
-
*/
|
249
|
-
Mat33.prototype.mapEntries = function (mapping) {
|
250
|
-
return new Mat33(mapping(this.a1, [0, 0]), mapping(this.a2, [0, 1]), mapping(this.a3, [0, 2]), mapping(this.b1, [1, 0]), mapping(this.b2, [1, 1]), mapping(this.b3, [1, 2]), mapping(this.c1, [2, 0]), mapping(this.c2, [2, 1]), mapping(this.c3, [2, 2]));
|
251
|
-
};
|
252
|
-
/** Estimate the scale factor of this matrix (based on the first row). */
|
253
|
-
Mat33.prototype.getScaleFactor = function () {
|
254
|
-
return Math.hypot(this.a1, this.a2);
|
255
|
-
};
|
256
|
-
/** Constructs a 3x3 translation matrix (for translating `Vec2`s) */
|
257
|
-
Mat33.translation = function (amount) {
|
258
|
-
// When transforming Vec2s by a 3x3 matrix, we give the input
|
259
|
-
// Vec2s z = 1. As such,
|
260
|
-
// outVec2.x = inVec2.x * 1 + inVec2.y * 0 + 1 * amount.x
|
261
|
-
// ...
|
262
|
-
return new Mat33(1, 0, amount.x, 0, 1, amount.y, 0, 0, 1);
|
263
|
-
};
|
264
|
-
Mat33.zRotation = function (radians, center) {
|
265
|
-
if (center === void 0) { center = Vec2.zero; }
|
266
|
-
if (radians === 0) {
|
267
|
-
return Mat33.identity;
|
268
|
-
}
|
269
|
-
var cos = Math.cos(radians);
|
270
|
-
var sin = Math.sin(radians);
|
271
|
-
// Translate everything so that rotation is about the origin
|
272
|
-
var result = Mat33.translation(center);
|
273
|
-
result = result.rightMul(new Mat33(cos, -sin, 0, sin, cos, 0, 0, 0, 1));
|
274
|
-
return result.rightMul(Mat33.translation(center.times(-1)));
|
275
|
-
};
|
276
|
-
Mat33.scaling2D = function (amount, center) {
|
277
|
-
if (center === void 0) { center = Vec2.zero; }
|
278
|
-
var result = Mat33.translation(center);
|
279
|
-
var xAmount, yAmount;
|
280
|
-
if (typeof amount === 'number') {
|
281
|
-
xAmount = amount;
|
282
|
-
yAmount = amount;
|
283
|
-
}
|
284
|
-
else {
|
285
|
-
xAmount = amount.x;
|
286
|
-
yAmount = amount.y;
|
287
|
-
}
|
288
|
-
result = result.rightMul(new Mat33(xAmount, 0, 0, 0, yAmount, 0, 0, 0, 1));
|
289
|
-
// Translate such that [center] goes to (0, 0)
|
290
|
-
return result.rightMul(Mat33.translation(center.times(-1)));
|
291
|
-
};
|
292
|
-
/** @see {@link fromCSSMatrix} */
|
293
|
-
Mat33.prototype.toCSSMatrix = function () {
|
294
|
-
return "matrix(".concat(this.a1, ",").concat(this.b1, ",").concat(this.a2, ",").concat(this.b2, ",").concat(this.a3, ",").concat(this.b3, ")");
|
295
|
-
};
|
296
|
-
/**
|
297
|
-
* Converts a CSS-form `matrix(a, b, c, d, e, f)` to a Mat33.
|
298
|
-
*
|
299
|
-
* Note that such a matrix has the form,
|
300
|
-
* ```
|
301
|
-
* ⎡ a c e ⎤
|
302
|
-
* ⎢ b d f ⎥
|
303
|
-
* ⎣ 0 0 1 ⎦
|
304
|
-
* ```
|
305
|
-
*/
|
306
|
-
Mat33.fromCSSMatrix = function (cssString) {
|
307
|
-
if (cssString === '' || cssString === 'none') {
|
308
|
-
return Mat33.identity;
|
309
|
-
}
|
310
|
-
var numberExp = '([-]?\\d*(?:\\.\\d*)?(?:[eE][-]?\\d+)?)';
|
311
|
-
var numberSepExp = '[, \\t\\n]';
|
312
|
-
var regExpSource = "^\\s*matrix\\s*\\(".concat([
|
313
|
-
// According to MDN, matrix(a,b,c,d,e,f) has form:
|
314
|
-
// ⎡ a c e ⎤
|
315
|
-
// ⎢ b d f ⎥
|
316
|
-
// ⎣ 0 0 1 ⎦
|
317
|
-
numberExp, numberExp, numberExp,
|
318
|
-
numberExp, numberExp, numberExp, // b, d, f
|
319
|
-
].join("".concat(numberSepExp, "+"))).concat(numberSepExp, "*\\)\\s*$");
|
320
|
-
var matrixExp = new RegExp(regExpSource, 'i');
|
321
|
-
var match = matrixExp.exec(cssString);
|
322
|
-
if (!match) {
|
323
|
-
throw new Error("Unsupported transformation: ".concat(cssString));
|
324
|
-
}
|
325
|
-
var matrixData = match.slice(1).map(function (entry) { return parseFloat(entry); });
|
326
|
-
var a = matrixData[0];
|
327
|
-
var b = matrixData[1];
|
328
|
-
var c = matrixData[2];
|
329
|
-
var d = matrixData[3];
|
330
|
-
var e = matrixData[4];
|
331
|
-
var f = matrixData[5];
|
332
|
-
var transform = new Mat33(a, c, e, b, d, f, 0, 0, 1);
|
333
|
-
return transform;
|
334
|
-
};
|
335
|
-
Mat33.identity = new Mat33(1, 0, 0, 0, 1, 0, 0, 0, 1);
|
336
|
-
return Mat33;
|
337
|
-
}());
|
338
|
-
export default Mat33;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/mjs/math/Vec2.d.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
import Vec3 from './Vec3';
|
2
|
-
export declare namespace Vec2 {
|
3
|
-
/**
|
4
|
-
* Creates a `Vec2` from an x and y coordinate.
|
5
|
-
*
|
6
|
-
* For example,
|
7
|
-
* ```ts
|
8
|
-
* const v = Vec2.of(3, 4); // x=3, y=4.
|
9
|
-
* ```
|
10
|
-
*/
|
11
|
-
const of: (x: number, y: number) => Vec2;
|
12
|
-
/**
|
13
|
-
* Creates a `Vec2` from an object containing x and y coordinates.
|
14
|
-
*
|
15
|
-
* For example,
|
16
|
-
* ```ts
|
17
|
-
* const v1 = Vec2.ofXY({ x: 3, y: 4.5 });
|
18
|
-
* const v2 = Vec2.ofXY({ x: -123.4, y: 1 });
|
19
|
-
* ```
|
20
|
-
*/
|
21
|
-
const ofXY: ({ x, y }: {
|
22
|
-
x: number;
|
23
|
-
y: number;
|
24
|
-
}) => Vec2;
|
25
|
-
/** A vector of length 1 in the X direction (→). */
|
26
|
-
const unitX: Vec3;
|
27
|
-
/** A vector of length 1 in the Y direction (↑). */
|
28
|
-
const unitY: Vec3;
|
29
|
-
/** The zero vector: A vector with x=0, y=0. */
|
30
|
-
const zero: Vec3;
|
31
|
-
}
|
32
|
-
export type Point2 = Vec3;
|
33
|
-
export type Vec2 = Vec3;
|
package/dist/mjs/math/Vec2.mjs
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import Vec3 from './Vec3.mjs';
|
2
|
-
export var Vec2;
|
3
|
-
(function (Vec2) {
|
4
|
-
/**
|
5
|
-
* Creates a `Vec2` from an x and y coordinate.
|
6
|
-
*
|
7
|
-
* For example,
|
8
|
-
* ```ts
|
9
|
-
* const v = Vec2.of(3, 4); // x=3, y=4.
|
10
|
-
* ```
|
11
|
-
*/
|
12
|
-
Vec2.of = function (x, y) {
|
13
|
-
return Vec3.of(x, y, 0);
|
14
|
-
};
|
15
|
-
/**
|
16
|
-
* Creates a `Vec2` from an object containing x and y coordinates.
|
17
|
-
*
|
18
|
-
* For example,
|
19
|
-
* ```ts
|
20
|
-
* const v1 = Vec2.ofXY({ x: 3, y: 4.5 });
|
21
|
-
* const v2 = Vec2.ofXY({ x: -123.4, y: 1 });
|
22
|
-
* ```
|
23
|
-
*/
|
24
|
-
Vec2.ofXY = function (_a) {
|
25
|
-
var x = _a.x, y = _a.y;
|
26
|
-
return Vec3.of(x, y, 0);
|
27
|
-
};
|
28
|
-
/** A vector of length 1 in the X direction (→). */
|
29
|
-
Vec2.unitX = Vec2.of(1, 0);
|
30
|
-
/** A vector of length 1 in the Y direction (↑). */
|
31
|
-
Vec2.unitY = Vec2.of(0, 1);
|
32
|
-
/** The zero vector: A vector with x=0, y=0. */
|
33
|
-
Vec2.zero = Vec2.of(0, 0);
|
34
|
-
})(Vec2 || (Vec2 = {}));
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/mjs/math/Vec3.d.ts
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* A vector with three components. Can also be used to represent a two-component vector.
|
3
|
-
*
|
4
|
-
* A `Vec3` is immutable.
|
5
|
-
*/
|
6
|
-
export default class Vec3 {
|
7
|
-
readonly x: number;
|
8
|
-
readonly y: number;
|
9
|
-
readonly z: number;
|
10
|
-
private constructor();
|
11
|
-
/** Returns the x, y components of this. */
|
12
|
-
get xy(): {
|
13
|
-
x: number;
|
14
|
-
y: number;
|
15
|
-
};
|
16
|
-
static of(x: number, y: number, z: number): Vec3;
|
17
|
-
/** Returns this' `idx`th component. For example, `Vec3.of(1, 2, 3).at(1) → 2`. */
|
18
|
-
at(idx: number): number;
|
19
|
-
/** Alias for this.magnitude. */
|
20
|
-
length(): number;
|
21
|
-
magnitude(): number;
|
22
|
-
magnitudeSquared(): number;
|
23
|
-
/**
|
24
|
-
* Return this' angle in the XY plane (treats this as a Vec2).
|
25
|
-
*
|
26
|
-
* This is equivalent to `Math.atan2(vec.y, vec.x)`.
|
27
|
-
*/
|
28
|
-
angle(): number;
|
29
|
-
/**
|
30
|
-
* Returns a unit vector in the same direction as this.
|
31
|
-
*
|
32
|
-
* If `this` has zero length, the resultant vector has `NaN` components.
|
33
|
-
*/
|
34
|
-
normalized(): Vec3;
|
35
|
-
/** @returns A copy of `this` multiplied by a scalar. */
|
36
|
-
times(c: number): Vec3;
|
37
|
-
plus(v: Vec3): Vec3;
|
38
|
-
minus(v: Vec3): Vec3;
|
39
|
-
dot(other: Vec3): number;
|
40
|
-
cross(other: Vec3): Vec3;
|
41
|
-
/**
|
42
|
-
* If `other` is a `Vec3`, multiplies `this` component-wise by `other`. Otherwise,
|
43
|
-
* if `other is a `number`, returns the result of scalar multiplication.
|
44
|
-
*
|
45
|
-
* @example
|
46
|
-
* ```
|
47
|
-
* Vec3.of(1, 2, 3).scale(Vec3.of(2, 4, 6)); // → Vec3(2, 8, 18)
|
48
|
-
* ```
|
49
|
-
*/
|
50
|
-
scale(other: Vec3 | number): Vec3;
|
51
|
-
/**
|
52
|
-
* Returns a vector orthogonal to this. If this is a Vec2, returns `this` rotated
|
53
|
-
* 90 degrees counter-clockwise.
|
54
|
-
*/
|
55
|
-
orthog(): Vec3;
|
56
|
-
/** Returns this plus a vector of length `distance` in `direction`. */
|
57
|
-
extend(distance: number, direction: Vec3): Vec3;
|
58
|
-
/** Returns a vector `fractionTo` of the way to target from this. */
|
59
|
-
lerp(target: Vec3, fractionTo: number): Vec3;
|
60
|
-
/**
|
61
|
-
* `zip` Maps a component of this and a corresponding component of
|
62
|
-
* `other` to a component of the output vector.
|
63
|
-
*
|
64
|
-
* @example
|
65
|
-
* ```
|
66
|
-
* const a = Vec3.of(1, 2, 3);
|
67
|
-
* const b = Vec3.of(0.5, 2.1, 2.9);
|
68
|
-
*
|
69
|
-
* const zipped = a.zip(b, (aComponent, bComponent) => {
|
70
|
-
* return Math.min(aComponent, bComponent);
|
71
|
-
* });
|
72
|
-
*
|
73
|
-
* console.log(zipped.toString()); // → Vec(0.5, 2, 2.9)
|
74
|
-
* ```
|
75
|
-
*/
|
76
|
-
zip(other: Vec3, zip: (componentInThis: number, componentInOther: number) => number): Vec3;
|
77
|
-
/**
|
78
|
-
* Returns a vector with each component acted on by `fn`.
|
79
|
-
*
|
80
|
-
* @example
|
81
|
-
* ```
|
82
|
-
* console.log(Vec3.of(1, 2, 3).map(val => val + 1)); // → Vec(2, 3, 4)
|
83
|
-
* ```
|
84
|
-
*/
|
85
|
-
map(fn: (component: number, index: number) => number): Vec3;
|
86
|
-
asArray(): [number, number, number];
|
87
|
-
/**
|
88
|
-
* [fuzz] The maximum difference between two components for this and [other]
|
89
|
-
* to be considered equal.
|
90
|
-
*
|
91
|
-
* @example
|
92
|
-
* ```
|
93
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 100); // → true
|
94
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 0.1); // → false
|
95
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 3); // → true
|
96
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 3.01); // → true
|
97
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 2.99); // → false
|
98
|
-
* ```
|
99
|
-
*/
|
100
|
-
eq(other: Vec3, fuzz?: number): boolean;
|
101
|
-
toString(): string;
|
102
|
-
static unitX: Vec3;
|
103
|
-
static unitY: Vec3;
|
104
|
-
static unitZ: Vec3;
|
105
|
-
static zero: Vec3;
|
106
|
-
}
|
package/dist/mjs/math/Vec3.mjs
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* A vector with three components. Can also be used to represent a two-component vector.
|
3
|
-
*
|
4
|
-
* A `Vec3` is immutable.
|
5
|
-
*/
|
6
|
-
var Vec3 = /** @class */ (function () {
|
7
|
-
function Vec3(x, y, z) {
|
8
|
-
this.x = x;
|
9
|
-
this.y = y;
|
10
|
-
this.z = z;
|
11
|
-
}
|
12
|
-
Object.defineProperty(Vec3.prototype, "xy", {
|
13
|
-
/** Returns the x, y components of this. */
|
14
|
-
get: function () {
|
15
|
-
// Useful for APIs that behave differently if .z is present.
|
16
|
-
return {
|
17
|
-
x: this.x,
|
18
|
-
y: this.y,
|
19
|
-
};
|
20
|
-
},
|
21
|
-
enumerable: false,
|
22
|
-
configurable: true
|
23
|
-
});
|
24
|
-
Vec3.of = function (x, y, z) {
|
25
|
-
return new Vec3(x, y, z);
|
26
|
-
};
|
27
|
-
/** Returns this' `idx`th component. For example, `Vec3.of(1, 2, 3).at(1) → 2`. */
|
28
|
-
Vec3.prototype.at = function (idx) {
|
29
|
-
if (idx === 0)
|
30
|
-
return this.x;
|
31
|
-
if (idx === 1)
|
32
|
-
return this.y;
|
33
|
-
if (idx === 2)
|
34
|
-
return this.z;
|
35
|
-
throw new Error("".concat(idx, " out of bounds!"));
|
36
|
-
};
|
37
|
-
/** Alias for this.magnitude. */
|
38
|
-
Vec3.prototype.length = function () {
|
39
|
-
return this.magnitude();
|
40
|
-
};
|
41
|
-
Vec3.prototype.magnitude = function () {
|
42
|
-
return Math.sqrt(this.dot(this));
|
43
|
-
};
|
44
|
-
Vec3.prototype.magnitudeSquared = function () {
|
45
|
-
return this.dot(this);
|
46
|
-
};
|
47
|
-
/**
|
48
|
-
* Return this' angle in the XY plane (treats this as a Vec2).
|
49
|
-
*
|
50
|
-
* This is equivalent to `Math.atan2(vec.y, vec.x)`.
|
51
|
-
*/
|
52
|
-
Vec3.prototype.angle = function () {
|
53
|
-
return Math.atan2(this.y, this.x);
|
54
|
-
};
|
55
|
-
/**
|
56
|
-
* Returns a unit vector in the same direction as this.
|
57
|
-
*
|
58
|
-
* If `this` has zero length, the resultant vector has `NaN` components.
|
59
|
-
*/
|
60
|
-
Vec3.prototype.normalized = function () {
|
61
|
-
var norm = this.magnitude();
|
62
|
-
return Vec3.of(this.x / norm, this.y / norm, this.z / norm);
|
63
|
-
};
|
64
|
-
/** @returns A copy of `this` multiplied by a scalar. */
|
65
|
-
Vec3.prototype.times = function (c) {
|
66
|
-
return Vec3.of(this.x * c, this.y * c, this.z * c);
|
67
|
-
};
|
68
|
-
Vec3.prototype.plus = function (v) {
|
69
|
-
return Vec3.of(this.x + v.x, this.y + v.y, this.z + v.z);
|
70
|
-
};
|
71
|
-
Vec3.prototype.minus = function (v) {
|
72
|
-
return Vec3.of(this.x - v.x, this.y - v.y, this.z - v.z);
|
73
|
-
};
|
74
|
-
Vec3.prototype.dot = function (other) {
|
75
|
-
return this.x * other.x + this.y * other.y + this.z * other.z;
|
76
|
-
};
|
77
|
-
Vec3.prototype.cross = function (other) {
|
78
|
-
// | i j k |
|
79
|
-
// | x1 y1 z1| = (i)(y1z2 - y2z1) - (j)(x1z2 - x2z1) + (k)(x1y2 - x2y1)
|
80
|
-
// | x2 y2 z2|
|
81
|
-
return Vec3.of(this.y * other.z - other.y * this.z, other.x * this.z - this.x * other.z, this.x * other.y - other.x * this.y);
|
82
|
-
};
|
83
|
-
/**
|
84
|
-
* If `other` is a `Vec3`, multiplies `this` component-wise by `other`. Otherwise,
|
85
|
-
* if `other is a `number`, returns the result of scalar multiplication.
|
86
|
-
*
|
87
|
-
* @example
|
88
|
-
* ```
|
89
|
-
* Vec3.of(1, 2, 3).scale(Vec3.of(2, 4, 6)); // → Vec3(2, 8, 18)
|
90
|
-
* ```
|
91
|
-
*/
|
92
|
-
Vec3.prototype.scale = function (other) {
|
93
|
-
if (typeof other === 'number') {
|
94
|
-
return this.times(other);
|
95
|
-
}
|
96
|
-
return Vec3.of(this.x * other.x, this.y * other.y, this.z * other.z);
|
97
|
-
};
|
98
|
-
/**
|
99
|
-
* Returns a vector orthogonal to this. If this is a Vec2, returns `this` rotated
|
100
|
-
* 90 degrees counter-clockwise.
|
101
|
-
*/
|
102
|
-
Vec3.prototype.orthog = function () {
|
103
|
-
// If parallel to the z-axis
|
104
|
-
if (this.dot(Vec3.unitX) === 0 && this.dot(Vec3.unitY) === 0) {
|
105
|
-
return this.dot(Vec3.unitX) === 0 ? Vec3.unitX : this.cross(Vec3.unitX).normalized();
|
106
|
-
}
|
107
|
-
return this.cross(Vec3.unitZ.times(-1)).normalized();
|
108
|
-
};
|
109
|
-
/** Returns this plus a vector of length `distance` in `direction`. */
|
110
|
-
Vec3.prototype.extend = function (distance, direction) {
|
111
|
-
return this.plus(direction.normalized().times(distance));
|
112
|
-
};
|
113
|
-
/** Returns a vector `fractionTo` of the way to target from this. */
|
114
|
-
Vec3.prototype.lerp = function (target, fractionTo) {
|
115
|
-
return this.times(1 - fractionTo).plus(target.times(fractionTo));
|
116
|
-
};
|
117
|
-
/**
|
118
|
-
* `zip` Maps a component of this and a corresponding component of
|
119
|
-
* `other` to a component of the output vector.
|
120
|
-
*
|
121
|
-
* @example
|
122
|
-
* ```
|
123
|
-
* const a = Vec3.of(1, 2, 3);
|
124
|
-
* const b = Vec3.of(0.5, 2.1, 2.9);
|
125
|
-
*
|
126
|
-
* const zipped = a.zip(b, (aComponent, bComponent) => {
|
127
|
-
* return Math.min(aComponent, bComponent);
|
128
|
-
* });
|
129
|
-
*
|
130
|
-
* console.log(zipped.toString()); // → Vec(0.5, 2, 2.9)
|
131
|
-
* ```
|
132
|
-
*/
|
133
|
-
Vec3.prototype.zip = function (other, zip) {
|
134
|
-
return Vec3.of(zip(other.x, this.x), zip(other.y, this.y), zip(other.z, this.z));
|
135
|
-
};
|
136
|
-
/**
|
137
|
-
* Returns a vector with each component acted on by `fn`.
|
138
|
-
*
|
139
|
-
* @example
|
140
|
-
* ```
|
141
|
-
* console.log(Vec3.of(1, 2, 3).map(val => val + 1)); // → Vec(2, 3, 4)
|
142
|
-
* ```
|
143
|
-
*/
|
144
|
-
Vec3.prototype.map = function (fn) {
|
145
|
-
return Vec3.of(fn(this.x, 0), fn(this.y, 1), fn(this.z, 2));
|
146
|
-
};
|
147
|
-
Vec3.prototype.asArray = function () {
|
148
|
-
return [this.x, this.y, this.z];
|
149
|
-
};
|
150
|
-
/**
|
151
|
-
* [fuzz] The maximum difference between two components for this and [other]
|
152
|
-
* to be considered equal.
|
153
|
-
*
|
154
|
-
* @example
|
155
|
-
* ```
|
156
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 100); // → true
|
157
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 0.1); // → false
|
158
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 3); // → true
|
159
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 3.01); // → true
|
160
|
-
* Vec3.of(1, 2, 3).eq(Vec3.of(4, 5, 6), 2.99); // → false
|
161
|
-
* ```
|
162
|
-
*/
|
163
|
-
Vec3.prototype.eq = function (other, fuzz) {
|
164
|
-
if (fuzz === void 0) { fuzz = 1e-10; }
|
165
|
-
for (var i = 0; i < 3; i++) {
|
166
|
-
if (Math.abs(other.at(i) - this.at(i)) > fuzz) {
|
167
|
-
return false;
|
168
|
-
}
|
169
|
-
}
|
170
|
-
return true;
|
171
|
-
};
|
172
|
-
Vec3.prototype.toString = function () {
|
173
|
-
return "Vec(".concat(this.x, ", ").concat(this.y, ", ").concat(this.z, ")");
|
174
|
-
};
|
175
|
-
Vec3.unitX = Vec3.of(1, 0, 0);
|
176
|
-
Vec3.unitY = Vec3.of(0, 1, 0);
|
177
|
-
Vec3.unitZ = Vec3.of(0, 0, 1);
|
178
|
-
Vec3.zero = Vec3.of(0, 0, 0);
|
179
|
-
return Vec3;
|
180
|
-
}());
|
181
|
-
export default Vec3;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|