js-draw 0.18.1 → 0.18.2
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 +3 -0
- package/dist/cjs/src/Color4.d.ts +61 -0
- package/dist/cjs/src/Color4.js +197 -0
- package/dist/cjs/src/Editor.d.ts +308 -0
- package/dist/cjs/src/Editor.js +904 -0
- package/dist/cjs/src/EditorImage.d.ts +97 -0
- package/dist/cjs/src/EditorImage.js +486 -0
- package/dist/cjs/src/EventDispatcher.d.ts +30 -0
- package/dist/cjs/src/EventDispatcher.js +57 -0
- package/dist/cjs/src/Pointer.d.ts +24 -0
- package/dist/cjs/src/Pointer.js +84 -0
- package/dist/cjs/src/SVGLoader.d.ts +48 -0
- package/dist/cjs/src/SVGLoader.js +472 -0
- package/dist/cjs/src/UndoRedoHistory.d.ts +19 -0
- package/dist/cjs/src/UndoRedoHistory.js +93 -0
- package/dist/cjs/src/Viewport.d.ts +71 -0
- package/dist/cjs/src/Viewport.js +264 -0
- package/dist/cjs/src/bundle/bundled.d.ts +4 -0
- package/dist/cjs/src/bundle/bundled.js +24 -0
- package/dist/cjs/src/commands/Command.d.ts +16 -0
- package/dist/cjs/src/commands/Command.js +34 -0
- package/dist/cjs/src/commands/Duplicate.d.ts +14 -0
- package/dist/cjs/src/commands/Duplicate.js +39 -0
- package/dist/cjs/src/commands/Erase.d.ts +14 -0
- package/dist/cjs/src/commands/Erase.js +63 -0
- package/dist/cjs/src/commands/SerializableCommand.d.ts +12 -0
- package/dist/cjs/src/commands/SerializableCommand.js +42 -0
- package/dist/cjs/src/commands/UnresolvedCommand.d.ts +14 -0
- package/dist/cjs/src/commands/UnresolvedCommand.js +28 -0
- package/dist/cjs/src/commands/invertCommand.d.ts +4 -0
- package/dist/cjs/src/commands/invertCommand.js +49 -0
- package/dist/cjs/src/commands/lib.d.ts +7 -0
- package/dist/cjs/src/commands/lib.js +18 -0
- package/dist/cjs/src/commands/localization.d.ts +23 -0
- package/dist/cjs/src/commands/localization.js +24 -0
- package/dist/cjs/src/commands/uniteCommands.d.ts +4 -0
- package/dist/cjs/src/commands/uniteCommands.js +121 -0
- package/dist/cjs/src/components/AbstractComponent.d.ts +73 -0
- package/dist/cjs/src/components/AbstractComponent.js +258 -0
- package/dist/cjs/src/components/ImageBackground.d.ts +42 -0
- package/dist/cjs/src/components/ImageBackground.js +146 -0
- package/dist/cjs/src/components/ImageComponent.d.ts +31 -0
- package/dist/cjs/src/components/ImageComponent.js +152 -0
- package/dist/cjs/src/components/RestylableComponent.d.ts +24 -0
- package/dist/cjs/src/components/RestylableComponent.js +88 -0
- package/dist/cjs/src/components/SVGGlobalAttributesObject.d.ts +21 -0
- package/dist/cjs/src/components/SVGGlobalAttributesObject.js +65 -0
- package/dist/cjs/src/components/Stroke.d.ts +40 -0
- package/dist/cjs/src/components/Stroke.js +191 -0
- package/dist/cjs/src/components/TextComponent.d.ts +53 -0
- package/dist/cjs/src/components/TextComponent.js +258 -0
- package/dist/cjs/src/components/UnknownSVGObject.d.ts +18 -0
- package/dist/cjs/src/components/UnknownSVGObject.js +50 -0
- package/dist/cjs/src/components/builders/ArrowBuilder.d.ts +19 -0
- package/dist/cjs/src/components/builders/ArrowBuilder.js +117 -0
- package/dist/cjs/src/components/builders/FreehandLineBuilder.d.ts +33 -0
- package/dist/cjs/src/components/builders/FreehandLineBuilder.js +173 -0
- package/dist/cjs/src/components/builders/LineBuilder.d.ts +18 -0
- package/dist/cjs/src/components/builders/LineBuilder.js +89 -0
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +36 -0
- package/dist/cjs/src/components/builders/PressureSensitiveFreehandLineBuilder.js +347 -0
- package/dist/cjs/src/components/builders/RectangleBuilder.d.ts +20 -0
- package/dist/cjs/src/components/builders/RectangleBuilder.js +59 -0
- package/dist/cjs/src/components/builders/types.d.ts +12 -0
- package/dist/cjs/src/components/builders/types.js +2 -0
- package/dist/cjs/src/components/lib.d.ts +12 -0
- package/dist/cjs/src/components/lib.js +43 -0
- package/dist/cjs/src/components/localization.d.ts +11 -0
- package/dist/cjs/src/components/localization.js +13 -0
- package/dist/cjs/src/components/util/StrokeSmoother.d.ts +35 -0
- package/dist/cjs/src/components/util/StrokeSmoother.js +217 -0
- package/dist/cjs/src/components/util/describeComponentList.d.ts +4 -0
- package/dist/cjs/src/components/util/describeComponentList.js +16 -0
- package/dist/cjs/src/lib.d.ts +34 -0
- package/dist/cjs/src/lib.js +63 -0
- package/dist/cjs/src/localization.d.ts +14 -0
- package/dist/cjs/src/localization.js +13 -0
- package/dist/cjs/src/localizations/de.d.ts +3 -0
- package/dist/cjs/src/localizations/de.js +6 -0
- package/dist/cjs/src/localizations/en.d.ts +3 -0
- package/dist/cjs/src/localizations/en.js +6 -0
- package/dist/cjs/src/localizations/es.d.ts +3 -0
- package/dist/cjs/src/localizations/es.js +20 -0
- package/dist/cjs/src/localizations/getLocalizationTable.d.ts +3 -0
- package/dist/cjs/src/localizations/getLocalizationTable.js +50 -0
- package/dist/cjs/src/math/LineSegment2.d.ts +24 -0
- package/dist/cjs/src/math/LineSegment2.js +131 -0
- package/dist/cjs/src/math/Mat33.d.ts +118 -0
- package/dist/cjs/src/math/Mat33.js +332 -0
- package/dist/cjs/src/math/Path.d.ts +71 -0
- package/dist/cjs/src/math/Path.js +655 -0
- package/dist/cjs/src/math/Rect2.d.ts +52 -0
- package/dist/cjs/src/math/Rect2.js +234 -0
- package/dist/cjs/src/math/Triangle.d.ts +11 -0
- package/dist/cjs/src/math/Triangle.js +22 -0
- package/dist/cjs/src/math/Vec2.d.ts +13 -0
- package/dist/cjs/src/math/Vec2.js +19 -0
- package/dist/cjs/src/math/Vec3.d.ts +106 -0
- package/dist/cjs/src/math/Vec3.js +177 -0
- package/dist/cjs/src/math/lib.d.ts +7 -0
- package/dist/cjs/src/math/lib.js +18 -0
- package/dist/cjs/src/math/rounding.d.ts +4 -0
- package/dist/cjs/src/math/rounding.js +135 -0
- package/dist/cjs/src/rendering/Display.d.ts +75 -0
- package/dist/cjs/src/rendering/Display.js +214 -0
- package/dist/cjs/src/rendering/RenderingStyle.d.ts +31 -0
- package/dist/cjs/src/rendering/RenderingStyle.js +48 -0
- package/dist/cjs/src/rendering/TextRenderingStyle.d.ts +36 -0
- package/dist/cjs/src/rendering/TextRenderingStyle.js +29 -0
- package/dist/cjs/src/rendering/caching/CacheRecord.d.ts +20 -0
- package/dist/cjs/src/rendering/caching/CacheRecord.js +61 -0
- package/dist/cjs/src/rendering/caching/CacheRecordManager.d.ts +12 -0
- package/dist/cjs/src/rendering/caching/CacheRecordManager.js +50 -0
- package/dist/cjs/src/rendering/caching/RenderingCache.d.ts +11 -0
- package/dist/cjs/src/rendering/caching/RenderingCache.js +51 -0
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.d.ts +29 -0
- package/dist/cjs/src/rendering/caching/RenderingCacheNode.js +326 -0
- package/dist/cjs/src/rendering/caching/testUtils.d.ts +9 -0
- package/dist/cjs/src/rendering/caching/testUtils.js +27 -0
- package/dist/cjs/src/rendering/caching/types.d.ts +19 -0
- package/dist/cjs/src/rendering/caching/types.js +2 -0
- package/dist/cjs/src/rendering/lib.d.ts +5 -0
- package/dist/cjs/src/rendering/lib.js +17 -0
- package/dist/cjs/src/rendering/localization.d.ts +10 -0
- package/dist/cjs/src/rendering/localization.js +12 -0
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.d.ts +68 -0
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.js +170 -0
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.d.ts +63 -0
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.js +236 -0
- package/dist/cjs/src/rendering/renderers/DummyRenderer.d.ts +35 -0
- package/dist/cjs/src/rendering/renderers/DummyRenderer.js +112 -0
- package/dist/cjs/src/rendering/renderers/SVGRenderer.d.ts +57 -0
- package/dist/cjs/src/rendering/renderers/SVGRenderer.js +311 -0
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.d.ts +29 -0
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.js +63 -0
- package/dist/cjs/src/testing/beforeEachFile.d.ts +1 -0
- package/dist/cjs/src/testing/beforeEachFile.js +12 -0
- package/dist/cjs/src/testing/createEditor.d.ts +4 -0
- package/dist/cjs/src/testing/createEditor.js +14 -0
- package/dist/cjs/src/testing/lib.d.ts +2 -0
- package/dist/cjs/src/testing/lib.js +10 -0
- package/dist/cjs/src/testing/loadExpectExtensions.d.ts +2 -0
- package/dist/cjs/src/testing/loadExpectExtensions.js +28 -0
- package/dist/cjs/src/testing/sendPenEvent.d.ts +12 -0
- package/dist/cjs/src/testing/sendPenEvent.js +24 -0
- package/dist/cjs/src/testing/sendTouchEvent.d.ts +42 -0
- package/dist/cjs/src/testing/sendTouchEvent.js +87 -0
- package/dist/cjs/src/toolbar/HTMLToolbar.d.ts +103 -0
- package/dist/cjs/src/toolbar/HTMLToolbar.js +383 -0
- package/dist/cjs/src/toolbar/IconProvider.d.ts +62 -0
- package/dist/cjs/src/toolbar/IconProvider.js +660 -0
- package/dist/cjs/src/toolbar/lib.d.ts +3 -0
- package/dist/cjs/src/toolbar/lib.js +24 -0
- package/dist/cjs/src/toolbar/localization.d.ts +49 -0
- package/dist/cjs/src/toolbar/localization.js +51 -0
- package/dist/cjs/src/toolbar/makeColorInput.d.ts +6 -0
- package/dist/cjs/src/toolbar/makeColorInput.js +120 -0
- package/dist/cjs/src/toolbar/types.d.ts +4 -0
- package/dist/cjs/src/toolbar/types.js +2 -0
- package/dist/cjs/src/toolbar/widgets/ActionButtonWidget.d.ts +15 -0
- package/dist/cjs/src/toolbar/widgets/ActionButtonWidget.js +31 -0
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.d.ts +11 -0
- package/dist/cjs/src/toolbar/widgets/BaseToolWidget.js +50 -0
- package/dist/cjs/src/toolbar/widgets/BaseWidget.d.ts +72 -0
- package/dist/cjs/src/toolbar/widgets/BaseWidget.js +313 -0
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +18 -0
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +126 -0
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.d.ts +17 -0
- package/dist/cjs/src/toolbar/widgets/EraserToolWidget.js +63 -0
- package/dist/cjs/src/toolbar/widgets/HandToolWidget.d.ts +17 -0
- package/dist/cjs/src/toolbar/widgets/HandToolWidget.js +201 -0
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.d.ts +19 -0
- package/dist/cjs/src/toolbar/widgets/InsertImageWidget.js +176 -0
- package/dist/cjs/src/toolbar/widgets/OverflowWidget.d.ts +25 -0
- package/dist/cjs/src/toolbar/widgets/OverflowWidget.js +77 -0
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.d.ts +27 -0
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +226 -0
- package/dist/cjs/src/toolbar/widgets/SelectionToolWidget.d.ts +13 -0
- package/dist/cjs/src/toolbar/widgets/SelectionToolWidget.js +153 -0
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.d.ts +16 -0
- package/dist/cjs/src/toolbar/widgets/TextToolWidget.js +115 -0
- package/dist/cjs/src/toolbar/widgets/lib.d.ts +10 -0
- package/dist/cjs/src/toolbar/widgets/lib.js +26 -0
- package/dist/cjs/src/tools/BaseTool.d.ts +22 -0
- package/dist/cjs/src/tools/BaseTool.js +66 -0
- package/dist/cjs/src/tools/Eraser.d.ts +23 -0
- package/dist/cjs/src/tools/Eraser.js +112 -0
- package/dist/cjs/src/tools/FindTool.d.ts +21 -0
- package/dist/cjs/src/tools/FindTool.js +121 -0
- package/dist/cjs/src/tools/PanZoom.d.ts +52 -0
- package/dist/cjs/src/tools/PanZoom.js +421 -0
- package/dist/cjs/src/tools/PasteHandler.d.ts +23 -0
- package/dist/cjs/src/tools/PasteHandler.js +99 -0
- package/dist/cjs/src/tools/Pen.d.ts +39 -0
- package/dist/cjs/src/tools/Pen.js +179 -0
- package/dist/cjs/src/tools/PipetteTool.d.ts +18 -0
- package/dist/cjs/src/tools/PipetteTool.js +45 -0
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +8 -0
- package/dist/cjs/src/tools/SelectionTool/SelectAllShortcutHandler.js +28 -0
- package/dist/cjs/src/tools/SelectionTool/Selection.d.ts +64 -0
- package/dist/cjs/src/tools/SelectionTool/Selection.js +488 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionHandle.d.ts +38 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionHandle.js +85 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.d.ts +36 -0
- package/dist/cjs/src/tools/SelectionTool/SelectionTool.js +405 -0
- package/dist/cjs/src/tools/SelectionTool/TransformMode.d.ts +34 -0
- package/dist/cjs/src/tools/SelectionTool/TransformMode.js +107 -0
- package/dist/cjs/src/tools/SelectionTool/types.d.ts +9 -0
- package/dist/cjs/src/tools/SelectionTool/types.js +14 -0
- package/dist/cjs/src/tools/TextTool.d.ts +33 -0
- package/dist/cjs/src/tools/TextTool.js +262 -0
- package/dist/cjs/src/tools/ToolController.d.ts +18 -0
- package/dist/cjs/src/tools/ToolController.js +187 -0
- package/dist/cjs/src/tools/ToolEnabledGroup.d.ts +6 -0
- package/dist/cjs/src/tools/ToolEnabledGroup.js +14 -0
- package/dist/cjs/src/tools/ToolSwitcherShortcut.d.ts +16 -0
- package/dist/cjs/src/tools/ToolSwitcherShortcut.js +38 -0
- package/dist/cjs/src/tools/ToolbarShortcutHandler.d.ts +12 -0
- package/dist/cjs/src/tools/ToolbarShortcutHandler.js +29 -0
- package/dist/cjs/src/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/cjs/src/tools/UndoRedoShortcut.js +28 -0
- package/dist/cjs/src/tools/lib.d.ts +16 -0
- package/dist/cjs/src/tools/lib.js +36 -0
- package/dist/cjs/src/tools/localization.d.ts +28 -0
- package/dist/cjs/src/tools/localization.js +30 -0
- package/dist/cjs/src/types.d.ts +151 -0
- package/dist/cjs/src/types.js +38 -0
- package/dist/cjs/src/util/assertions.d.ts +23 -0
- package/dist/cjs/src/util/assertions.js +51 -0
- package/dist/cjs/src/util/fileToBase64.d.ts +3 -0
- package/dist/cjs/src/util/fileToBase64.js +15 -0
- package/dist/cjs/src/util/untilNextAnimationFrame.d.ts +3 -0
- package/dist/cjs/src/util/untilNextAnimationFrame.js +9 -0
- package/dist/cjs/src/util/waitForTimeout.d.ts +2 -0
- package/dist/cjs/src/util/waitForTimeout.js +9 -0
- package/dist/mjs/src/Color4.d.ts +61 -0
- package/dist/mjs/src/Color4.mjs +193 -0
- package/dist/mjs/src/Editor.d.ts +308 -0
- package/dist/mjs/src/Editor.mjs +874 -0
- package/dist/mjs/src/EditorImage.d.ts +97 -0
- package/dist/mjs/src/EditorImage.mjs +477 -0
- package/dist/mjs/src/EventDispatcher.d.ts +30 -0
- package/dist/mjs/src/EventDispatcher.mjs +54 -0
- package/dist/mjs/src/Pointer.d.ts +24 -0
- package/dist/mjs/src/Pointer.mjs +80 -0
- package/dist/mjs/src/SVGLoader.d.ts +48 -0
- package/dist/mjs/src/SVGLoader.mjs +442 -0
- package/dist/mjs/src/UndoRedoHistory.d.ts +19 -0
- package/dist/mjs/src/UndoRedoHistory.mjs +91 -0
- package/dist/mjs/src/Viewport.d.ts +71 -0
- package/dist/mjs/src/Viewport.mjs +256 -0
- package/dist/mjs/src/bundle/bundled.d.ts +4 -0
- package/dist/mjs/src/bundle/bundled.mjs +5 -0
- package/dist/mjs/src/commands/Command.d.ts +16 -0
- package/dist/mjs/src/commands/Command.mjs +30 -0
- package/dist/mjs/src/commands/Duplicate.d.ts +14 -0
- package/dist/mjs/src/commands/Duplicate.mjs +33 -0
- package/dist/mjs/src/commands/Erase.d.ts +14 -0
- package/dist/mjs/src/commands/Erase.mjs +57 -0
- package/dist/mjs/src/commands/SerializableCommand.d.ts +12 -0
- package/dist/mjs/src/commands/SerializableCommand.mjs +36 -0
- package/dist/mjs/src/commands/UnresolvedCommand.d.ts +14 -0
- package/dist/mjs/src/commands/UnresolvedCommand.mjs +22 -0
- package/dist/mjs/src/commands/invertCommand.d.ts +4 -0
- package/dist/mjs/src/commands/invertCommand.mjs +44 -0
- package/dist/mjs/src/commands/lib.d.ts +7 -0
- package/dist/mjs/src/commands/lib.mjs +7 -0
- package/dist/mjs/src/commands/localization.d.ts +23 -0
- package/dist/mjs/src/commands/localization.mjs +21 -0
- package/dist/mjs/src/commands/uniteCommands.d.ts +4 -0
- package/dist/mjs/src/commands/uniteCommands.mjs +116 -0
- package/dist/mjs/src/components/AbstractComponent.d.ts +73 -0
- package/dist/mjs/src/components/AbstractComponent.mjs +252 -0
- package/dist/mjs/src/components/ImageBackground.d.ts +42 -0
- package/dist/mjs/src/components/ImageBackground.mjs +139 -0
- package/dist/mjs/src/components/ImageComponent.d.ts +31 -0
- package/dist/mjs/src/components/ImageComponent.mjs +146 -0
- package/dist/mjs/src/components/RestylableComponent.d.ts +24 -0
- package/dist/mjs/src/components/RestylableComponent.mjs +80 -0
- package/dist/mjs/src/components/SVGGlobalAttributesObject.d.ts +21 -0
- package/dist/mjs/src/components/SVGGlobalAttributesObject.mjs +59 -0
- package/dist/mjs/src/components/Stroke.d.ts +40 -0
- package/dist/mjs/src/components/Stroke.mjs +185 -0
- package/dist/mjs/src/components/TextComponent.d.ts +53 -0
- package/dist/mjs/src/components/TextComponent.mjs +252 -0
- package/dist/mjs/src/components/UnknownSVGObject.d.ts +18 -0
- package/dist/mjs/src/components/UnknownSVGObject.mjs +44 -0
- package/dist/mjs/src/components/builders/ArrowBuilder.d.ts +19 -0
- package/dist/mjs/src/components/builders/ArrowBuilder.mjs +86 -0
- package/dist/mjs/src/components/builders/FreehandLineBuilder.d.ts +33 -0
- package/dist/mjs/src/components/builders/FreehandLineBuilder.mjs +165 -0
- package/dist/mjs/src/components/builders/LineBuilder.d.ts +18 -0
- package/dist/mjs/src/components/builders/LineBuilder.mjs +58 -0
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.d.ts +36 -0
- package/dist/mjs/src/components/builders/PressureSensitiveFreehandLineBuilder.mjs +339 -0
- package/dist/mjs/src/components/builders/RectangleBuilder.d.ts +20 -0
- package/dist/mjs/src/components/builders/RectangleBuilder.mjs +50 -0
- package/dist/mjs/src/components/builders/types.d.ts +12 -0
- package/dist/mjs/src/components/builders/types.mjs +1 -0
- package/dist/mjs/src/components/lib.d.ts +12 -0
- package/dist/mjs/src/components/lib.mjs +12 -0
- package/dist/mjs/src/components/localization.d.ts +11 -0
- package/dist/mjs/src/components/localization.mjs +10 -0
- package/dist/mjs/src/components/util/StrokeSmoother.d.ts +35 -0
- package/dist/mjs/src/components/util/StrokeSmoother.mjs +210 -0
- package/dist/mjs/src/components/util/describeComponentList.d.ts +4 -0
- package/dist/mjs/src/components/util/describeComponentList.mjs +14 -0
- package/dist/mjs/src/lib.d.ts +34 -0
- package/dist/mjs/src/lib.mjs +34 -0
- package/dist/mjs/src/localization.d.ts +14 -0
- package/dist/mjs/src/localization.mjs +10 -0
- package/dist/mjs/src/localizations/de.d.ts +3 -0
- package/dist/mjs/src/localizations/de.mjs +4 -0
- package/dist/mjs/src/localizations/en.d.ts +3 -0
- package/dist/mjs/src/localizations/en.mjs +4 -0
- package/dist/mjs/src/localizations/es.d.ts +3 -0
- package/dist/mjs/src/localizations/es.mjs +18 -0
- package/dist/mjs/src/localizations/getLocalizationTable.d.ts +3 -0
- package/dist/mjs/src/localizations/getLocalizationTable.mjs +45 -0
- package/dist/mjs/src/math/LineSegment2.d.ts +24 -0
- package/dist/mjs/src/math/LineSegment2.mjs +125 -0
- package/dist/mjs/src/math/Mat33.d.ts +118 -0
- package/dist/mjs/src/math/Mat33.mjs +326 -0
- package/dist/mjs/src/math/Path.d.ts +71 -0
- package/dist/mjs/src/math/Path.mjs +648 -0
- package/dist/mjs/src/math/Rect2.d.ts +52 -0
- package/dist/mjs/src/math/Rect2.mjs +228 -0
- package/dist/mjs/src/math/Triangle.d.ts +11 -0
- package/dist/mjs/src/math/Triangle.mjs +19 -0
- package/dist/mjs/src/math/Vec2.d.ts +13 -0
- package/dist/mjs/src/math/Vec2.mjs +13 -0
- package/dist/mjs/src/math/Vec3.d.ts +106 -0
- package/dist/mjs/src/math/Vec3.mjs +174 -0
- package/dist/mjs/src/math/lib.d.ts +7 -0
- package/dist/mjs/src/math/lib.mjs +7 -0
- package/dist/mjs/src/math/rounding.d.ts +4 -0
- package/dist/mjs/src/math/rounding.mjs +128 -0
- package/dist/mjs/src/rendering/Display.d.ts +75 -0
- package/dist/mjs/src/rendering/Display.mjs +207 -0
- package/dist/mjs/src/rendering/RenderingStyle.d.ts +31 -0
- package/dist/mjs/src/rendering/RenderingStyle.mjs +38 -0
- package/dist/mjs/src/rendering/TextRenderingStyle.d.ts +36 -0
- package/dist/mjs/src/rendering/TextRenderingStyle.mjs +23 -0
- package/dist/mjs/src/rendering/caching/CacheRecord.d.ts +20 -0
- package/dist/mjs/src/rendering/caching/CacheRecord.mjs +55 -0
- package/dist/mjs/src/rendering/caching/CacheRecordManager.d.ts +12 -0
- package/dist/mjs/src/rendering/caching/CacheRecordManager.mjs +43 -0
- package/dist/mjs/src/rendering/caching/RenderingCache.d.ts +11 -0
- package/dist/mjs/src/rendering/caching/RenderingCache.mjs +45 -0
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.d.ts +29 -0
- package/dist/mjs/src/rendering/caching/RenderingCacheNode.mjs +320 -0
- package/dist/mjs/src/rendering/caching/testUtils.d.ts +9 -0
- package/dist/mjs/src/rendering/caching/testUtils.mjs +20 -0
- package/dist/mjs/src/rendering/caching/types.d.ts +19 -0
- package/dist/mjs/src/rendering/caching/types.mjs +1 -0
- package/dist/mjs/src/rendering/lib.d.ts +5 -0
- package/dist/mjs/src/rendering/lib.mjs +5 -0
- package/dist/mjs/src/rendering/localization.d.ts +10 -0
- package/dist/mjs/src/rendering/localization.mjs +9 -0
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.d.ts +68 -0
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.mjs +144 -0
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.d.ts +63 -0
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.mjs +230 -0
- package/dist/mjs/src/rendering/renderers/DummyRenderer.d.ts +35 -0
- package/dist/mjs/src/rendering/renderers/DummyRenderer.mjs +106 -0
- package/dist/mjs/src/rendering/renderers/SVGRenderer.d.ts +57 -0
- package/dist/mjs/src/rendering/renderers/SVGRenderer.mjs +304 -0
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.d.ts +29 -0
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.mjs +57 -0
- package/dist/mjs/src/testing/beforeEachFile.d.ts +1 -0
- package/dist/mjs/src/testing/beforeEachFile.mjs +7 -0
- package/dist/mjs/src/testing/createEditor.d.ts +4 -0
- package/dist/mjs/src/testing/createEditor.mjs +9 -0
- package/dist/mjs/src/testing/lib.d.ts +2 -0
- package/dist/mjs/src/testing/lib.mjs +2 -0
- package/dist/mjs/src/testing/loadExpectExtensions.d.ts +2 -0
- package/dist/mjs/src/testing/loadExpectExtensions.mjs +24 -0
- package/dist/mjs/src/testing/sendPenEvent.d.ts +12 -0
- package/dist/mjs/src/testing/sendPenEvent.mjs +19 -0
- package/dist/mjs/src/testing/sendTouchEvent.d.ts +42 -0
- package/dist/mjs/src/testing/sendTouchEvent.mjs +62 -0
- package/dist/mjs/src/toolbar/HTMLToolbar.d.ts +103 -0
- package/dist/mjs/src/toolbar/HTMLToolbar.mjs +376 -0
- package/dist/mjs/src/toolbar/IconProvider.d.ts +62 -0
- package/dist/mjs/src/toolbar/IconProvider.mjs +654 -0
- package/dist/mjs/src/toolbar/lib.d.ts +3 -0
- package/dist/mjs/src/toolbar/lib.mjs +3 -0
- package/dist/mjs/src/toolbar/localization.d.ts +49 -0
- package/dist/mjs/src/toolbar/localization.mjs +48 -0
- package/dist/mjs/src/toolbar/makeColorInput.d.ts +6 -0
- package/dist/mjs/src/toolbar/makeColorInput.mjs +113 -0
- package/dist/mjs/src/toolbar/types.d.ts +4 -0
- package/dist/mjs/src/toolbar/types.mjs +1 -0
- package/dist/mjs/src/toolbar/widgets/ActionButtonWidget.d.ts +15 -0
- package/dist/mjs/src/toolbar/widgets/ActionButtonWidget.mjs +25 -0
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.d.ts +11 -0
- package/dist/mjs/src/toolbar/widgets/BaseToolWidget.mjs +44 -0
- package/dist/mjs/src/toolbar/widgets/BaseWidget.d.ts +72 -0
- package/dist/mjs/src/toolbar/widgets/BaseWidget.mjs +307 -0
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +18 -0
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs +120 -0
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.d.ts +17 -0
- package/dist/mjs/src/toolbar/widgets/EraserToolWidget.mjs +57 -0
- package/dist/mjs/src/toolbar/widgets/HandToolWidget.d.ts +17 -0
- package/dist/mjs/src/toolbar/widgets/HandToolWidget.mjs +172 -0
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.d.ts +19 -0
- package/dist/mjs/src/toolbar/widgets/InsertImageWidget.mjs +170 -0
- package/dist/mjs/src/toolbar/widgets/OverflowWidget.d.ts +25 -0
- package/dist/mjs/src/toolbar/widgets/OverflowWidget.mjs +71 -0
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.d.ts +27 -0
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.mjs +220 -0
- package/dist/mjs/src/toolbar/widgets/SelectionToolWidget.d.ts +13 -0
- package/dist/mjs/src/toolbar/widgets/SelectionToolWidget.mjs +147 -0
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.d.ts +16 -0
- package/dist/mjs/src/toolbar/widgets/TextToolWidget.mjs +109 -0
- package/dist/mjs/src/toolbar/widgets/lib.d.ts +10 -0
- package/dist/mjs/src/toolbar/widgets/lib.mjs +10 -0
- package/dist/mjs/src/tools/BaseTool.d.ts +22 -0
- package/dist/mjs/src/tools/BaseTool.mjs +63 -0
- package/dist/mjs/src/tools/Eraser.d.ts +23 -0
- package/dist/mjs/src/tools/Eraser.mjs +106 -0
- package/dist/mjs/src/tools/FindTool.d.ts +21 -0
- package/dist/mjs/src/tools/FindTool.mjs +114 -0
- package/dist/mjs/src/tools/PanZoom.d.ts +52 -0
- package/dist/mjs/src/tools/PanZoom.mjs +414 -0
- package/dist/mjs/src/tools/PasteHandler.d.ts +23 -0
- package/dist/mjs/src/tools/PasteHandler.mjs +93 -0
- package/dist/mjs/src/tools/Pen.d.ts +39 -0
- package/dist/mjs/src/tools/Pen.mjs +173 -0
- package/dist/mjs/src/tools/PipetteTool.d.ts +18 -0
- package/dist/mjs/src/tools/PipetteTool.mjs +39 -0
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.d.ts +8 -0
- package/dist/mjs/src/tools/SelectionTool/SelectAllShortcutHandler.mjs +22 -0
- package/dist/mjs/src/tools/SelectionTool/Selection.d.ts +64 -0
- package/dist/mjs/src/tools/SelectionTool/Selection.mjs +459 -0
- package/dist/mjs/src/tools/SelectionTool/SelectionHandle.d.ts +38 -0
- package/dist/mjs/src/tools/SelectionTool/SelectionHandle.mjs +81 -0
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.d.ts +36 -0
- package/dist/mjs/src/tools/SelectionTool/SelectionTool.mjs +398 -0
- package/dist/mjs/src/tools/SelectionTool/TransformMode.d.ts +34 -0
- package/dist/mjs/src/tools/SelectionTool/TransformMode.mjs +98 -0
- package/dist/mjs/src/tools/SelectionTool/types.d.ts +9 -0
- package/dist/mjs/src/tools/SelectionTool/types.mjs +11 -0
- package/dist/mjs/src/tools/TextTool.d.ts +33 -0
- package/dist/mjs/src/tools/TextTool.mjs +256 -0
- package/dist/mjs/src/tools/ToolController.d.ts +18 -0
- package/dist/mjs/src/tools/ToolController.mjs +158 -0
- package/dist/mjs/src/tools/ToolEnabledGroup.d.ts +6 -0
- package/dist/mjs/src/tools/ToolEnabledGroup.mjs +11 -0
- package/dist/mjs/src/tools/ToolSwitcherShortcut.d.ts +16 -0
- package/dist/mjs/src/tools/ToolSwitcherShortcut.mjs +32 -0
- package/dist/mjs/src/tools/ToolbarShortcutHandler.d.ts +12 -0
- package/dist/mjs/src/tools/ToolbarShortcutHandler.mjs +23 -0
- package/dist/mjs/src/tools/UndoRedoShortcut.d.ts +8 -0
- package/dist/mjs/src/tools/UndoRedoShortcut.mjs +22 -0
- package/dist/mjs/src/tools/lib.d.ts +16 -0
- package/dist/mjs/src/tools/lib.mjs +16 -0
- package/dist/mjs/src/tools/localization.d.ts +28 -0
- package/dist/mjs/src/tools/localization.mjs +27 -0
- package/dist/mjs/src/types.d.ts +151 -0
- package/dist/mjs/src/types.mjs +35 -0
- package/dist/mjs/src/util/assertions.d.ts +23 -0
- package/dist/mjs/src/util/assertions.mjs +45 -0
- package/dist/mjs/src/util/fileToBase64.d.ts +3 -0
- package/dist/mjs/src/util/fileToBase64.mjs +13 -0
- package/dist/mjs/src/util/untilNextAnimationFrame.d.ts +3 -0
- package/dist/mjs/src/util/untilNextAnimationFrame.mjs +7 -0
- package/dist/mjs/src/util/waitForTimeout.d.ts +2 -0
- package/dist/mjs/src/util/waitForTimeout.mjs +7 -0
- package/package.json +1 -1
- package/src/Color4.test.ts +40 -0
- package/src/Color4.ts +236 -0
- package/src/Editor.css +86 -0
- package/src/Editor.loadFrom.test.ts +24 -0
- package/src/Editor.toSVG.test.ts +111 -0
- package/src/Editor.ts +1122 -0
- package/src/EditorImage.test.ts +120 -0
- package/src/EditorImage.ts +603 -0
- package/src/EventDispatcher.test.ts +123 -0
- package/src/EventDispatcher.ts +71 -0
- package/src/Pointer.ts +127 -0
- package/src/SVGLoader.test.ts +114 -0
- package/src/SVGLoader.ts +511 -0
- package/src/UndoRedoHistory.test.ts +33 -0
- package/src/UndoRedoHistory.ts +102 -0
- package/src/Viewport.ts +319 -0
- package/src/bundle/bundled.ts +7 -0
- package/src/commands/Command.ts +45 -0
- package/src/commands/Duplicate.ts +48 -0
- package/src/commands/Erase.ts +74 -0
- package/src/commands/SerializableCommand.ts +49 -0
- package/src/commands/UnresolvedCommand.ts +37 -0
- package/src/commands/invertCommand.ts +51 -0
- package/src/commands/lib.ts +16 -0
- package/src/commands/localization.ts +47 -0
- package/src/commands/uniteCommands.test.ts +23 -0
- package/src/commands/uniteCommands.ts +135 -0
- package/src/components/AbstractComponent.transformBy.test.ts +22 -0
- package/src/components/AbstractComponent.ts +364 -0
- package/src/components/ImageBackground.test.ts +35 -0
- package/src/components/ImageBackground.ts +176 -0
- package/src/components/ImageComponent.ts +171 -0
- package/src/components/RestylableComponent.ts +142 -0
- package/src/components/SVGGlobalAttributesObject.ts +81 -0
- package/src/components/Stroke.test.ts +139 -0
- package/src/components/Stroke.ts +245 -0
- package/src/components/TextComponent.test.ts +99 -0
- package/src/components/TextComponent.ts +315 -0
- package/src/components/UnknownSVGObject.test.ts +10 -0
- package/src/components/UnknownSVGObject.ts +60 -0
- package/src/components/builders/ArrowBuilder.ts +107 -0
- package/src/components/builders/FreehandLineBuilder.ts +212 -0
- package/src/components/builders/LineBuilder.ts +77 -0
- package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +454 -0
- package/src/components/builders/RectangleBuilder.ts +74 -0
- package/src/components/builders/types.ts +15 -0
- package/src/components/lib.ts +25 -0
- package/src/components/localization.ts +22 -0
- package/src/components/util/StrokeSmoother.ts +293 -0
- package/src/components/util/describeComponentList.ts +18 -0
- package/src/lib.ts +37 -0
- package/src/localization.ts +34 -0
- package/src/localizations/de.ts +98 -0
- package/src/localizations/en.ts +8 -0
- package/src/localizations/es.ts +74 -0
- package/src/localizations/getLocalizationTable.test.ts +27 -0
- package/src/localizations/getLocalizationTable.ts +55 -0
- package/src/math/LineSegment2.test.ts +99 -0
- package/src/math/LineSegment2.ts +160 -0
- package/src/math/Mat33.test.ts +244 -0
- package/src/math/Mat33.ts +437 -0
- package/src/math/Path.fromString.test.ts +223 -0
- package/src/math/Path.test.ts +198 -0
- package/src/math/Path.toString.test.ts +77 -0
- package/src/math/Path.ts +790 -0
- package/src/math/Rect2.test.ts +204 -0
- package/src/math/Rect2.ts +315 -0
- package/src/math/Triangle.ts +29 -0
- package/src/math/Vec2.test.ts +30 -0
- package/src/math/Vec2.ts +18 -0
- package/src/math/Vec3.test.ts +44 -0
- package/src/math/Vec3.ts +218 -0
- package/src/math/lib.ts +15 -0
- package/src/math/rounding.test.ts +65 -0
- package/src/math/rounding.ts +156 -0
- package/src/rendering/Display.ts +249 -0
- package/src/rendering/RenderingStyle.test.ts +68 -0
- package/src/rendering/RenderingStyle.ts +55 -0
- package/src/rendering/TextRenderingStyle.ts +45 -0
- package/src/rendering/caching/CacheRecord.test.ts +49 -0
- package/src/rendering/caching/CacheRecord.ts +77 -0
- package/src/rendering/caching/CacheRecordManager.ts +71 -0
- package/src/rendering/caching/RenderingCache.test.ts +44 -0
- package/src/rendering/caching/RenderingCache.ts +66 -0
- package/src/rendering/caching/RenderingCacheNode.ts +405 -0
- package/src/rendering/caching/testUtils.ts +35 -0
- package/src/rendering/caching/types.ts +34 -0
- package/src/rendering/lib.ts +6 -0
- package/src/rendering/localization.ts +20 -0
- package/src/rendering/renderers/AbstractRenderer.ts +222 -0
- package/src/rendering/renderers/CanvasRenderer.ts +296 -0
- package/src/rendering/renderers/DummyRenderer.test.ts +42 -0
- package/src/rendering/renderers/DummyRenderer.ts +136 -0
- package/src/rendering/renderers/SVGRenderer.ts +354 -0
- package/src/rendering/renderers/TextOnlyRenderer.ts +70 -0
- package/src/styles.js +7 -0
- package/src/testing/beforeEachFile.ts +8 -0
- package/src/testing/createEditor.ts +11 -0
- package/src/testing/global.d.ts +17 -0
- package/src/testing/lib.ts +3 -0
- package/src/testing/loadExpectExtensions.ts +25 -0
- package/src/testing/sendPenEvent.ts +31 -0
- package/src/testing/sendTouchEvent.ts +78 -0
- package/src/toolbar/HTMLToolbar.ts +492 -0
- package/src/toolbar/IconProvider.ts +736 -0
- package/src/toolbar/lib.ts +4 -0
- package/src/toolbar/localization.ts +106 -0
- package/src/toolbar/makeColorInput.ts +145 -0
- package/src/toolbar/toolbar.css +213 -0
- package/src/toolbar/types.ts +5 -0
- package/src/toolbar/widgets/ActionButtonWidget.ts +39 -0
- package/src/toolbar/widgets/BaseToolWidget.ts +56 -0
- package/src/toolbar/widgets/BaseWidget.ts +377 -0
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +167 -0
- package/src/toolbar/widgets/EraserToolWidget.ts +85 -0
- package/src/toolbar/widgets/HandToolWidget.ts +250 -0
- package/src/toolbar/widgets/InsertImageWidget.css +44 -0
- package/src/toolbar/widgets/InsertImageWidget.ts +223 -0
- package/src/toolbar/widgets/OverflowWidget.css +27 -0
- package/src/toolbar/widgets/OverflowWidget.ts +92 -0
- package/src/toolbar/widgets/PenToolWidget.ts +288 -0
- package/src/toolbar/widgets/SelectionToolWidget.ts +190 -0
- package/src/toolbar/widgets/TextToolWidget.ts +145 -0
- package/src/toolbar/widgets/lib.ts +13 -0
- package/src/tools/BaseTool.ts +76 -0
- package/src/tools/Eraser.test.ts +103 -0
- package/src/tools/Eraser.ts +139 -0
- package/src/tools/FindTool.css +7 -0
- package/src/tools/FindTool.ts +152 -0
- package/src/tools/PanZoom.test.ts +310 -0
- package/src/tools/PanZoom.ts +520 -0
- package/src/tools/PasteHandler.ts +95 -0
- package/src/tools/Pen.test.ts +194 -0
- package/src/tools/Pen.ts +226 -0
- package/src/tools/PipetteTool.ts +55 -0
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +28 -0
- package/src/tools/SelectionTool/Selection.ts +607 -0
- package/src/tools/SelectionTool/SelectionHandle.ts +108 -0
- package/src/tools/SelectionTool/SelectionTool.css +23 -0
- package/src/tools/SelectionTool/SelectionTool.test.ts +261 -0
- package/src/tools/SelectionTool/SelectionTool.ts +480 -0
- package/src/tools/SelectionTool/TransformMode.ts +114 -0
- package/src/tools/SelectionTool/types.ts +11 -0
- package/src/tools/TextTool.ts +326 -0
- package/src/tools/ToolController.ts +178 -0
- package/src/tools/ToolEnabledGroup.ts +14 -0
- package/src/tools/ToolSwitcherShortcut.ts +39 -0
- package/src/tools/ToolbarShortcutHandler.ts +34 -0
- package/src/tools/UndoRedoShortcut.test.ts +56 -0
- package/src/tools/UndoRedoShortcut.ts +25 -0
- package/src/tools/lib.ts +21 -0
- package/src/tools/localization.ts +66 -0
- package/src/types.ts +234 -0
- package/src/util/assertions.ts +55 -0
- package/src/util/fileToBase64.ts +18 -0
- package/src/util/untilNextAnimationFrame.ts +9 -0
- package/src/util/waitForTimeout.ts +9 -0
@@ -0,0 +1,99 @@
|
|
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
|
+
});
|
@@ -0,0 +1,160 @@
|
|
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
|
+
}
|
@@ -0,0 +1,244 @@
|
|
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
|
+
});
|