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/src/Color4.ts
DELETED
@@ -1,304 +0,0 @@
|
|
1
|
-
import Vec3 from './math/Vec3';
|
2
|
-
|
3
|
-
export default class Color4 {
|
4
|
-
private constructor(
|
5
|
-
/** Red component. Should be in the range [0, 1]. */
|
6
|
-
public readonly r: number,
|
7
|
-
|
8
|
-
/** Green component. `g` ∈ [0, 1] */
|
9
|
-
public readonly g: number,
|
10
|
-
|
11
|
-
/** Blue component. `b` ∈ [0, 1] */
|
12
|
-
public readonly b: number,
|
13
|
-
|
14
|
-
/** Alpha/transparent component. `a` ∈ [0, 1]. 0 = transparent */
|
15
|
-
public readonly a: number
|
16
|
-
) {
|
17
|
-
}
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Create a color from red, green, blue components. The color is fully opaque (`a = 1.0`).
|
21
|
-
*
|
22
|
-
* Each component should be in the range [0, 1].
|
23
|
-
*/
|
24
|
-
public static ofRGB(red: number, green: number, blue: number): Color4 {
|
25
|
-
return Color4.ofRGBA(red, green, blue, 1.0);
|
26
|
-
}
|
27
|
-
|
28
|
-
public static ofRGBA(red: number, green: number, blue: number, alpha: number): Color4 {
|
29
|
-
red = Math.max(0, Math.min(red, 1));
|
30
|
-
green = Math.max(0, Math.min(green, 1));
|
31
|
-
blue = Math.max(0, Math.min(blue, 1));
|
32
|
-
alpha = Math.max(0, Math.min(alpha, 1));
|
33
|
-
|
34
|
-
return new Color4(red, green, blue, alpha);
|
35
|
-
}
|
36
|
-
|
37
|
-
public static fromHex(hexString: string): Color4 {
|
38
|
-
// Remove starting '#' (if present)
|
39
|
-
hexString = (hexString.match(/^[#]?(.*)$/) ?? [])[1];
|
40
|
-
hexString = hexString.toUpperCase();
|
41
|
-
|
42
|
-
if (!hexString.match(/^[0-9A-F]+$/)) {
|
43
|
-
throw new Error(`${hexString} is not in a valid format.`);
|
44
|
-
}
|
45
|
-
|
46
|
-
// RGBA or RGB
|
47
|
-
if (hexString.length === 3 || hexString.length === 4) {
|
48
|
-
// Each character is a component
|
49
|
-
const components = hexString.split('');
|
50
|
-
|
51
|
-
// Convert to RRGGBBAA or RRGGBB format
|
52
|
-
hexString = components.map(component => `${component}0`).join('');
|
53
|
-
}
|
54
|
-
|
55
|
-
if (hexString.length === 6) {
|
56
|
-
// Alpha component
|
57
|
-
hexString += 'FF';
|
58
|
-
}
|
59
|
-
|
60
|
-
const components: number[] = [];
|
61
|
-
for (let i = 2; i <= hexString.length; i += 2) {
|
62
|
-
const chunk = hexString.substring(i - 2, i);
|
63
|
-
components.push(parseInt(chunk, 16) / 255);
|
64
|
-
}
|
65
|
-
|
66
|
-
if (components.length !== 4) {
|
67
|
-
throw new Error(`Unable to parse ${hexString}: Wrong number of components.`);
|
68
|
-
}
|
69
|
-
|
70
|
-
return Color4.ofRGBA(components[0], components[1], components[2], components[3]);
|
71
|
-
}
|
72
|
-
|
73
|
-
/** Like fromHex, but can handle additional colors if an `HTMLCanvasElement` is available. */
|
74
|
-
public static fromString(text: string): Color4 {
|
75
|
-
if (text.startsWith('#')) {
|
76
|
-
return Color4.fromHex(text);
|
77
|
-
}
|
78
|
-
|
79
|
-
if (text === 'none' || text === 'transparent') {
|
80
|
-
return Color4.transparent;
|
81
|
-
}
|
82
|
-
|
83
|
-
// rgba?: Match both rgb and rgba strings.
|
84
|
-
// ([,0-9.]+): Match any string of only numeric, '.' and ',' characters.
|
85
|
-
const rgbRegex = /^rgba?\(([,0-9.]+)\)$/i;
|
86
|
-
const rgbMatch = text.replace(/\s*/g, '').match(rgbRegex);
|
87
|
-
|
88
|
-
if (rgbMatch) {
|
89
|
-
const componentsListStr = rgbMatch[1];
|
90
|
-
const componentsList = JSON.parse(`[ ${componentsListStr} ]`);
|
91
|
-
|
92
|
-
if (componentsList.length === 3) {
|
93
|
-
return Color4.ofRGB(
|
94
|
-
componentsList[0] / 255, componentsList[1] / 255, componentsList[2] / 255
|
95
|
-
);
|
96
|
-
} else if (componentsList.length === 4) {
|
97
|
-
return Color4.ofRGBA(
|
98
|
-
componentsList[0] / 255, componentsList[1] / 255, componentsList[2] / 255, componentsList[3]
|
99
|
-
);
|
100
|
-
} else {
|
101
|
-
throw new Error(`RGB string, ${text}, has wrong number of components: ${componentsList.length}`);
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
// Otherwise, try to use an HTMLCanvasElement to determine the color.
|
106
|
-
// Note: We may be unable to create an HTMLCanvasElement if running as a unit test.
|
107
|
-
const canvas = document.createElement('canvas');
|
108
|
-
canvas.width = 1;
|
109
|
-
canvas.height = 1;
|
110
|
-
|
111
|
-
const ctx = canvas.getContext('2d')!;
|
112
|
-
ctx.fillStyle = text;
|
113
|
-
ctx.fillRect(0, 0, 1, 1);
|
114
|
-
|
115
|
-
const data = ctx.getImageData(0, 0, 1, 1);
|
116
|
-
const red = data.data[0] / 255;
|
117
|
-
const green = data.data[1] / 255;
|
118
|
-
const blue = data.data[2] / 255;
|
119
|
-
const alpha = data.data[3] / 255;
|
120
|
-
|
121
|
-
return Color4.ofRGBA(red, green, blue, alpha);
|
122
|
-
}
|
123
|
-
|
124
|
-
/** @returns true if `this` and `other` are approximately equal. */
|
125
|
-
public eq(other: Color4|null|undefined): boolean {
|
126
|
-
if (other == null) {
|
127
|
-
return false;
|
128
|
-
}
|
129
|
-
|
130
|
-
// If both completely transparent,
|
131
|
-
if (this.a === 0 && other.a === 0) {
|
132
|
-
return true;
|
133
|
-
}
|
134
|
-
|
135
|
-
return this.toHexString() === other.toHexString();
|
136
|
-
}
|
137
|
-
|
138
|
-
/**
|
139
|
-
* If `fractionTo` is not in the range [0, 1], it will be clamped to the nearest number
|
140
|
-
* in that range. For example, `a.mix(b, -1)` is equivalent to `a.mix(b, 0)`.
|
141
|
-
*
|
142
|
-
* @returns a color `fractionTo` of the way from this color to `other`.
|
143
|
-
*
|
144
|
-
* @example
|
145
|
-
* ```ts
|
146
|
-
* Color4.ofRGB(1, 0, 0).mix(Color4.ofRGB(0, 1, 0), 0.1) // -> Color4(0.9, 0.1, 0)
|
147
|
-
* ```
|
148
|
-
*/
|
149
|
-
public mix(other: Color4, fractionTo: number): Color4 {
|
150
|
-
fractionTo = Math.min(Math.max(fractionTo, 0), 1);
|
151
|
-
const fractionOfThis = 1 - fractionTo;
|
152
|
-
return new Color4(
|
153
|
-
this.r * fractionOfThis + other.r * fractionTo,
|
154
|
-
this.g * fractionOfThis + other.g * fractionTo,
|
155
|
-
this.b * fractionOfThis + other.b * fractionTo,
|
156
|
-
this.a * fractionOfThis + other.a * fractionTo,
|
157
|
-
);
|
158
|
-
}
|
159
|
-
|
160
|
-
/**
|
161
|
-
* @returns the component-wise average of `colors`, or `Color4.transparent` if `colors` is empty.
|
162
|
-
*/
|
163
|
-
public static average(colors: Color4[]) {
|
164
|
-
let averageA = 0;
|
165
|
-
let averageR = 0;
|
166
|
-
let averageG = 0;
|
167
|
-
let averageB = 0;
|
168
|
-
|
169
|
-
for (const color of colors) {
|
170
|
-
averageA += color.a;
|
171
|
-
averageR += color.r;
|
172
|
-
averageG += color.g;
|
173
|
-
averageB += color.b;
|
174
|
-
}
|
175
|
-
|
176
|
-
if (colors.length > 0) {
|
177
|
-
averageA /= colors.length;
|
178
|
-
averageR /= colors.length;
|
179
|
-
averageG /= colors.length;
|
180
|
-
averageB /= colors.length;
|
181
|
-
}
|
182
|
-
|
183
|
-
return new Color4(averageR, averageG, averageB, averageA);
|
184
|
-
}
|
185
|
-
|
186
|
-
/**
|
187
|
-
* Converts to (hue, saturation, value).
|
188
|
-
* See also https://en.wikipedia.org/wiki/HSL_and_HSV#General_approach
|
189
|
-
*
|
190
|
-
* The resultant hue is represented in radians and is thus in [0, 2pi].
|
191
|
-
*/
|
192
|
-
public asHSV(): Vec3 {
|
193
|
-
// Ref: https://en.wikipedia.org/wiki/HSL_and_HSV#General_approach
|
194
|
-
//
|
195
|
-
// HUE:
|
196
|
-
// First, consider the unit cube. Rotate it such that one vertex is at the origin
|
197
|
-
// of a plane and its three neighboring vertices are equidistant from that plane:
|
198
|
-
//
|
199
|
-
// /\
|
200
|
-
// / | \
|
201
|
-
// 2 / 3 \ 1
|
202
|
-
// \ | /
|
203
|
-
// \ | /
|
204
|
-
// . \/ .
|
205
|
-
//
|
206
|
-
// .
|
207
|
-
//
|
208
|
-
// Let z be up and (x, y, 0) be in the plane.
|
209
|
-
//
|
210
|
-
// Label vectors 1,2,3 with R, G, and B, respectively. Let R's projection into the plane
|
211
|
-
// lie along the x axis.
|
212
|
-
//
|
213
|
-
// Because R is a unit vector and R, G, B are equidistant from the plane, they must
|
214
|
-
// form 30-60-90 triangles, which have side lengths proportional to (1, √3, 2)
|
215
|
-
//
|
216
|
-
// /|
|
217
|
-
// 1/ | (√3)/2
|
218
|
-
// / |
|
219
|
-
// 1/2
|
220
|
-
//
|
221
|
-
const minComponent = Math.min(this.r, this.g, this.b);
|
222
|
-
const maxComponent = Math.max(this.r, this.g, this.b);
|
223
|
-
const chroma = maxComponent - minComponent;
|
224
|
-
|
225
|
-
let hue;
|
226
|
-
|
227
|
-
// See https://en.wikipedia.org/wiki/HSL_and_HSV#General_approach
|
228
|
-
if (chroma === 0) {
|
229
|
-
hue = 0;
|
230
|
-
} else if (this.r >= this.g && this.r >= this.b) {
|
231
|
-
hue = ((this.g - this.b) / chroma) % 6;
|
232
|
-
} else if (this.g >= this.r && this.g >= this.b) {
|
233
|
-
hue = (this.b - this.r) / chroma + 2;
|
234
|
-
} else {
|
235
|
-
hue = (this.r - this.g) / chroma + 4;
|
236
|
-
}
|
237
|
-
|
238
|
-
// Convert to degree representation, then to radians.
|
239
|
-
hue *= 60;
|
240
|
-
hue *= Math.PI / 180;
|
241
|
-
|
242
|
-
// Ensure positivity.
|
243
|
-
if (hue < 0) {
|
244
|
-
hue += Math.PI * 2;
|
245
|
-
}
|
246
|
-
|
247
|
-
const value = maxComponent;
|
248
|
-
const saturation = value > 0 ? chroma / value : 0;
|
249
|
-
|
250
|
-
return Vec3.of(hue, saturation, value);
|
251
|
-
}
|
252
|
-
|
253
|
-
private hexString: string|null = null;
|
254
|
-
|
255
|
-
/**
|
256
|
-
* @returns a hexadecimal color string representation of `this`, in the form `#rrggbbaa`.
|
257
|
-
*
|
258
|
-
* @example
|
259
|
-
* ```
|
260
|
-
* Color4.red.toHexString(); // -> #ff0000ff
|
261
|
-
* ```
|
262
|
-
*/
|
263
|
-
public toHexString(): string {
|
264
|
-
if (this.hexString) {
|
265
|
-
return this.hexString;
|
266
|
-
}
|
267
|
-
|
268
|
-
const componentToHex = (component: number): string => {
|
269
|
-
const res = Math.round(255 * component).toString(16);
|
270
|
-
|
271
|
-
if (res.length === 1) {
|
272
|
-
return `0${res}`;
|
273
|
-
}
|
274
|
-
return res;
|
275
|
-
};
|
276
|
-
|
277
|
-
const alpha = componentToHex(this.a);
|
278
|
-
const red = componentToHex(this.r);
|
279
|
-
const green = componentToHex(this.g);
|
280
|
-
const blue = componentToHex(this.b);
|
281
|
-
if (alpha === 'ff') {
|
282
|
-
return `#${red}${green}${blue}`;
|
283
|
-
}
|
284
|
-
this.hexString = `#${red}${green}${blue}${alpha}`;
|
285
|
-
return this.hexString;
|
286
|
-
}
|
287
|
-
|
288
|
-
public toString() {
|
289
|
-
return this.toHexString();
|
290
|
-
}
|
291
|
-
|
292
|
-
public static transparent = Color4.ofRGBA(0, 0, 0, 0);
|
293
|
-
public static red = Color4.ofRGB(1.0, 0.0, 0.0);
|
294
|
-
public static green = Color4.ofRGB(0.0, 1.0, 0.0);
|
295
|
-
public static blue = Color4.ofRGB(0.0, 0.0, 1.0);
|
296
|
-
public static purple = Color4.ofRGB(0.5, 0.2, 0.5);
|
297
|
-
public static yellow = Color4.ofRGB(1, 1, 0.1);
|
298
|
-
public static clay = Color4.ofRGB(0.8, 0.4, 0.2);
|
299
|
-
public static black = Color4.ofRGB(0, 0, 0);
|
300
|
-
public static gray = Color4.ofRGB(0.5, 0.5, 0.5);
|
301
|
-
public static white = Color4.ofRGB(1, 1, 1);
|
302
|
-
}
|
303
|
-
|
304
|
-
export { Color4 };
|
package/src/Editor.css
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
|
2
|
-
@import url('./toolbar/toolbar.css');
|
3
|
-
@import url('./tools/tools.css');
|
4
|
-
@import url('./Coloris.css');
|
5
|
-
|
6
|
-
.imageEditorContainer {
|
7
|
-
/* Deafult colors for the editor */
|
8
|
-
--primary-background-color: white;
|
9
|
-
--primary-background-color-transparent: rgba(255, 255, 255, 0.5);
|
10
|
-
--secondary-background-color: #faf;
|
11
|
-
--primary-foreground-color: black;
|
12
|
-
--secondary-foreground-color: black;
|
13
|
-
--primary-shadow-color: rgba(0, 0, 0, 0.5);
|
14
|
-
}
|
15
|
-
|
16
|
-
@media (prefers-color-scheme: dark) {
|
17
|
-
.imageEditorContainer {
|
18
|
-
--primary-background-color: #151515;
|
19
|
-
--primary-background-color-transparent: rgba(50, 50, 50, 0.5);
|
20
|
-
--secondary-background-color: #607;
|
21
|
-
--primary-foreground-color: white;
|
22
|
-
--secondary-foreground-color: white;
|
23
|
-
--primary-shadow-color: rgba(250, 250, 250, 0.5);
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
.imageEditorContainer {
|
28
|
-
color: var(--primary-foreground-color);
|
29
|
-
font-family: system-ui, -apple-system, sans-serif;
|
30
|
-
background-color: var(--primary-background-color);
|
31
|
-
|
32
|
-
display: flex;
|
33
|
-
flex-direction: column-reverse;
|
34
|
-
}
|
35
|
-
|
36
|
-
.imageEditorContainer .imageEditorRenderArea {
|
37
|
-
display: grid;
|
38
|
-
grid-template-columns: 1fr;
|
39
|
-
flex-grow: 2;
|
40
|
-
flex-shrink: 1;
|
41
|
-
min-height: 100px;
|
42
|
-
}
|
43
|
-
|
44
|
-
.imageEditorContainer .imageEditorRenderArea canvas {
|
45
|
-
/* Stack all canvases on top of each other */
|
46
|
-
grid-row: 1 / 1;
|
47
|
-
grid-column: 1 / 1;
|
48
|
-
touch-action: none;
|
49
|
-
|
50
|
-
/* Fill the container */
|
51
|
-
box-sizing: border-box;
|
52
|
-
width: 100%;
|
53
|
-
height: 100%;
|
54
|
-
|
55
|
-
/* Allow the canvas to shrink (needed in Chrome) */
|
56
|
-
min-height: 0px;
|
57
|
-
max-height: inherit;
|
58
|
-
}
|
59
|
-
|
60
|
-
.imageEditorContainer .loadingMessage {
|
61
|
-
position: fixed;
|
62
|
-
text-align: center;
|
63
|
-
font-size: 2em;
|
64
|
-
|
65
|
-
bottom: 0;
|
66
|
-
left: 0;
|
67
|
-
right: 0;
|
68
|
-
}
|
69
|
-
|
70
|
-
.imageEditorContainer .accessibilityAnnouncement {
|
71
|
-
opacity: 0;
|
72
|
-
width: 0;
|
73
|
-
height: 0;
|
74
|
-
overflow: hidden;
|
75
|
-
pointer-events: none;
|
76
|
-
}
|
77
|
-
|
78
|
-
.imageEditorContainer .textRendererOutputContainer {
|
79
|
-
width: 1px;
|
80
|
-
height: 1px;
|
81
|
-
overflow: hidden;
|
82
|
-
}
|
83
|
-
|
84
|
-
.imageEditorContainer .textRendererOutputContainer:focus-within {
|
85
|
-
overflow: visible;
|
86
|
-
z-index: 5;
|
87
|
-
}
|
88
|
-
|
89
|
-
@media print {
|
90
|
-
.imageEditorContainer .loadingMessage {
|
91
|
-
display: none;
|
92
|
-
}
|
93
|
-
|
94
|
-
.imageEditorContainer .imageEditorRenderArea canvas {
|
95
|
-
width: 100%;
|
96
|
-
height: initial;
|
97
|
-
}
|
98
|
-
}
|
package/src/math/Mat33.test.ts
DELETED
@@ -1,244 +0,0 @@
|
|
1
|
-
import Mat33 from './Mat33';
|
2
|
-
import { Point2, Vec2 } from './Vec2';
|
3
|
-
import Vec3 from './Vec3';
|
4
|
-
|
5
|
-
|
6
|
-
describe('Mat33 tests', () => {
|
7
|
-
it('equality', () => {
|
8
|
-
expect(Mat33.identity).objEq(Mat33.identity);
|
9
|
-
expect(new Mat33(
|
10
|
-
0.1, 0.2, 0.3,
|
11
|
-
0.4, 0.5, 0.6,
|
12
|
-
0.7, 0.8, -0.9
|
13
|
-
)).objEq(new Mat33(
|
14
|
-
0.2, 0.1, 0.4,
|
15
|
-
0.5, 0.5, 0.7,
|
16
|
-
0.7, 0.8, -0.9
|
17
|
-
), 0.2);
|
18
|
-
});
|
19
|
-
|
20
|
-
it('transposition', () => {
|
21
|
-
expect(Mat33.identity.transposed()).objEq(Mat33.identity);
|
22
|
-
expect(new Mat33(
|
23
|
-
1, 2, 0,
|
24
|
-
0, 0, 0,
|
25
|
-
0, 1, 0
|
26
|
-
).transposed()).objEq(new Mat33(
|
27
|
-
1, 0, 0,
|
28
|
-
2, 0, 1,
|
29
|
-
0, 0, 0
|
30
|
-
));
|
31
|
-
});
|
32
|
-
|
33
|
-
it('multiplication', () => {
|
34
|
-
const M = new Mat33(
|
35
|
-
1, 2, 3,
|
36
|
-
4, 5, 6,
|
37
|
-
7, 8, 9
|
38
|
-
);
|
39
|
-
|
40
|
-
expect(Mat33.identity.rightMul(Mat33.identity)).objEq(Mat33.identity);
|
41
|
-
expect(M.rightMul(Mat33.identity)).objEq(M);
|
42
|
-
expect(M.rightMul(new Mat33(
|
43
|
-
1, 0, 0,
|
44
|
-
0, 2, 0,
|
45
|
-
0, 0, 1
|
46
|
-
))).objEq(new Mat33(
|
47
|
-
1, 4, 3,
|
48
|
-
4, 10, 6,
|
49
|
-
7, 16, 9
|
50
|
-
));
|
51
|
-
expect(M.rightMul(new Mat33(
|
52
|
-
2, 0, 1,
|
53
|
-
0, 1, 0,
|
54
|
-
0, 0, 3
|
55
|
-
))).objEq(new Mat33(
|
56
|
-
2, 2, 10,
|
57
|
-
8, 5, 22,
|
58
|
-
14, 8, 34
|
59
|
-
));
|
60
|
-
});
|
61
|
-
|
62
|
-
it('the inverse of the identity matrix should be the identity matrix', () => {
|
63
|
-
const fuzz = 0.01;
|
64
|
-
expect(Mat33.identity.inverse()).objEq(Mat33.identity, fuzz);
|
65
|
-
|
66
|
-
const M = new Mat33(
|
67
|
-
1, 2, 3,
|
68
|
-
4, 1, 0,
|
69
|
-
2, 3, 0
|
70
|
-
);
|
71
|
-
expect(M.inverse().rightMul(M)).objEq(Mat33.identity, fuzz);
|
72
|
-
});
|
73
|
-
|
74
|
-
it('90 degree z-rotation matricies should rotate 90 degrees counter clockwise', () => {
|
75
|
-
const fuzz = 0.001;
|
76
|
-
|
77
|
-
const M = Mat33.zRotation(Math.PI / 2);
|
78
|
-
const rotated = M.transformVec2(Vec2.unitX);
|
79
|
-
expect(rotated).objEq(Vec2.unitY, fuzz);
|
80
|
-
expect(M.transformVec2(rotated)).objEq(Vec2.unitX.times(-1), fuzz);
|
81
|
-
});
|
82
|
-
|
83
|
-
it('z-rotation matricies should preserve the given origin', () => {
|
84
|
-
const testPairs: Array<[number, Vec2]> = [
|
85
|
-
[ Math.PI / 2, Vec2.zero ],
|
86
|
-
[ -Math.PI / 2, Vec2.zero ],
|
87
|
-
[ -Math.PI / 2, Vec2.of(10, 10) ],
|
88
|
-
];
|
89
|
-
|
90
|
-
for (const [ angle, center ] of testPairs) {
|
91
|
-
expect(Mat33.zRotation(angle, center).transformVec2(center)).objEq(center);
|
92
|
-
}
|
93
|
-
});
|
94
|
-
|
95
|
-
it('translation matricies should translate Vec2s', () => {
|
96
|
-
const fuzz = 0.01;
|
97
|
-
|
98
|
-
const M = Mat33.translation(Vec2.of(1, -4));
|
99
|
-
expect(M.transformVec2(Vec2.of(0, 0))).objEq(Vec2.of(1, -4), fuzz);
|
100
|
-
expect(M.transformVec2(Vec2.of(-1, 3))).objEq(Vec2.of(0, -1), fuzz);
|
101
|
-
});
|
102
|
-
|
103
|
-
it('scaling matricies should scale about the provided center', () => {
|
104
|
-
const fuzz = 0.01;
|
105
|
-
|
106
|
-
const center = Vec2.of(1, -4);
|
107
|
-
const M = Mat33.scaling2D(2, center);
|
108
|
-
expect(M.transformVec2(center)).objEq(center, fuzz);
|
109
|
-
expect(M.transformVec2(Vec2.of(0, 0))).objEq(Vec2.of(-1, 4), fuzz);
|
110
|
-
});
|
111
|
-
|
112
|
-
it('calling inverse on singular matricies should result in the identity matrix', () => {
|
113
|
-
const fuzz = 0.001;
|
114
|
-
const singularMat = Mat33.ofRows(
|
115
|
-
Vec3.of(0, 0, 1),
|
116
|
-
Vec3.of(0, 1, 0),
|
117
|
-
Vec3.of(0, 1, 1)
|
118
|
-
);
|
119
|
-
expect(singularMat.invertable()).toBe(false);
|
120
|
-
expect(singularMat.inverse()).objEq(Mat33.identity, fuzz);
|
121
|
-
});
|
122
|
-
|
123
|
-
it('z-rotation matricies should be invertable', () => {
|
124
|
-
const fuzz = 0.01;
|
125
|
-
const M = Mat33.zRotation(-0.2617993877991494, Vec2.of(481, 329.5));
|
126
|
-
expect(
|
127
|
-
M.inverse().transformVec2(M.transformVec2(Vec2.unitX))
|
128
|
-
).objEq(Vec2.unitX, fuzz);
|
129
|
-
expect(M.invertable());
|
130
|
-
|
131
|
-
const starterTransform = new Mat33(
|
132
|
-
-0.2588190451025205, -0.9659258262890688, 923.7645204565603,
|
133
|
-
0.9659258262890688, -0.2588190451025205, -49.829447083761465,
|
134
|
-
0, 0, 1
|
135
|
-
);
|
136
|
-
expect(starterTransform.invertable()).toBe(true);
|
137
|
-
|
138
|
-
const fullTransform = starterTransform.rightMul(M);
|
139
|
-
const fullTransformInverse = fullTransform.inverse();
|
140
|
-
expect(fullTransform.invertable()).toBe(true);
|
141
|
-
|
142
|
-
expect(
|
143
|
-
fullTransformInverse.rightMul(fullTransform)
|
144
|
-
).objEq(Mat33.identity, fuzz);
|
145
|
-
|
146
|
-
expect(
|
147
|
-
fullTransform.transformVec2(fullTransformInverse.transformVec2(Vec2.unitX))
|
148
|
-
).objEq(Vec2.unitX, fuzz);
|
149
|
-
|
150
|
-
expect(
|
151
|
-
fullTransformInverse.transformVec2(fullTransform.transformVec2(Vec2.unitX))
|
152
|
-
).objEq(Vec2.unitX, fuzz);
|
153
|
-
});
|
154
|
-
|
155
|
-
it('z-rotation matrix inverses should undo the z-rotation', () => {
|
156
|
-
const testCases: Array<[ number, Point2 ]> = [
|
157
|
-
[ Math.PI / 2, Vec2.zero ],
|
158
|
-
[ Math.PI, Vec2.of(1, 1) ],
|
159
|
-
[ -Math.PI, Vec2.of(1, 1) ],
|
160
|
-
[ -Math.PI * 2, Vec2.of(1, 1) ],
|
161
|
-
[ -Math.PI * 2, Vec2.of(123, 456) ],
|
162
|
-
[ -Math.PI / 4, Vec2.of(123, 456) ],
|
163
|
-
[ 0.1, Vec2.of(1, 2) ],
|
164
|
-
];
|
165
|
-
|
166
|
-
const fuzz = 0.00001;
|
167
|
-
for (const [ angle, center ] of testCases) {
|
168
|
-
const mat = Mat33.zRotation(angle, center);
|
169
|
-
expect(mat.inverse().rightMul(mat)).objEq(Mat33.identity, fuzz);
|
170
|
-
expect(mat.rightMul(mat.inverse())).objEq(Mat33.identity, fuzz);
|
171
|
-
}
|
172
|
-
});
|
173
|
-
|
174
|
-
it('z-rotation should preserve given origin', () => {
|
175
|
-
const testCases: Array<[ number, Point2 ]> = [
|
176
|
-
[ 6.205048847547065, Vec2.of(75.16363373235318, 104.29870408043762) ],
|
177
|
-
[ 1.234, Vec2.of(-56, 789) ],
|
178
|
-
[ -Math.PI, Vec2.of(-56, 789) ],
|
179
|
-
[ -Math.PI / 2, Vec2.of(-0.001, 1.0002) ],
|
180
|
-
];
|
181
|
-
|
182
|
-
for (const [angle, rotationOrigin] of testCases) {
|
183
|
-
expect(Mat33.zRotation(angle, rotationOrigin).transformVec2(rotationOrigin)).objEq(rotationOrigin);
|
184
|
-
}
|
185
|
-
});
|
186
|
-
|
187
|
-
it('should correctly apply a mapping to all components', () => {
|
188
|
-
expect(
|
189
|
-
new Mat33(
|
190
|
-
1, 2, 3,
|
191
|
-
4, 5, 6,
|
192
|
-
7, 8, 9,
|
193
|
-
).mapEntries(component => component - 1)
|
194
|
-
).toMatchObject(new Mat33(
|
195
|
-
0, 1, 2,
|
196
|
-
3, 4, 5,
|
197
|
-
6, 7, 8,
|
198
|
-
));
|
199
|
-
});
|
200
|
-
|
201
|
-
it('should convert CSS matrix(...) strings to matricies', () => {
|
202
|
-
// From MDN:
|
203
|
-
// ⎡ a c e ⎤
|
204
|
-
// ⎢ b d f ⎥ = matrix(a,b,c,d,e,f)
|
205
|
-
// ⎣ 0 0 1 ⎦
|
206
|
-
const identity = Mat33.fromCSSMatrix('matrix(1, 0, 0, 1, 0, 0)');
|
207
|
-
expect(identity).objEq(Mat33.identity);
|
208
|
-
expect(Mat33.fromCSSMatrix('matrix(1, 2, 3, 4, 5, 6)')).objEq(new Mat33(
|
209
|
-
1, 3, 5,
|
210
|
-
2, 4, 6,
|
211
|
-
0, 0, 1,
|
212
|
-
));
|
213
|
-
expect(Mat33.fromCSSMatrix('matrix(1e2, 2, 3, 4, 5, 6)')).objEq(new Mat33(
|
214
|
-
1e2, 3, 5,
|
215
|
-
2, 4, 6,
|
216
|
-
0, 0, 1,
|
217
|
-
));
|
218
|
-
expect(Mat33.fromCSSMatrix('matrix(1.6, 2, .3, 4, 5, 6)')).objEq(new Mat33(
|
219
|
-
1.6, .3, 5,
|
220
|
-
2, 4, 6,
|
221
|
-
0, 0, 1,
|
222
|
-
));
|
223
|
-
expect(Mat33.fromCSSMatrix('matrix(-1, 2, 3.E-2, 4, -5.123, -6.5)')).objEq(new Mat33(
|
224
|
-
-1, 0.03, -5.123,
|
225
|
-
2, 4, -6.5,
|
226
|
-
0, 0, 1,
|
227
|
-
));
|
228
|
-
expect(Mat33.fromCSSMatrix('matrix(1.6,\n\t2, .3, 4, 5, 6)')).objEq(new Mat33(
|
229
|
-
1.6, .3, 5,
|
230
|
-
2, 4, 6,
|
231
|
-
0, 0, 1,
|
232
|
-
));
|
233
|
-
expect(Mat33.fromCSSMatrix('matrix(1.6,2, .3E-2, 4, 5, 6)')).objEq(new Mat33(
|
234
|
-
1.6, 3e-3, 5,
|
235
|
-
2, 4, 6,
|
236
|
-
0, 0, 1,
|
237
|
-
));
|
238
|
-
expect(Mat33.fromCSSMatrix('matrix(-1, 2e6, 3E-2,-5.123, -6.5e-1, 0.01)')).objEq(new Mat33(
|
239
|
-
-1, 3E-2, -6.5e-1,
|
240
|
-
2e6, -5.123, 0.01,
|
241
|
-
0, 0, 1,
|
242
|
-
));
|
243
|
-
});
|
244
|
-
});
|