js-draw 0.18.0 → 0.18.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/CHANGELOG.md +4 -0
- package/dist/bundle.js +1 -1
- package/package.json +3 -2
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -34
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/ISSUE_TEMPLATE/translation.yml +0 -902
- package/.github/pull_request_template.md +0 -15
- package/.github/workflows/firebase-hosting-merge.yml +0 -34
- package/.github/workflows/firebase-hosting-pull-request.yml +0 -34
- package/.github/workflows/github-pages.yml +0 -58
- package/.husky/pre-commit +0 -4
- package/build_tools/BundledFile.ts +0 -167
- package/build_tools/buildTranslationTemplate.ts +0 -121
- package/build_tools/bundle.ts +0 -11
- package/build_tools/postDist.ts +0 -71
- package/dist/cjs/build_tools/BundledFile.d.ts +0 -13
- package/dist/cjs/build_tools/BundledFile.js +0 -163
- package/dist/cjs/build_tools/buildTranslationTemplate.d.ts +0 -1
- package/dist/cjs/build_tools/buildTranslationTemplate.js +0 -119
- package/dist/cjs/build_tools/bundle.d.ts +0 -1
- package/dist/cjs/build_tools/bundle.js +0 -10
- package/dist/cjs/build_tools/postDist.d.ts +0 -1
- package/dist/cjs/build_tools/postDist.js +0 -72
- package/dist/cjs/src/Color4.d.ts +0 -61
- package/dist/cjs/src/Color4.js +0 -197
- package/dist/cjs/src/Editor.d.ts +0 -308
- package/dist/cjs/src/Editor.js +0 -904
- package/dist/cjs/src/EditorImage.d.ts +0 -97
- package/dist/cjs/src/EditorImage.js +0 -486
- package/dist/cjs/src/EventDispatcher.d.ts +0 -30
- package/dist/cjs/src/EventDispatcher.js +0 -57
- package/dist/cjs/src/Pointer.d.ts +0 -24
- package/dist/cjs/src/Pointer.js +0 -84
- package/dist/cjs/src/SVGLoader.d.ts +0 -48
- package/dist/cjs/src/SVGLoader.js +0 -472
- package/dist/cjs/src/UndoRedoHistory.d.ts +0 -19
- package/dist/cjs/src/UndoRedoHistory.js +0 -93
- package/dist/cjs/src/Viewport.d.ts +0 -71
- package/dist/cjs/src/Viewport.js +0 -264
- package/dist/cjs/src/bundle/bundled.d.ts +0 -4
- package/dist/cjs/src/bundle/bundled.js +0 -24
- package/dist/cjs/src/commands/Command.d.ts +0 -16
- package/dist/cjs/src/commands/Command.js +0 -34
- package/dist/cjs/src/commands/Duplicate.d.ts +0 -14
- package/dist/cjs/src/commands/Duplicate.js +0 -39
- package/dist/cjs/src/commands/Erase.d.ts +0 -14
- package/dist/cjs/src/commands/Erase.js +0 -63
- package/dist/cjs/src/commands/SerializableCommand.d.ts +0 -12
- package/dist/cjs/src/commands/SerializableCommand.js +0 -42
- package/dist/cjs/src/commands/UnresolvedCommand.d.ts +0 -14
- package/dist/cjs/src/commands/UnresolvedCommand.js +0 -28
- package/dist/cjs/src/commands/invertCommand.d.ts +0 -4
- package/dist/cjs/src/commands/invertCommand.js +0 -49
- package/dist/cjs/src/commands/lib.d.ts +0 -7
- package/dist/cjs/src/commands/lib.js +0 -18
- package/dist/cjs/src/commands/localization.d.ts +0 -23
- package/dist/cjs/src/commands/localization.js +0 -24
- package/dist/cjs/src/commands/uniteCommands.d.ts +0 -4
- package/dist/cjs/src/commands/uniteCommands.js +0 -121
- package/dist/cjs/src/components/AbstractComponent.d.ts +0 -73
- package/dist/cjs/src/components/AbstractComponent.js +0 -258
- package/dist/cjs/src/components/ImageBackground.d.ts +0 -42
- package/dist/cjs/src/components/ImageBackground.js +0 -146
- package/dist/cjs/src/components/ImageComponent.d.ts +0 -31
- package/dist/cjs/src/components/ImageComponent.js +0 -152
- package/dist/cjs/src/components/RestylableComponent.d.ts +0 -24
- package/dist/cjs/src/components/RestylableComponent.js +0 -88
- package/dist/cjs/src/components/SVGGlobalAttributesObject.d.ts +0 -21
- package/dist/cjs/src/components/SVGGlobalAttributesObject.js +0 -65
- package/dist/cjs/src/components/Stroke.d.ts +0 -40
- package/dist/cjs/src/components/Stroke.js +0 -191
- package/dist/cjs/src/components/TextComponent.d.ts +0 -53
- package/dist/cjs/src/components/TextComponent.js +0 -258
- package/dist/cjs/src/components/UnknownSVGObject.d.ts +0 -18
- package/dist/cjs/src/components/UnknownSVGObject.js +0 -50
- package/dist/cjs/src/components/builders/ArrowBuilder.d.ts +0 -19
- package/dist/cjs/src/components/builders/ArrowBuilder.js +0 -117
- package/dist/cjs/src/components/builders/FreehandLineBuilder.d.ts +0 -33
- package/dist/cjs/src/components/builders/FreehandLineBuilder.js +0 -173
- package/dist/cjs/src/components/builders/LineBuilder.d.ts +0 -18
- package/dist/cjs/src/components/builders/LineBuilder.js +0 -89
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +0 -36
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.js +0 -347
- package/dist/cjs/src/components/builders/RectangleBuilder.d.ts +0 -20
- package/dist/cjs/src/components/builders/RectangleBuilder.js +0 -59
- package/dist/cjs/src/components/builders/types.d.ts +0 -12
- package/dist/cjs/src/components/builders/types.js +0 -2
- package/dist/cjs/src/components/lib.d.ts +0 -12
- package/dist/cjs/src/components/lib.js +0 -43
- package/dist/cjs/src/components/localization.d.ts +0 -11
- package/dist/cjs/src/components/localization.js +0 -13
- package/dist/cjs/src/components/util/StrokeSmoother.d.ts +0 -35
- package/dist/cjs/src/components/util/StrokeSmoother.js +0 -217
- package/dist/cjs/src/components/util/describeComponentList.d.ts +0 -4
- package/dist/cjs/src/components/util/describeComponentList.js +0 -16
- package/dist/cjs/src/lib.d.ts +0 -34
- package/dist/cjs/src/lib.js +0 -63
- package/dist/cjs/src/localization.d.ts +0 -14
- package/dist/cjs/src/localization.js +0 -13
- package/dist/cjs/src/localizations/de.d.ts +0 -3
- package/dist/cjs/src/localizations/de.js +0 -6
- package/dist/cjs/src/localizations/en.d.ts +0 -3
- package/dist/cjs/src/localizations/en.js +0 -6
- package/dist/cjs/src/localizations/es.d.ts +0 -3
- package/dist/cjs/src/localizations/es.js +0 -20
- package/dist/cjs/src/localizations/getLocalizationTable.d.ts +0 -3
- package/dist/cjs/src/localizations/getLocalizationTable.js +0 -50
- package/dist/cjs/src/math/LineSegment2.d.ts +0 -24
- package/dist/cjs/src/math/LineSegment2.js +0 -131
- package/dist/cjs/src/math/Mat33.d.ts +0 -118
- package/dist/cjs/src/math/Mat33.js +0 -332
- package/dist/cjs/src/math/Path.d.ts +0 -71
- package/dist/cjs/src/math/Path.js +0 -655
- package/dist/cjs/src/math/Rect2.d.ts +0 -52
- package/dist/cjs/src/math/Rect2.js +0 -234
- package/dist/cjs/src/math/Triangle.d.ts +0 -11
- package/dist/cjs/src/math/Triangle.js +0 -22
- package/dist/cjs/src/math/Vec2.d.ts +0 -13
- package/dist/cjs/src/math/Vec2.js +0 -19
- package/dist/cjs/src/math/Vec3.d.ts +0 -106
- package/dist/cjs/src/math/Vec3.js +0 -177
- package/dist/cjs/src/math/lib.d.ts +0 -7
- package/dist/cjs/src/math/lib.js +0 -18
- package/dist/cjs/src/math/rounding.d.ts +0 -4
- package/dist/cjs/src/math/rounding.js +0 -135
- package/dist/cjs/src/rendering/Display.d.ts +0 -75
- package/dist/cjs/src/rendering/Display.js +0 -214
- package/dist/cjs/src/rendering/RenderingStyle.d.ts +0 -31
- package/dist/cjs/src/rendering/RenderingStyle.js +0 -48
- package/dist/cjs/src/rendering/TextRenderingStyle.d.ts +0 -36
- package/dist/cjs/src/rendering/TextRenderingStyle.js +0 -29
- package/dist/cjs/src/rendering/caching/CacheRecord.d.ts +0 -20
- package/dist/cjs/src/rendering/caching/CacheRecord.js +0 -61
- package/dist/cjs/src/rendering/caching/CacheRecordManager.d.ts +0 -12
- package/dist/cjs/src/rendering/caching/CacheRecordManager.js +0 -50
- package/dist/cjs/src/rendering/caching/RenderingCache.d.ts +0 -11
- package/dist/cjs/src/rendering/caching/RenderingCache.js +0 -51
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.d.ts +0 -29
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.js +0 -326
- package/dist/cjs/src/rendering/caching/testUtils.d.ts +0 -9
- package/dist/cjs/src/rendering/caching/testUtils.js +0 -27
- package/dist/cjs/src/rendering/caching/types.d.ts +0 -19
- package/dist/cjs/src/rendering/caching/types.js +0 -2
- package/dist/cjs/src/rendering/lib.d.ts +0 -5
- package/dist/cjs/src/rendering/lib.js +0 -16
- package/dist/cjs/src/rendering/localization.d.ts +0 -10
- package/dist/cjs/src/rendering/localization.js +0 -12
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.d.ts +0 -68
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.js +0 -170
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.d.ts +0 -63
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.js +0 -236
- package/dist/cjs/src/rendering/renderers/DummyRenderer.d.ts +0 -35
- package/dist/cjs/src/rendering/renderers/DummyRenderer.js +0 -112
- package/dist/cjs/src/rendering/renderers/SVGRenderer.d.ts +0 -57
- package/dist/cjs/src/rendering/renderers/SVGRenderer.js +0 -311
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.d.ts +0 -29
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.js +0 -63
- package/dist/cjs/src/testing/beforeEachFile.d.ts +0 -1
- package/dist/cjs/src/testing/beforeEachFile.js +0 -12
- package/dist/cjs/src/testing/createEditor.d.ts +0 -4
- package/dist/cjs/src/testing/createEditor.js +0 -14
- package/dist/cjs/src/testing/lib.d.ts +0 -2
- package/dist/cjs/src/testing/lib.js +0 -10
- package/dist/cjs/src/testing/loadExpectExtensions.d.ts +0 -2
- package/dist/cjs/src/testing/loadExpectExtensions.js +0 -28
- package/dist/cjs/src/testing/sendPenEvent.d.ts +0 -12
- package/dist/cjs/src/testing/sendPenEvent.js +0 -24
- package/dist/cjs/src/testing/sendTouchEvent.d.ts +0 -42
- package/dist/cjs/src/testing/sendTouchEvent.js +0 -87
- package/dist/cjs/src/toolbar/HTMLToolbar.d.ts +0 -103
- package/dist/cjs/src/toolbar/HTMLToolbar.js +0 -383
- package/dist/cjs/src/toolbar/IconProvider.d.ts +0 -62
- package/dist/cjs/src/toolbar/IconProvider.js +0 -660
- package/dist/cjs/src/toolbar/lib.d.ts +0 -3
- package/dist/cjs/src/toolbar/lib.js +0 -24
- package/dist/cjs/src/toolbar/localization.d.ts +0 -49
- package/dist/cjs/src/toolbar/localization.js +0 -51
- package/dist/cjs/src/toolbar/makeColorInput.d.ts +0 -6
- package/dist/cjs/src/toolbar/makeColorInput.js +0 -120
- package/dist/cjs/src/toolbar/types.d.ts +0 -4
- package/dist/cjs/src/toolbar/types.js +0 -2
- package/dist/cjs/src/toolbar/widgets/ActionButtonWidget.d.ts +0 -15
- package/dist/cjs/src/toolbar/widgets/ActionButtonWidget.js +0 -31
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.d.ts +0 -11
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.js +0 -50
- package/dist/cjs/src/toolbar/widgets/BaseWidget.d.ts +0 -72
- package/dist/cjs/src/toolbar/widgets/BaseWidget.js +0 -313
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +0 -18
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +0 -126
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.d.ts +0 -17
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.js +0 -63
- package/dist/cjs/src/toolbar/widgets/HandToolWidget.d.ts +0 -17
- package/dist/cjs/src/toolbar/widgets/HandToolWidget.js +0 -201
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.d.ts +0 -19
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.js +0 -176
- package/dist/cjs/src/toolbar/widgets/OverflowWidget.d.ts +0 -25
- package/dist/cjs/src/toolbar/widgets/OverflowWidget.js +0 -77
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.d.ts +0 -27
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +0 -226
- package/dist/cjs/src/toolbar/widgets/SelectionToolWidget.d.ts +0 -13
- package/dist/cjs/src/toolbar/widgets/SelectionToolWidget.js +0 -153
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.d.ts +0 -16
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.js +0 -115
- package/dist/cjs/src/toolbar/widgets/lib.d.ts +0 -10
- package/dist/cjs/src/toolbar/widgets/lib.js +0 -26
- package/dist/cjs/src/tools/BaseTool.d.ts +0 -22
- package/dist/cjs/src/tools/BaseTool.js +0 -66
- package/dist/cjs/src/tools/Eraser.d.ts +0 -23
- package/dist/cjs/src/tools/Eraser.js +0 -112
- package/dist/cjs/src/tools/FindTool.d.ts +0 -21
- package/dist/cjs/src/tools/FindTool.js +0 -121
- package/dist/cjs/src/tools/PanZoom.d.ts +0 -52
- package/dist/cjs/src/tools/PanZoom.js +0 -421
- package/dist/cjs/src/tools/PasteHandler.d.ts +0 -23
- package/dist/cjs/src/tools/PasteHandler.js +0 -99
- package/dist/cjs/src/tools/Pen.d.ts +0 -39
- package/dist/cjs/src/tools/Pen.js +0 -179
- package/dist/cjs/src/tools/PipetteTool.d.ts +0 -18
- package/dist/cjs/src/tools/PipetteTool.js +0 -45
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +0 -8
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.js +0 -28
- package/dist/cjs/src/tools/SelectionTool/Selection.d.ts +0 -64
- package/dist/cjs/src/tools/SelectionTool/Selection.js +0 -488
- package/dist/cjs/src/tools/SelectionTool/SelectionHandle.d.ts +0 -38
- package/dist/cjs/src/tools/SelectionTool/SelectionHandle.js +0 -85
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.d.ts +0 -36
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.js +0 -405
- package/dist/cjs/src/tools/SelectionTool/TransformMode.d.ts +0 -34
- package/dist/cjs/src/tools/SelectionTool/TransformMode.js +0 -107
- package/dist/cjs/src/tools/SelectionTool/types.d.ts +0 -9
- package/dist/cjs/src/tools/SelectionTool/types.js +0 -14
- package/dist/cjs/src/tools/TextTool.d.ts +0 -33
- package/dist/cjs/src/tools/TextTool.js +0 -262
- package/dist/cjs/src/tools/ToolController.d.ts +0 -18
- package/dist/cjs/src/tools/ToolController.js +0 -187
- package/dist/cjs/src/tools/ToolEnabledGroup.d.ts +0 -6
- package/dist/cjs/src/tools/ToolEnabledGroup.js +0 -14
- package/dist/cjs/src/tools/ToolSwitcherShortcut.d.ts +0 -16
- package/dist/cjs/src/tools/ToolSwitcherShortcut.js +0 -38
- package/dist/cjs/src/tools/ToolbarShortcutHandler.d.ts +0 -12
- package/dist/cjs/src/tools/ToolbarShortcutHandler.js +0 -29
- package/dist/cjs/src/tools/UndoRedoShortcut.d.ts +0 -8
- package/dist/cjs/src/tools/UndoRedoShortcut.js +0 -28
- package/dist/cjs/src/tools/lib.d.ts +0 -16
- package/dist/cjs/src/tools/lib.js +0 -36
- package/dist/cjs/src/tools/localization.d.ts +0 -28
- package/dist/cjs/src/tools/localization.js +0 -30
- package/dist/cjs/src/types.d.ts +0 -151
- package/dist/cjs/src/types.js +0 -38
- package/dist/cjs/src/util/assertions.d.ts +0 -23
- package/dist/cjs/src/util/assertions.js +0 -51
- package/dist/cjs/src/util/fileToBase64.d.ts +0 -3
- package/dist/cjs/src/util/fileToBase64.js +0 -15
- package/dist/cjs/src/util/untilNextAnimationFrame.d.ts +0 -3
- package/dist/cjs/src/util/untilNextAnimationFrame.js +0 -9
- package/dist/cjs/src/util/waitForTimeout.d.ts +0 -2
- package/dist/cjs/src/util/waitForTimeout.js +0 -9
- package/dist/mjs/build_tools/BundledFile.d.ts +0 -13
- package/dist/mjs/build_tools/BundledFile.mjs +0 -157
- package/dist/mjs/build_tools/buildTranslationTemplate.d.ts +0 -1
- package/dist/mjs/build_tools/buildTranslationTemplate.mjs +0 -94
- package/dist/mjs/build_tools/bundle.d.ts +0 -1
- package/dist/mjs/build_tools/bundle.mjs +0 -5
- package/dist/mjs/build_tools/postDist.d.ts +0 -1
- package/dist/mjs/build_tools/postDist.mjs +0 -67
- package/dist/mjs/src/Color4.d.ts +0 -61
- package/dist/mjs/src/Color4.mjs +0 -193
- package/dist/mjs/src/Editor.d.ts +0 -308
- package/dist/mjs/src/Editor.mjs +0 -874
- package/dist/mjs/src/EditorImage.d.ts +0 -97
- package/dist/mjs/src/EditorImage.mjs +0 -477
- package/dist/mjs/src/EventDispatcher.d.ts +0 -30
- package/dist/mjs/src/EventDispatcher.mjs +0 -54
- package/dist/mjs/src/Pointer.d.ts +0 -24
- package/dist/mjs/src/Pointer.mjs +0 -80
- package/dist/mjs/src/SVGLoader.d.ts +0 -48
- package/dist/mjs/src/SVGLoader.mjs +0 -442
- package/dist/mjs/src/UndoRedoHistory.d.ts +0 -19
- package/dist/mjs/src/UndoRedoHistory.mjs +0 -91
- package/dist/mjs/src/Viewport.d.ts +0 -71
- package/dist/mjs/src/Viewport.mjs +0 -256
- package/dist/mjs/src/bundle/bundled.d.ts +0 -4
- package/dist/mjs/src/bundle/bundled.mjs +0 -5
- package/dist/mjs/src/commands/Command.d.ts +0 -16
- package/dist/mjs/src/commands/Command.mjs +0 -30
- package/dist/mjs/src/commands/Duplicate.d.ts +0 -14
- package/dist/mjs/src/commands/Duplicate.mjs +0 -33
- package/dist/mjs/src/commands/Erase.d.ts +0 -14
- package/dist/mjs/src/commands/Erase.mjs +0 -57
- package/dist/mjs/src/commands/SerializableCommand.d.ts +0 -12
- package/dist/mjs/src/commands/SerializableCommand.mjs +0 -36
- package/dist/mjs/src/commands/UnresolvedCommand.d.ts +0 -14
- package/dist/mjs/src/commands/UnresolvedCommand.mjs +0 -22
- package/dist/mjs/src/commands/invertCommand.d.ts +0 -4
- package/dist/mjs/src/commands/invertCommand.mjs +0 -44
- package/dist/mjs/src/commands/lib.d.ts +0 -7
- package/dist/mjs/src/commands/lib.mjs +0 -7
- package/dist/mjs/src/commands/localization.d.ts +0 -23
- package/dist/mjs/src/commands/localization.mjs +0 -21
- package/dist/mjs/src/commands/uniteCommands.d.ts +0 -4
- package/dist/mjs/src/commands/uniteCommands.mjs +0 -116
- package/dist/mjs/src/components/AbstractComponent.d.ts +0 -73
- package/dist/mjs/src/components/AbstractComponent.mjs +0 -252
- package/dist/mjs/src/components/ImageBackground.d.ts +0 -42
- package/dist/mjs/src/components/ImageBackground.mjs +0 -139
- package/dist/mjs/src/components/ImageComponent.d.ts +0 -31
- package/dist/mjs/src/components/ImageComponent.mjs +0 -146
- package/dist/mjs/src/components/RestylableComponent.d.ts +0 -24
- package/dist/mjs/src/components/RestylableComponent.mjs +0 -80
- package/dist/mjs/src/components/SVGGlobalAttributesObject.d.ts +0 -21
- package/dist/mjs/src/components/SVGGlobalAttributesObject.mjs +0 -59
- package/dist/mjs/src/components/Stroke.d.ts +0 -40
- package/dist/mjs/src/components/Stroke.mjs +0 -185
- package/dist/mjs/src/components/TextComponent.d.ts +0 -53
- package/dist/mjs/src/components/TextComponent.mjs +0 -252
- package/dist/mjs/src/components/UnknownSVGObject.d.ts +0 -18
- package/dist/mjs/src/components/UnknownSVGObject.mjs +0 -44
- package/dist/mjs/src/components/builders/ArrowBuilder.d.ts +0 -19
- package/dist/mjs/src/components/builders/ArrowBuilder.mjs +0 -86
- package/dist/mjs/src/components/builders/FreehandLineBuilder.d.ts +0 -33
- package/dist/mjs/src/components/builders/FreehandLineBuilder.mjs +0 -165
- package/dist/mjs/src/components/builders/LineBuilder.d.ts +0 -18
- package/dist/mjs/src/components/builders/LineBuilder.mjs +0 -58
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +0 -36
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.mjs +0 -339
- package/dist/mjs/src/components/builders/RectangleBuilder.d.ts +0 -20
- package/dist/mjs/src/components/builders/RectangleBuilder.mjs +0 -50
- package/dist/mjs/src/components/builders/types.d.ts +0 -12
- package/dist/mjs/src/components/builders/types.mjs +0 -1
- package/dist/mjs/src/components/lib.d.ts +0 -12
- package/dist/mjs/src/components/lib.mjs +0 -12
- package/dist/mjs/src/components/localization.d.ts +0 -11
- package/dist/mjs/src/components/localization.mjs +0 -10
- package/dist/mjs/src/components/util/StrokeSmoother.d.ts +0 -35
- package/dist/mjs/src/components/util/StrokeSmoother.mjs +0 -210
- package/dist/mjs/src/components/util/describeComponentList.d.ts +0 -4
- package/dist/mjs/src/components/util/describeComponentList.mjs +0 -14
- package/dist/mjs/src/lib.d.ts +0 -34
- package/dist/mjs/src/lib.mjs +0 -34
- package/dist/mjs/src/localization.d.ts +0 -14
- package/dist/mjs/src/localization.mjs +0 -10
- package/dist/mjs/src/localizations/de.d.ts +0 -3
- package/dist/mjs/src/localizations/de.mjs +0 -4
- package/dist/mjs/src/localizations/en.d.ts +0 -3
- package/dist/mjs/src/localizations/en.mjs +0 -4
- package/dist/mjs/src/localizations/es.d.ts +0 -3
- package/dist/mjs/src/localizations/es.mjs +0 -18
- package/dist/mjs/src/localizations/getLocalizationTable.d.ts +0 -3
- package/dist/mjs/src/localizations/getLocalizationTable.mjs +0 -45
- package/dist/mjs/src/math/LineSegment2.d.ts +0 -24
- package/dist/mjs/src/math/LineSegment2.mjs +0 -125
- package/dist/mjs/src/math/Mat33.d.ts +0 -118
- package/dist/mjs/src/math/Mat33.mjs +0 -326
- package/dist/mjs/src/math/Path.d.ts +0 -71
- package/dist/mjs/src/math/Path.mjs +0 -648
- package/dist/mjs/src/math/Rect2.d.ts +0 -52
- package/dist/mjs/src/math/Rect2.mjs +0 -228
- package/dist/mjs/src/math/Triangle.d.ts +0 -11
- package/dist/mjs/src/math/Triangle.mjs +0 -19
- package/dist/mjs/src/math/Vec2.d.ts +0 -13
- package/dist/mjs/src/math/Vec2.mjs +0 -13
- package/dist/mjs/src/math/Vec3.d.ts +0 -106
- package/dist/mjs/src/math/Vec3.mjs +0 -174
- package/dist/mjs/src/math/lib.d.ts +0 -7
- package/dist/mjs/src/math/lib.mjs +0 -7
- package/dist/mjs/src/math/rounding.d.ts +0 -4
- package/dist/mjs/src/math/rounding.mjs +0 -128
- package/dist/mjs/src/rendering/Display.d.ts +0 -75
- package/dist/mjs/src/rendering/Display.mjs +0 -207
- package/dist/mjs/src/rendering/RenderingStyle.d.ts +0 -31
- package/dist/mjs/src/rendering/RenderingStyle.mjs +0 -38
- package/dist/mjs/src/rendering/TextRenderingStyle.d.ts +0 -36
- package/dist/mjs/src/rendering/TextRenderingStyle.mjs +0 -23
- package/dist/mjs/src/rendering/caching/CacheRecord.d.ts +0 -20
- package/dist/mjs/src/rendering/caching/CacheRecord.mjs +0 -55
- package/dist/mjs/src/rendering/caching/CacheRecordManager.d.ts +0 -12
- package/dist/mjs/src/rendering/caching/CacheRecordManager.mjs +0 -43
- package/dist/mjs/src/rendering/caching/RenderingCache.d.ts +0 -11
- package/dist/mjs/src/rendering/caching/RenderingCache.mjs +0 -45
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.d.ts +0 -29
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.mjs +0 -320
- package/dist/mjs/src/rendering/caching/testUtils.d.ts +0 -9
- package/dist/mjs/src/rendering/caching/testUtils.mjs +0 -20
- package/dist/mjs/src/rendering/caching/types.d.ts +0 -19
- package/dist/mjs/src/rendering/caching/types.mjs +0 -1
- package/dist/mjs/src/rendering/lib.d.ts +0 -5
- package/dist/mjs/src/rendering/lib.mjs +0 -5
- package/dist/mjs/src/rendering/localization.d.ts +0 -10
- package/dist/mjs/src/rendering/localization.mjs +0 -9
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.d.ts +0 -68
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.mjs +0 -144
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.d.ts +0 -63
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.mjs +0 -230
- package/dist/mjs/src/rendering/renderers/DummyRenderer.d.ts +0 -35
- package/dist/mjs/src/rendering/renderers/DummyRenderer.mjs +0 -106
- package/dist/mjs/src/rendering/renderers/SVGRenderer.d.ts +0 -57
- package/dist/mjs/src/rendering/renderers/SVGRenderer.mjs +0 -304
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.d.ts +0 -29
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.mjs +0 -57
- package/dist/mjs/src/testing/beforeEachFile.d.ts +0 -1
- package/dist/mjs/src/testing/beforeEachFile.mjs +0 -7
- package/dist/mjs/src/testing/createEditor.d.ts +0 -4
- package/dist/mjs/src/testing/createEditor.mjs +0 -9
- package/dist/mjs/src/testing/lib.d.ts +0 -2
- package/dist/mjs/src/testing/lib.mjs +0 -2
- package/dist/mjs/src/testing/loadExpectExtensions.d.ts +0 -2
- package/dist/mjs/src/testing/loadExpectExtensions.mjs +0 -24
- package/dist/mjs/src/testing/sendPenEvent.d.ts +0 -12
- package/dist/mjs/src/testing/sendPenEvent.mjs +0 -19
- package/dist/mjs/src/testing/sendTouchEvent.d.ts +0 -42
- package/dist/mjs/src/testing/sendTouchEvent.mjs +0 -62
- package/dist/mjs/src/toolbar/HTMLToolbar.d.ts +0 -103
- package/dist/mjs/src/toolbar/HTMLToolbar.mjs +0 -376
- package/dist/mjs/src/toolbar/IconProvider.d.ts +0 -62
- package/dist/mjs/src/toolbar/IconProvider.mjs +0 -654
- package/dist/mjs/src/toolbar/lib.d.ts +0 -3
- package/dist/mjs/src/toolbar/lib.mjs +0 -3
- package/dist/mjs/src/toolbar/localization.d.ts +0 -49
- package/dist/mjs/src/toolbar/localization.mjs +0 -48
- package/dist/mjs/src/toolbar/makeColorInput.d.ts +0 -6
- package/dist/mjs/src/toolbar/makeColorInput.mjs +0 -113
- package/dist/mjs/src/toolbar/types.d.ts +0 -4
- package/dist/mjs/src/toolbar/types.mjs +0 -1
- package/dist/mjs/src/toolbar/widgets/ActionButtonWidget.d.ts +0 -15
- package/dist/mjs/src/toolbar/widgets/ActionButtonWidget.mjs +0 -25
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.d.ts +0 -11
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.mjs +0 -44
- package/dist/mjs/src/toolbar/widgets/BaseWidget.d.ts +0 -72
- package/dist/mjs/src/toolbar/widgets/BaseWidget.mjs +0 -307
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +0 -18
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs +0 -120
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.d.ts +0 -17
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.mjs +0 -57
- package/dist/mjs/src/toolbar/widgets/HandToolWidget.d.ts +0 -17
- package/dist/mjs/src/toolbar/widgets/HandToolWidget.mjs +0 -172
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.d.ts +0 -19
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.mjs +0 -170
- package/dist/mjs/src/toolbar/widgets/OverflowWidget.d.ts +0 -25
- package/dist/mjs/src/toolbar/widgets/OverflowWidget.mjs +0 -71
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.d.ts +0 -27
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.mjs +0 -220
- package/dist/mjs/src/toolbar/widgets/SelectionToolWidget.d.ts +0 -13
- package/dist/mjs/src/toolbar/widgets/SelectionToolWidget.mjs +0 -147
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.d.ts +0 -16
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.mjs +0 -109
- package/dist/mjs/src/toolbar/widgets/lib.d.ts +0 -10
- package/dist/mjs/src/toolbar/widgets/lib.mjs +0 -10
- package/dist/mjs/src/tools/BaseTool.d.ts +0 -22
- package/dist/mjs/src/tools/BaseTool.mjs +0 -63
- package/dist/mjs/src/tools/Eraser.d.ts +0 -23
- package/dist/mjs/src/tools/Eraser.mjs +0 -106
- package/dist/mjs/src/tools/FindTool.d.ts +0 -21
- package/dist/mjs/src/tools/FindTool.mjs +0 -114
- package/dist/mjs/src/tools/PanZoom.d.ts +0 -52
- package/dist/mjs/src/tools/PanZoom.mjs +0 -414
- package/dist/mjs/src/tools/PasteHandler.d.ts +0 -23
- package/dist/mjs/src/tools/PasteHandler.mjs +0 -93
- package/dist/mjs/src/tools/Pen.d.ts +0 -39
- package/dist/mjs/src/tools/Pen.mjs +0 -173
- package/dist/mjs/src/tools/PipetteTool.d.ts +0 -18
- package/dist/mjs/src/tools/PipetteTool.mjs +0 -39
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +0 -8
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.mjs +0 -22
- package/dist/mjs/src/tools/SelectionTool/Selection.d.ts +0 -64
- package/dist/mjs/src/tools/SelectionTool/Selection.mjs +0 -459
- package/dist/mjs/src/tools/SelectionTool/SelectionHandle.d.ts +0 -38
- package/dist/mjs/src/tools/SelectionTool/SelectionHandle.mjs +0 -81
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.d.ts +0 -36
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.mjs +0 -398
- package/dist/mjs/src/tools/SelectionTool/TransformMode.d.ts +0 -34
- package/dist/mjs/src/tools/SelectionTool/TransformMode.mjs +0 -98
- package/dist/mjs/src/tools/SelectionTool/types.d.ts +0 -9
- package/dist/mjs/src/tools/SelectionTool/types.mjs +0 -11
- package/dist/mjs/src/tools/TextTool.d.ts +0 -33
- package/dist/mjs/src/tools/TextTool.mjs +0 -256
- package/dist/mjs/src/tools/ToolController.d.ts +0 -18
- package/dist/mjs/src/tools/ToolController.mjs +0 -158
- package/dist/mjs/src/tools/ToolEnabledGroup.d.ts +0 -6
- package/dist/mjs/src/tools/ToolEnabledGroup.mjs +0 -11
- package/dist/mjs/src/tools/ToolSwitcherShortcut.d.ts +0 -16
- package/dist/mjs/src/tools/ToolSwitcherShortcut.mjs +0 -32
- package/dist/mjs/src/tools/ToolbarShortcutHandler.d.ts +0 -12
- package/dist/mjs/src/tools/ToolbarShortcutHandler.mjs +0 -23
- package/dist/mjs/src/tools/UndoRedoShortcut.d.ts +0 -8
- package/dist/mjs/src/tools/UndoRedoShortcut.mjs +0 -22
- package/dist/mjs/src/tools/lib.d.ts +0 -16
- package/dist/mjs/src/tools/lib.mjs +0 -16
- package/dist/mjs/src/tools/localization.d.ts +0 -28
- package/dist/mjs/src/tools/localization.mjs +0 -27
- package/dist/mjs/src/types.d.ts +0 -151
- package/dist/mjs/src/types.mjs +0 -35
- package/dist/mjs/src/util/assertions.d.ts +0 -23
- package/dist/mjs/src/util/assertions.mjs +0 -45
- package/dist/mjs/src/util/fileToBase64.d.ts +0 -3
- package/dist/mjs/src/util/fileToBase64.mjs +0 -13
- package/dist/mjs/src/util/untilNextAnimationFrame.d.ts +0 -3
- package/dist/mjs/src/util/untilNextAnimationFrame.mjs +0 -7
- package/dist/mjs/src/util/waitForTimeout.d.ts +0 -2
- package/dist/mjs/src/util/waitForTimeout.mjs +0 -7
- package/src/Color4.test.ts +0 -40
- package/src/Color4.ts +0 -236
- package/src/Editor.css +0 -86
- package/src/Editor.loadFrom.test.ts +0 -24
- package/src/Editor.toSVG.test.ts +0 -111
- package/src/Editor.ts +0 -1122
- package/src/EditorImage.test.ts +0 -120
- package/src/EditorImage.ts +0 -603
- package/src/EventDispatcher.test.ts +0 -123
- package/src/EventDispatcher.ts +0 -71
- package/src/Pointer.ts +0 -127
- package/src/SVGLoader.test.ts +0 -114
- package/src/SVGLoader.ts +0 -511
- package/src/UndoRedoHistory.test.ts +0 -33
- package/src/UndoRedoHistory.ts +0 -102
- package/src/Viewport.ts +0 -319
- package/src/bundle/bundled.ts +0 -7
- package/src/commands/Command.ts +0 -45
- package/src/commands/Duplicate.ts +0 -48
- package/src/commands/Erase.ts +0 -74
- package/src/commands/SerializableCommand.ts +0 -49
- package/src/commands/UnresolvedCommand.ts +0 -37
- package/src/commands/invertCommand.ts +0 -51
- package/src/commands/lib.ts +0 -16
- package/src/commands/localization.ts +0 -47
- package/src/commands/uniteCommands.test.ts +0 -23
- package/src/commands/uniteCommands.ts +0 -135
- package/src/components/AbstractComponent.transformBy.test.ts +0 -22
- package/src/components/AbstractComponent.ts +0 -364
- package/src/components/ImageBackground.test.ts +0 -35
- package/src/components/ImageBackground.ts +0 -176
- package/src/components/ImageComponent.ts +0 -171
- package/src/components/RestylableComponent.ts +0 -142
- package/src/components/SVGGlobalAttributesObject.ts +0 -81
- package/src/components/Stroke.test.ts +0 -139
- package/src/components/Stroke.ts +0 -245
- package/src/components/TextComponent.test.ts +0 -99
- package/src/components/TextComponent.ts +0 -315
- package/src/components/UnknownSVGObject.test.ts +0 -10
- package/src/components/UnknownSVGObject.ts +0 -60
- package/src/components/builders/ArrowBuilder.ts +0 -107
- package/src/components/builders/FreehandLineBuilder.ts +0 -212
- package/src/components/builders/LineBuilder.ts +0 -77
- package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +0 -454
- package/src/components/builders/RectangleBuilder.ts +0 -74
- package/src/components/builders/types.ts +0 -15
- package/src/components/lib.ts +0 -25
- package/src/components/localization.ts +0 -22
- package/src/components/util/StrokeSmoother.ts +0 -293
- package/src/components/util/describeComponentList.ts +0 -18
- package/src/lib.ts +0 -37
- package/src/localization.ts +0 -34
- package/src/localizations/de.ts +0 -98
- package/src/localizations/en.ts +0 -8
- package/src/localizations/es.ts +0 -74
- package/src/localizations/getLocalizationTable.test.ts +0 -27
- package/src/localizations/getLocalizationTable.ts +0 -55
- package/src/math/LineSegment2.test.ts +0 -99
- package/src/math/LineSegment2.ts +0 -160
- package/src/math/Mat33.test.ts +0 -244
- package/src/math/Mat33.ts +0 -437
- package/src/math/Path.fromString.test.ts +0 -223
- package/src/math/Path.test.ts +0 -198
- package/src/math/Path.toString.test.ts +0 -77
- package/src/math/Path.ts +0 -790
- package/src/math/Rect2.test.ts +0 -204
- package/src/math/Rect2.ts +0 -315
- package/src/math/Triangle.ts +0 -29
- package/src/math/Vec2.test.ts +0 -30
- package/src/math/Vec2.ts +0 -18
- 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/rounding.test.ts +0 -65
- package/src/math/rounding.ts +0 -156
- package/src/rendering/Display.ts +0 -249
- package/src/rendering/RenderingStyle.test.ts +0 -68
- package/src/rendering/RenderingStyle.ts +0 -55
- package/src/rendering/TextRenderingStyle.ts +0 -45
- package/src/rendering/caching/CacheRecord.test.ts +0 -49
- package/src/rendering/caching/CacheRecord.ts +0 -77
- package/src/rendering/caching/CacheRecordManager.ts +0 -71
- package/src/rendering/caching/RenderingCache.test.ts +0 -44
- package/src/rendering/caching/RenderingCache.ts +0 -66
- package/src/rendering/caching/RenderingCacheNode.ts +0 -405
- package/src/rendering/caching/testUtils.ts +0 -35
- package/src/rendering/caching/types.ts +0 -34
- package/src/rendering/lib.ts +0 -6
- package/src/rendering/localization.ts +0 -20
- package/src/rendering/renderers/AbstractRenderer.ts +0 -222
- package/src/rendering/renderers/CanvasRenderer.ts +0 -296
- package/src/rendering/renderers/DummyRenderer.test.ts +0 -42
- package/src/rendering/renderers/DummyRenderer.ts +0 -136
- package/src/rendering/renderers/SVGRenderer.ts +0 -354
- package/src/rendering/renderers/TextOnlyRenderer.ts +0 -70
- package/src/styles.js +0 -7
- package/src/testing/beforeEachFile.ts +0 -8
- package/src/testing/createEditor.ts +0 -11
- package/src/testing/global.d.ts +0 -17
- package/src/testing/lib.ts +0 -3
- package/src/testing/loadExpectExtensions.ts +0 -25
- package/src/testing/sendPenEvent.ts +0 -31
- package/src/testing/sendTouchEvent.ts +0 -78
- package/src/toolbar/HTMLToolbar.ts +0 -492
- package/src/toolbar/IconProvider.ts +0 -736
- package/src/toolbar/lib.ts +0 -4
- package/src/toolbar/localization.ts +0 -106
- package/src/toolbar/makeColorInput.ts +0 -145
- package/src/toolbar/toolbar.css +0 -213
- package/src/toolbar/types.ts +0 -5
- package/src/toolbar/widgets/ActionButtonWidget.ts +0 -39
- package/src/toolbar/widgets/BaseToolWidget.ts +0 -56
- package/src/toolbar/widgets/BaseWidget.ts +0 -377
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +0 -167
- package/src/toolbar/widgets/EraserToolWidget.ts +0 -85
- package/src/toolbar/widgets/HandToolWidget.ts +0 -250
- package/src/toolbar/widgets/InsertImageWidget.css +0 -44
- package/src/toolbar/widgets/InsertImageWidget.ts +0 -223
- package/src/toolbar/widgets/OverflowWidget.css +0 -27
- package/src/toolbar/widgets/OverflowWidget.ts +0 -92
- package/src/toolbar/widgets/PenToolWidget.ts +0 -288
- package/src/toolbar/widgets/SelectionToolWidget.ts +0 -190
- package/src/toolbar/widgets/TextToolWidget.ts +0 -145
- package/src/toolbar/widgets/lib.ts +0 -13
- package/src/tools/BaseTool.ts +0 -76
- package/src/tools/Eraser.test.ts +0 -103
- package/src/tools/Eraser.ts +0 -139
- package/src/tools/FindTool.css +0 -7
- package/src/tools/FindTool.ts +0 -152
- package/src/tools/PanZoom.test.ts +0 -310
- package/src/tools/PanZoom.ts +0 -520
- package/src/tools/PasteHandler.ts +0 -95
- package/src/tools/Pen.test.ts +0 -194
- package/src/tools/Pen.ts +0 -226
- package/src/tools/PipetteTool.ts +0 -55
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +0 -28
- package/src/tools/SelectionTool/Selection.ts +0 -607
- package/src/tools/SelectionTool/SelectionHandle.ts +0 -108
- package/src/tools/SelectionTool/SelectionTool.css +0 -23
- package/src/tools/SelectionTool/SelectionTool.test.ts +0 -261
- package/src/tools/SelectionTool/SelectionTool.ts +0 -480
- package/src/tools/SelectionTool/TransformMode.ts +0 -114
- package/src/tools/SelectionTool/types.ts +0 -11
- package/src/tools/TextTool.ts +0 -326
- package/src/tools/ToolController.ts +0 -178
- package/src/tools/ToolEnabledGroup.ts +0 -14
- package/src/tools/ToolSwitcherShortcut.ts +0 -39
- package/src/tools/ToolbarShortcutHandler.ts +0 -34
- package/src/tools/UndoRedoShortcut.test.ts +0 -56
- package/src/tools/UndoRedoShortcut.ts +0 -25
- package/src/tools/lib.ts +0 -21
- package/src/tools/localization.ts +0 -66
- package/src/types.ts +0 -234
- package/src/util/assertions.ts +0 -55
- package/src/util/fileToBase64.ts +0 -18
- package/src/util/untilNextAnimationFrame.ts +0 -9
- package/src/util/waitForTimeout.ts +0 -9
@@ -1,99 +0,0 @@
|
|
1
|
-
import LineSegment2 from './LineSegment2';
|
2
|
-
import { Vec2 } from './Vec2';
|
3
|
-
import Mat33 from './Mat33';
|
4
|
-
|
5
|
-
|
6
|
-
describe('Line2', () => {
|
7
|
-
it('x and y axes should intersect at (0, 0)', () => {
|
8
|
-
const xAxis = new LineSegment2(Vec2.of(-10, 0), Vec2.of(10, 0));
|
9
|
-
const yAxis = new LineSegment2(Vec2.of(0, -10), Vec2.of(0, 10));
|
10
|
-
expect(xAxis.intersection(yAxis)?.point).objEq(Vec2.zero);
|
11
|
-
expect(yAxis.intersection(xAxis)?.point).objEq(Vec2.zero);
|
12
|
-
});
|
13
|
-
|
14
|
-
it('y = -2x + 2 and y = 2x - 2 should intersect at (1,0)', () => {
|
15
|
-
// y = -4x + 2
|
16
|
-
const line1 = new LineSegment2(Vec2.of(0, 2), Vec2.of(1, -2));
|
17
|
-
// y = 4x - 2
|
18
|
-
const line2 = new LineSegment2(Vec2.of(0, -2), Vec2.of(1, 2));
|
19
|
-
|
20
|
-
expect(line1.intersection(line2)?.point).objEq(Vec2.of(0.5, 0));
|
21
|
-
expect(line2.intersection(line1)?.point).objEq(Vec2.of(0.5, 0));
|
22
|
-
});
|
23
|
-
|
24
|
-
it('line from (10, 10) to (-100, 10) should intersect with the y-axis at t = 10', () => {
|
25
|
-
const line1 = new LineSegment2(Vec2.of(10, 10), Vec2.of(-10, 10));
|
26
|
-
// y = 2x - 2
|
27
|
-
const line2 = new LineSegment2(Vec2.of(0, -2), Vec2.of(0, 200));
|
28
|
-
|
29
|
-
expect(line1.intersection(line2)?.point).objEq(Vec2.of(0, 10));
|
30
|
-
|
31
|
-
// t=10 implies 10 units along he line from (10, 10) to (-10, 10)
|
32
|
-
expect(line1.intersection(line2)?.t).toBe(10);
|
33
|
-
|
34
|
-
// Similarly, t = 12 implies 12 units above (0, -2) in the direction of (0, 200)
|
35
|
-
expect(line2.intersection(line1)?.t).toBe(12);
|
36
|
-
});
|
37
|
-
|
38
|
-
it('y=2 and y=0 should not intersect', () => {
|
39
|
-
const line1 = new LineSegment2(Vec2.of(-10, 2), Vec2.of(10, 2));
|
40
|
-
const line2 = new LineSegment2(Vec2.of(-10, 0), Vec2.of(10, 0));
|
41
|
-
expect(line1.intersection(line2)).toBeNull();
|
42
|
-
expect(line2.intersection(line1)).toBeNull();
|
43
|
-
});
|
44
|
-
|
45
|
-
it('x=2 and x=-1 should not intersect', () => {
|
46
|
-
const line1 = new LineSegment2(Vec2.of(2, -10), Vec2.of(2, 10));
|
47
|
-
const line2 = new LineSegment2(Vec2.of(-1, 10), Vec2.of(-1, -10));
|
48
|
-
expect(line1.intersection(line2)).toBeNull();
|
49
|
-
expect(line2.intersection(line1)).toBeNull();
|
50
|
-
});
|
51
|
-
|
52
|
-
it('Line from (0, 0) to (1, 0) should not intersect line from (1.1, 0) to (2, 0)', () => {
|
53
|
-
const line1 = new LineSegment2(Vec2.of(0, 0), Vec2.of(1, 0));
|
54
|
-
const line2 = new LineSegment2(Vec2.of(1.1, 0), Vec2.of(2, 0));
|
55
|
-
expect(line1.intersection(line2)).toBeNull();
|
56
|
-
expect(line2.intersection(line1)).toBeNull();
|
57
|
-
});
|
58
|
-
|
59
|
-
it('Line segment from (1, 1) to (3, 1) should have length 2', () => {
|
60
|
-
const segment = new LineSegment2(Vec2.of(1, 1), Vec2.of(3, 1));
|
61
|
-
expect(segment.length).toBe(2);
|
62
|
-
});
|
63
|
-
|
64
|
-
it('(769.612,221.037)->(770.387,224.962) should not intersect (763.359,223.667)->(763.5493, 223.667)', () => {
|
65
|
-
// Points taken from issue observed directly in editor
|
66
|
-
const p1 = Vec2.of(769.6126045442547, 221.037877485765);
|
67
|
-
const p2 = Vec2.of(770.3873954557453, 224.962122514235);
|
68
|
-
const p3 = Vec2.of( 763.3590010920082, 223.66723995850086);
|
69
|
-
const p4 = Vec2.of(763.5494167642871, 223.66723995850086);
|
70
|
-
|
71
|
-
const line1 = new LineSegment2(p1, p2);
|
72
|
-
const line2 = new LineSegment2(p3, p4);
|
73
|
-
expect(line1.intersection(line2)).toBeNull();
|
74
|
-
expect(line2.intersection(line1)).toBeNull();
|
75
|
-
});
|
76
|
-
|
77
|
-
it('Closest point to (0,0) on the line x = 1 should be (1,0)', () => {
|
78
|
-
const line = new LineSegment2(Vec2.of(1, 100), Vec2.of(1, -100));
|
79
|
-
expect(line.closestPointTo(Vec2.zero)).objEq(Vec2.of(1, 0));
|
80
|
-
});
|
81
|
-
|
82
|
-
it('Closest point from (-1,-2) to segment((1,1) -> (2,4)) should be (1,1)', () => {
|
83
|
-
const line = new LineSegment2(Vec2.of(1, 1), Vec2.of(2, 4));
|
84
|
-
expect(line.closestPointTo(Vec2.of(-1, -2))).objEq(Vec2.of(1, 1));
|
85
|
-
});
|
86
|
-
|
87
|
-
it('Closest point from (5,8) to segment((1,1) -> (2,4)) should be (2,4)', () => {
|
88
|
-
const line = new LineSegment2(Vec2.of(1, 1), Vec2.of(2, 4));
|
89
|
-
expect(line.closestPointTo(Vec2.of(5, 8))).objEq(Vec2.of(2, 4));
|
90
|
-
});
|
91
|
-
|
92
|
-
it('Should translate when translated by a translation matrix', () => {
|
93
|
-
const line = new LineSegment2(Vec2.of(-1, 1), Vec2.of(2, 100));
|
94
|
-
expect(line.transformedBy(Mat33.translation(Vec2.of(1, -2)))).toMatchObject({
|
95
|
-
p1: Vec2.of(0, -1),
|
96
|
-
p2: Vec2.of(3, 98),
|
97
|
-
});
|
98
|
-
});
|
99
|
-
});
|
package/src/math/LineSegment2.ts
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
import Mat33 from './Mat33';
|
2
|
-
import Rect2 from './Rect2';
|
3
|
-
import { Vec2, Point2 } from './Vec2';
|
4
|
-
|
5
|
-
interface IntersectionResult {
|
6
|
-
point: Point2;
|
7
|
-
t: number;
|
8
|
-
}
|
9
|
-
|
10
|
-
export default class LineSegment2 {
|
11
|
-
// invariant: ||direction|| = 1
|
12
|
-
public readonly direction: Vec2;
|
13
|
-
public readonly length: number;
|
14
|
-
public readonly bbox;
|
15
|
-
|
16
|
-
public constructor(
|
17
|
-
private readonly point1: Point2,
|
18
|
-
private readonly point2: Point2
|
19
|
-
) {
|
20
|
-
this.bbox = Rect2.bboxOf([point1, point2]);
|
21
|
-
|
22
|
-
this.direction = point2.minus(point1);
|
23
|
-
this.length = this.direction.magnitude();
|
24
|
-
|
25
|
-
// Normalize
|
26
|
-
if (this.length > 0) {
|
27
|
-
this.direction = this.direction.times(1 / this.length);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
// Accessors to make LineSegment2 compatible with bezier-js's
|
32
|
-
// interface
|
33
|
-
public get p1(): Point2 {
|
34
|
-
return this.point1;
|
35
|
-
}
|
36
|
-
|
37
|
-
public get p2(): Point2 {
|
38
|
-
return this.point2;
|
39
|
-
}
|
40
|
-
|
41
|
-
public get(t: number): Point2 {
|
42
|
-
return this.point1.plus(this.direction.times(t));
|
43
|
-
}
|
44
|
-
|
45
|
-
public intersection(other: LineSegment2): IntersectionResult|null {
|
46
|
-
// We want x₁(t) = x₂(t) and y₁(t) = y₂(t)
|
47
|
-
// Observe that
|
48
|
-
// x = this.point1.x + this.direction.x · t₁
|
49
|
-
// = other.point1.x + other.direction.x · t₂
|
50
|
-
// Thus,
|
51
|
-
// t₁ = (x - this.point1.x) / this.direction.x
|
52
|
-
// = (y - this.point1.y) / this.direction.y
|
53
|
-
// and
|
54
|
-
// t₂ = (x - other.point1.x) / other.direction.x
|
55
|
-
// (and similarly for y)
|
56
|
-
//
|
57
|
-
// Letting o₁ₓ = this.point1.x, o₂ₓ = other.point1.x,
|
58
|
-
// d₁ᵧ = this.direction.y, ...
|
59
|
-
//
|
60
|
-
// We can substitute these into the equations for y:
|
61
|
-
// y = o₁ᵧ + d₁ᵧ · (x - o₁ₓ) / d₁ₓ
|
62
|
-
// = o₂ᵧ + d₂ᵧ · (x - o₂ₓ) / d₂ₓ
|
63
|
-
// ⇒ o₁ᵧ - o₂ᵧ = d₂ᵧ · (x - o₂ₓ) / d₂ₓ - d₁ᵧ · (x - o₁ₓ) / d₁ₓ
|
64
|
-
// = (d₂ᵧ/d₂ₓ)(x) - (d₂ᵧ/d₂ₓ)(o₂ₓ) - (d₁ᵧ/d₁ₓ)(x) + (d₁ᵧ/d₁ₓ)(o₁ₓ)
|
65
|
-
// = (x)(d₂ᵧ/d₂ₓ - d₁ᵧ/d₁ₓ) - (d₂ᵧ/d₂ₓ)(o₂ₓ) + (d₁ᵧ/d₁ₓ)(o₁ₓ)
|
66
|
-
// ⇒ (x)(d₂ᵧ/d₂ₓ - d₁ᵧ/d₁ₓ) = o₁ᵧ - o₂ᵧ + (d₂ᵧ/d₂ₓ)(o₂ₓ) - (d₁ᵧ/d₁ₓ)(o₁ₓ)
|
67
|
-
// ⇒ x = (o₁ᵧ - o₂ᵧ + (d₂ᵧ/d₂ₓ)(o₂ₓ) - (d₁ᵧ/d₁ₓ)(o₁ₓ))/(d₂ᵧ/d₂ₓ - d₁ᵧ/d₁ₓ)
|
68
|
-
// = (d₁ₓd₂ₓ)(o₁ᵧ - o₂ᵧ + (d₂ᵧ/d₂ₓ)(o₂ₓ) - (d₁ᵧ/d₁ₓ)(o₁ₓ))/(d₂ᵧd₁ₓ - d₁ᵧd₂ₓ)
|
69
|
-
// = ((o₁ᵧ - o₂ᵧ)((d₁ₓd₂ₓ)) + (d₂ᵧd₁ₓ)(o₂ₓ) - (d₁ᵧd₂ₓ)(o₁ₓ))/(d₂ᵧd₁ₓ - d₁ᵧd₂ₓ)
|
70
|
-
// ⇒ y = o₁ᵧ + d₁ᵧ · (x - o₁ₓ) / d₁ₓ = ...
|
71
|
-
let resultPoint, resultT;
|
72
|
-
if (this.direction.x === 0) {
|
73
|
-
// Vertical line: Where does the other have x = this.point1.x?
|
74
|
-
// x = o₁ₓ = o₂ₓ + d₂ₓ · (y - o₂ᵧ) / d₂ᵧ
|
75
|
-
// ⇒ (o₁ₓ - o₂ₓ)(d₂ᵧ/d₂ₓ) + o₂ᵧ = y
|
76
|
-
|
77
|
-
// Avoid division by zero
|
78
|
-
if (other.direction.x === 0 || this.direction.y === 0) {
|
79
|
-
return null;
|
80
|
-
}
|
81
|
-
|
82
|
-
const xIntersect = this.point1.x;
|
83
|
-
const yIntersect =
|
84
|
-
(this.point1.x - other.point1.x) * other.direction.y / other.direction.x + other.point1.y;
|
85
|
-
resultPoint = Vec2.of(xIntersect, yIntersect);
|
86
|
-
resultT = (yIntersect - this.point1.y) / this.direction.y;
|
87
|
-
} else {
|
88
|
-
// From above,
|
89
|
-
// x = ((o₁ᵧ - o₂ᵧ)(d₁ₓd₂ₓ) + (d₂ᵧd₁ₓ)(o₂ₓ) - (d₁ᵧd₂ₓ)(o₁ₓ))/(d₂ᵧd₁ₓ - d₁ᵧd₂ₓ)
|
90
|
-
const numerator = (
|
91
|
-
(this.point1.y - other.point1.y) * this.direction.x * other.direction.x
|
92
|
-
+ this.direction.x * other.direction.y * other.point1.x
|
93
|
-
- this.direction.y * other.direction.x * this.point1.x
|
94
|
-
);
|
95
|
-
const denominator = (
|
96
|
-
other.direction.y * this.direction.x
|
97
|
-
- this.direction.y * other.direction.x
|
98
|
-
);
|
99
|
-
|
100
|
-
// Avoid dividing by zero. It means there is no intersection
|
101
|
-
if (denominator === 0) {
|
102
|
-
return null;
|
103
|
-
}
|
104
|
-
|
105
|
-
const xIntersect = numerator / denominator;
|
106
|
-
const t1 = (xIntersect - this.point1.x) / this.direction.x;
|
107
|
-
const yIntersect = this.point1.y + this.direction.y * t1;
|
108
|
-
resultPoint = Vec2.of(xIntersect, yIntersect);
|
109
|
-
resultT = (xIntersect - this.point1.x) / this.direction.x;
|
110
|
-
}
|
111
|
-
|
112
|
-
// Ensure the result is in this/the other segment.
|
113
|
-
const resultToP1 = resultPoint.minus(this.point1).magnitude();
|
114
|
-
const resultToP2 = resultPoint.minus(this.point2).magnitude();
|
115
|
-
const resultToP3 = resultPoint.minus(other.point1).magnitude();
|
116
|
-
const resultToP4 = resultPoint.minus(other.point2).magnitude();
|
117
|
-
if (resultToP1 > this.length
|
118
|
-
|| resultToP2 > this.length
|
119
|
-
|| resultToP3 > other.length
|
120
|
-
|| resultToP4 > other.length) {
|
121
|
-
return null;
|
122
|
-
}
|
123
|
-
|
124
|
-
return {
|
125
|
-
point: resultPoint,
|
126
|
-
t: resultT,
|
127
|
-
};
|
128
|
-
}
|
129
|
-
|
130
|
-
public intersects(other: LineSegment2) {
|
131
|
-
return this.intersection(other) !== null;
|
132
|
-
}
|
133
|
-
|
134
|
-
// Returns the closest point on this to [target]
|
135
|
-
public closestPointTo(target: Point2) {
|
136
|
-
// Distance from P1 along this' direction.
|
137
|
-
const projectedDistFromP1 = target.minus(this.p1).dot(this.direction);
|
138
|
-
const projectedDistFromP2 = this.length - projectedDistFromP1;
|
139
|
-
|
140
|
-
const projection = this.p1.plus(this.direction.times(projectedDistFromP1));
|
141
|
-
|
142
|
-
if (projectedDistFromP1 > 0 && projectedDistFromP1 < this.length) {
|
143
|
-
return projection;
|
144
|
-
}
|
145
|
-
|
146
|
-
if (Math.abs(projectedDistFromP2) < Math.abs(projectedDistFromP1)) {
|
147
|
-
return this.p2;
|
148
|
-
} else {
|
149
|
-
return this.p1;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
public transformedBy(affineTransfm: Mat33): LineSegment2 {
|
154
|
-
return new LineSegment2(affineTransfm.transformVec2(this.p1), affineTransfm.transformVec2(this.p2));
|
155
|
-
}
|
156
|
-
|
157
|
-
public toString() {
|
158
|
-
return `LineSegment(${this.p1.toString()}, ${this.p2.toString()})`;
|
159
|
-
}
|
160
|
-
}
|
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
|
-
});
|