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,437 @@
|
|
1
|
+
import { Point2, Vec2 } from './Vec2';
|
2
|
+
import Vec3 from './Vec3';
|
3
|
+
|
4
|
+
export type Mat33Array = [
|
5
|
+
number, number, number,
|
6
|
+
number, number, number,
|
7
|
+
number, number, number,
|
8
|
+
];
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Represents a three dimensional linear transformation or
|
12
|
+
* a two-dimensional affine transformation. (An affine transformation scales/rotates/shears
|
13
|
+
* **and** translates while a linear transformation just scales/rotates/shears).
|
14
|
+
*/
|
15
|
+
export default class Mat33 {
|
16
|
+
private readonly rows: Vec3[];
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Creates a matrix from inputs in the form,
|
20
|
+
* ```
|
21
|
+
* ⎡ a1 a2 a3 ⎤
|
22
|
+
* ⎢ b1 b2 b3 ⎥
|
23
|
+
* ⎣ c1 c2 c3 ⎦
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
public constructor(
|
27
|
+
public readonly a1: number,
|
28
|
+
public readonly a2: number,
|
29
|
+
public readonly a3: number,
|
30
|
+
|
31
|
+
public readonly b1: number,
|
32
|
+
public readonly b2: number,
|
33
|
+
public readonly b3: number,
|
34
|
+
|
35
|
+
public readonly c1: number,
|
36
|
+
public readonly c2: number,
|
37
|
+
public readonly c3: number
|
38
|
+
) {
|
39
|
+
this.rows = [
|
40
|
+
Vec3.of(a1, a2, a3),
|
41
|
+
Vec3.of(b1, b2, b3),
|
42
|
+
Vec3.of(c1, c2, c3),
|
43
|
+
];
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Creates a matrix from the given rows:
|
48
|
+
* ```
|
49
|
+
* ⎡ r1.x r1.y r1.z ⎤
|
50
|
+
* ⎢ r2.x r2.y r2.z ⎥
|
51
|
+
* ⎣ r3.x r3.y r3.z ⎦
|
52
|
+
* ```
|
53
|
+
*/
|
54
|
+
public static ofRows(r1: Vec3, r2: Vec3, r3: Vec3): Mat33 {
|
55
|
+
return new Mat33(
|
56
|
+
r1.x, r1.y, r1.z,
|
57
|
+
r2.x, r2.y, r2.z,
|
58
|
+
r3.x, r3.y, r3.z
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
public static identity = new Mat33(
|
63
|
+
1, 0, 0,
|
64
|
+
0, 1, 0,
|
65
|
+
0, 0, 1
|
66
|
+
);
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Either returns the inverse of this, or, if this matrix is singular/uninvertable,
|
70
|
+
* returns Mat33.identity.
|
71
|
+
*
|
72
|
+
* This may cache the computed inverse and return the cached version instead of recomputing
|
73
|
+
* it.
|
74
|
+
*/
|
75
|
+
public inverse(): Mat33 {
|
76
|
+
return this.computeInverse() ?? Mat33.identity;
|
77
|
+
}
|
78
|
+
|
79
|
+
public invertable(): boolean {
|
80
|
+
return this.computeInverse() !== null;
|
81
|
+
}
|
82
|
+
|
83
|
+
private cachedInverse: Mat33|undefined|null = undefined;
|
84
|
+
private computeInverse(): Mat33|null {
|
85
|
+
if (this.cachedInverse !== undefined) {
|
86
|
+
return this.cachedInverse;
|
87
|
+
}
|
88
|
+
|
89
|
+
const toIdentity = [
|
90
|
+
this.rows[0],
|
91
|
+
this.rows[1],
|
92
|
+
this.rows[2],
|
93
|
+
];
|
94
|
+
|
95
|
+
const toResult = [
|
96
|
+
Vec3.unitX,
|
97
|
+
Vec3.unitY,
|
98
|
+
Vec3.unitZ,
|
99
|
+
];
|
100
|
+
|
101
|
+
// Convert toIdentity to the identity matrix and
|
102
|
+
// toResult to the inverse through elementary row operations
|
103
|
+
for (let cursor = 0; cursor < 3; cursor++) {
|
104
|
+
// Select the [cursor]th diagonal entry
|
105
|
+
let pivot = toIdentity[cursor].at(cursor);
|
106
|
+
|
107
|
+
// Don't divide by zero (treat very small numbers as zero).
|
108
|
+
const minDivideBy = 1e-10;
|
109
|
+
if (Math.abs(pivot) < minDivideBy) {
|
110
|
+
let swapIndex = -1;
|
111
|
+
// For all other rows,
|
112
|
+
for (let i = 1; i <= 2; i++) {
|
113
|
+
const otherRowIdx = (cursor + i) % 3;
|
114
|
+
|
115
|
+
if (Math.abs(toIdentity[otherRowIdx].at(cursor)) >= minDivideBy) {
|
116
|
+
swapIndex = otherRowIdx;
|
117
|
+
break;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
// Can't swap with another row?
|
122
|
+
if (swapIndex === -1) {
|
123
|
+
this.cachedInverse = null;
|
124
|
+
return null;
|
125
|
+
}
|
126
|
+
|
127
|
+
const tmpIdentityRow = toIdentity[cursor];
|
128
|
+
const tmpResultRow = toResult[cursor];
|
129
|
+
|
130
|
+
// Swap!
|
131
|
+
toIdentity[cursor] = toIdentity[swapIndex];
|
132
|
+
toResult[cursor] = toResult[swapIndex];
|
133
|
+
toIdentity[swapIndex] = tmpIdentityRow;
|
134
|
+
toResult[swapIndex] = tmpResultRow;
|
135
|
+
|
136
|
+
pivot = toIdentity[cursor].at(cursor);
|
137
|
+
}
|
138
|
+
|
139
|
+
// Make toIdentity[k = cursor] = 1
|
140
|
+
let scale = 1.0 / pivot;
|
141
|
+
toIdentity[cursor] = toIdentity[cursor].times(scale);
|
142
|
+
toResult[cursor] = toResult[cursor].times(scale);
|
143
|
+
|
144
|
+
const cursorToIdentityRow = toIdentity[cursor];
|
145
|
+
const cursorToResultRow = toResult[cursor];
|
146
|
+
|
147
|
+
// Make toIdentity[k ≠ cursor] = 0
|
148
|
+
for (let i = 1; i <= 2; i++) {
|
149
|
+
const otherRowIdx = (cursor + i) % 3;
|
150
|
+
scale = -toIdentity[otherRowIdx].at(cursor);
|
151
|
+
toIdentity[otherRowIdx] = toIdentity[otherRowIdx].plus(
|
152
|
+
cursorToIdentityRow.times(scale)
|
153
|
+
);
|
154
|
+
toResult[otherRowIdx] = toResult[otherRowIdx].plus(
|
155
|
+
cursorToResultRow.times(scale)
|
156
|
+
);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
const inverse = Mat33.ofRows(
|
161
|
+
toResult[0],
|
162
|
+
toResult[1],
|
163
|
+
toResult[2]
|
164
|
+
);
|
165
|
+
this.cachedInverse = inverse;
|
166
|
+
return inverse;
|
167
|
+
}
|
168
|
+
|
169
|
+
public transposed(): Mat33 {
|
170
|
+
return new Mat33(
|
171
|
+
this.a1, this.b1, this.c1,
|
172
|
+
this.a2, this.b2, this.c2,
|
173
|
+
this.a3, this.b3, this.c3
|
174
|
+
);
|
175
|
+
}
|
176
|
+
|
177
|
+
public rightMul(other: Mat33): Mat33 {
|
178
|
+
other = other.transposed();
|
179
|
+
|
180
|
+
const at = (row: number, col: number): number => {
|
181
|
+
return this.rows[row].dot(other.rows[col]);
|
182
|
+
};
|
183
|
+
|
184
|
+
return new Mat33(
|
185
|
+
at(0, 0), at(0, 1), at(0, 2),
|
186
|
+
at(1, 0), at(1, 1), at(1, 2),
|
187
|
+
at(2, 0), at(2, 1), at(2, 2)
|
188
|
+
);
|
189
|
+
}
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Applies this as an affine transformation to the given vector.
|
193
|
+
* Returns a transformed version of `other`.
|
194
|
+
*/
|
195
|
+
public transformVec2(other: Vec2): Vec2 {
|
196
|
+
// When transforming a Vec2, we want to use the z transformation
|
197
|
+
// components of this for translation:
|
198
|
+
// ⎡ . . tX ⎤
|
199
|
+
// ⎢ . . tY ⎥
|
200
|
+
// ⎣ 0 0 1 ⎦
|
201
|
+
// For this, we need other's z component to be 1 (so that tX and tY
|
202
|
+
// are scaled by 1):
|
203
|
+
let intermediate = Vec3.of(other.x, other.y, 1);
|
204
|
+
intermediate = this.transformVec3(intermediate);
|
205
|
+
|
206
|
+
// Drop the z=1 to allow magnitude to work as expected
|
207
|
+
return Vec2.of(intermediate.x, intermediate.y);
|
208
|
+
}
|
209
|
+
|
210
|
+
/**
|
211
|
+
* Applies this as a linear transformation to the given vector (doesn't translate).
|
212
|
+
* This is the standard way of transforming vectors in ℝ³.
|
213
|
+
*/
|
214
|
+
public transformVec3(other: Vec3): Vec3 {
|
215
|
+
return Vec3.of(
|
216
|
+
this.rows[0].dot(other),
|
217
|
+
this.rows[1].dot(other),
|
218
|
+
this.rows[2].dot(other)
|
219
|
+
);
|
220
|
+
}
|
221
|
+
|
222
|
+
/** @returns true iff this is the identity matrix. */
|
223
|
+
public isIdentity(): boolean {
|
224
|
+
if (this === Mat33.identity) {
|
225
|
+
return true;
|
226
|
+
}
|
227
|
+
|
228
|
+
return this.eq(Mat33.identity);
|
229
|
+
}
|
230
|
+
|
231
|
+
/** Returns true iff this = other ± fuzz */
|
232
|
+
public eq(other: Mat33, fuzz: number = 0): boolean {
|
233
|
+
for (let i = 0; i < 3; i++) {
|
234
|
+
if (!this.rows[i].eq(other.rows[i], fuzz)) {
|
235
|
+
return false;
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
return true;
|
240
|
+
}
|
241
|
+
|
242
|
+
public toString(): string {
|
243
|
+
let result = '';
|
244
|
+
const maxColumnLens = [ 0, 0, 0 ];
|
245
|
+
|
246
|
+
// Determine the longest item in each column so we can pad the others to that
|
247
|
+
// length.
|
248
|
+
for (const row of this.rows) {
|
249
|
+
for (let i = 0; i < 3; i++) {
|
250
|
+
maxColumnLens[i] = Math.max(maxColumnLens[0], `${row.at(i)}`.length);
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
for (let i = 0; i < 3; i++) {
|
255
|
+
if (i === 0) {
|
256
|
+
result += '⎡ ';
|
257
|
+
} else if (i === 1) {
|
258
|
+
result += '⎢ ';
|
259
|
+
} else {
|
260
|
+
result += '⎣ ';
|
261
|
+
}
|
262
|
+
|
263
|
+
// Add each component of the ith row (after padding it)
|
264
|
+
for (let j = 0; j < 3; j++) {
|
265
|
+
const val = this.rows[i].at(j).toString();
|
266
|
+
|
267
|
+
let padding = '';
|
268
|
+
for (let i = val.length; i < maxColumnLens[j]; i++) {
|
269
|
+
padding += ' ';
|
270
|
+
}
|
271
|
+
|
272
|
+
result += val + ', ' + padding;
|
273
|
+
}
|
274
|
+
|
275
|
+
if (i === 0) {
|
276
|
+
result += ' ⎤';
|
277
|
+
} else if (i === 1) {
|
278
|
+
result += ' ⎥';
|
279
|
+
} else {
|
280
|
+
result += ' ⎦';
|
281
|
+
}
|
282
|
+
result += '\n';
|
283
|
+
}
|
284
|
+
|
285
|
+
return result.trimEnd();
|
286
|
+
}
|
287
|
+
|
288
|
+
/**
|
289
|
+
* ```
|
290
|
+
* result[0] = top left element
|
291
|
+
* result[1] = element at row zero, column 1
|
292
|
+
* ...
|
293
|
+
* ```
|
294
|
+
*/
|
295
|
+
public toArray(): Mat33Array {
|
296
|
+
return [
|
297
|
+
this.a1, this.a2, this.a3,
|
298
|
+
this.b1, this.b2, this.b3,
|
299
|
+
this.c1, this.c2, this.c3,
|
300
|
+
];
|
301
|
+
}
|
302
|
+
|
303
|
+
/**
|
304
|
+
* @example
|
305
|
+
* ```
|
306
|
+
* new Mat33(
|
307
|
+
* 1, 2, 3,
|
308
|
+
* 4, 5, 6,
|
309
|
+
* 7, 8, 9,
|
310
|
+
* ).mapEntries(component => component - 1);
|
311
|
+
* // → ⎡ 0, 1, 2 ⎤
|
312
|
+
* // ⎢ 3, 4, 5 ⎥
|
313
|
+
* // ⎣ 6, 7, 8 ⎦
|
314
|
+
* ```
|
315
|
+
*/
|
316
|
+
public mapEntries(mapping: (component: number)=>number): Mat33 {
|
317
|
+
return new Mat33(
|
318
|
+
mapping(this.a1), mapping(this.a2), mapping(this.a3),
|
319
|
+
mapping(this.b1), mapping(this.b2), mapping(this.b3),
|
320
|
+
mapping(this.c1), mapping(this.c2), mapping(this.c3),
|
321
|
+
);
|
322
|
+
}
|
323
|
+
|
324
|
+
/** Estimate the scale factor of this matrix (based on the first row). */
|
325
|
+
public getScaleFactor() {
|
326
|
+
return Math.hypot(this.a1, this.a2);
|
327
|
+
}
|
328
|
+
|
329
|
+
/** Constructs a 3x3 translation matrix (for translating `Vec2`s) */
|
330
|
+
public static translation(amount: Vec2): Mat33 {
|
331
|
+
// When transforming Vec2s by a 3x3 matrix, we give the input
|
332
|
+
// Vec2s z = 1. As such,
|
333
|
+
// outVec2.x = inVec2.x * 1 + inVec2.y * 0 + 1 * amount.x
|
334
|
+
// ...
|
335
|
+
return new Mat33(
|
336
|
+
1, 0, amount.x,
|
337
|
+
0, 1, amount.y,
|
338
|
+
0, 0, 1
|
339
|
+
);
|
340
|
+
}
|
341
|
+
|
342
|
+
public static zRotation(radians: number, center: Point2 = Vec2.zero): Mat33 {
|
343
|
+
if (radians === 0) {
|
344
|
+
return Mat33.identity;
|
345
|
+
}
|
346
|
+
|
347
|
+
const cos = Math.cos(radians);
|
348
|
+
const sin = Math.sin(radians);
|
349
|
+
|
350
|
+
// Translate everything so that rotation is about the origin
|
351
|
+
let result = Mat33.translation(center);
|
352
|
+
|
353
|
+
result = result.rightMul(new Mat33(
|
354
|
+
cos, -sin, 0,
|
355
|
+
sin, cos, 0,
|
356
|
+
0, 0, 1
|
357
|
+
));
|
358
|
+
return result.rightMul(Mat33.translation(center.times(-1)));
|
359
|
+
}
|
360
|
+
|
361
|
+
public static scaling2D(amount: number|Vec2, center: Point2 = Vec2.zero): Mat33 {
|
362
|
+
let result = Mat33.translation(center);
|
363
|
+
let xAmount, yAmount;
|
364
|
+
|
365
|
+
if (typeof amount === 'number') {
|
366
|
+
xAmount = amount;
|
367
|
+
yAmount = amount;
|
368
|
+
} else {
|
369
|
+
xAmount = amount.x;
|
370
|
+
yAmount = amount.y;
|
371
|
+
}
|
372
|
+
|
373
|
+
result = result.rightMul(new Mat33(
|
374
|
+
xAmount, 0, 0,
|
375
|
+
0, yAmount, 0,
|
376
|
+
0, 0, 1
|
377
|
+
));
|
378
|
+
|
379
|
+
// Translate such that [center] goes to (0, 0)
|
380
|
+
return result.rightMul(Mat33.translation(center.times(-1)));
|
381
|
+
}
|
382
|
+
|
383
|
+
/** @see {@link fromCSSMatrix} */
|
384
|
+
public toCSSMatrix(): string {
|
385
|
+
return `matrix(${this.a1},${this.b1},${this.a2},${this.b2},${this.a3},${this.b3})`;
|
386
|
+
}
|
387
|
+
|
388
|
+
/**
|
389
|
+
* Converts a CSS-form `matrix(a, b, c, d, e, f)` to a Mat33.
|
390
|
+
*
|
391
|
+
* Note that such a matrix has the form,
|
392
|
+
* ```
|
393
|
+
* ⎡ a c e ⎤
|
394
|
+
* ⎢ b d f ⎥
|
395
|
+
* ⎣ 0 0 1 ⎦
|
396
|
+
* ```
|
397
|
+
*/
|
398
|
+
public static fromCSSMatrix(cssString: string): Mat33 {
|
399
|
+
if (cssString === '' || cssString === 'none') {
|
400
|
+
return Mat33.identity;
|
401
|
+
}
|
402
|
+
|
403
|
+
const numberExp = '([-]?\\d*(?:\\.\\d*)?(?:[eE][-]?\\d+)?)';
|
404
|
+
const numberSepExp = '[, \\t\\n]';
|
405
|
+
const regExpSource = `^\\s*matrix\\s*\\(${
|
406
|
+
[
|
407
|
+
// According to MDN, matrix(a,b,c,d,e,f) has form:
|
408
|
+
// ⎡ a c e ⎤
|
409
|
+
// ⎢ b d f ⎥
|
410
|
+
// ⎣ 0 0 1 ⎦
|
411
|
+
numberExp, numberExp, numberExp, // a, c, e
|
412
|
+
numberExp, numberExp, numberExp, // b, d, f
|
413
|
+
].join(`${numberSepExp}+`)
|
414
|
+
}${numberSepExp}*\\)\\s*$`;
|
415
|
+
const matrixExp = new RegExp(regExpSource, 'i');
|
416
|
+
const match = matrixExp.exec(cssString);
|
417
|
+
|
418
|
+
if (!match) {
|
419
|
+
throw new Error(`Unsupported transformation: ${cssString}`);
|
420
|
+
}
|
421
|
+
|
422
|
+
const matrixData = match.slice(1).map(entry => parseFloat(entry));
|
423
|
+
const a = matrixData[0];
|
424
|
+
const b = matrixData[1];
|
425
|
+
const c = matrixData[2];
|
426
|
+
const d = matrixData[3];
|
427
|
+
const e = matrixData[4];
|
428
|
+
const f = matrixData[5];
|
429
|
+
|
430
|
+
const transform = new Mat33(
|
431
|
+
a, c, e,
|
432
|
+
b, d, f,
|
433
|
+
0, 0, 1
|
434
|
+
);
|
435
|
+
return transform;
|
436
|
+
}
|
437
|
+
}
|
@@ -0,0 +1,223 @@
|
|
1
|
+
// Tests to ensure that Paths can be deserialized
|
2
|
+
|
3
|
+
import Path, { PathCommandType } from './Path';
|
4
|
+
import { Vec2 } from './Vec2';
|
5
|
+
|
6
|
+
describe('Path.fromString', () => {
|
7
|
+
it('should handle an empty path', () => {
|
8
|
+
const path = Path.fromString('');
|
9
|
+
expect(path.geometry.length).toBe(0);
|
10
|
+
});
|
11
|
+
|
12
|
+
it('should properly handle absolute moveTo commands', () => {
|
13
|
+
const path1 = Path.fromString('M0,0');
|
14
|
+
const path2 = Path.fromString('M 0 0');
|
15
|
+
const path3 = Path.fromString('M 1,1M 2,2 M 3,3');
|
16
|
+
|
17
|
+
expect(path1.parts.length).toBe(0);
|
18
|
+
expect(path1.startPoint).toMatchObject(Vec2.zero);
|
19
|
+
|
20
|
+
expect(path2.parts.length).toBe(0);
|
21
|
+
expect(path2.startPoint).toMatchObject(Vec2.zero);
|
22
|
+
|
23
|
+
expect(path3.parts).toMatchObject([
|
24
|
+
{
|
25
|
+
kind: PathCommandType.MoveTo,
|
26
|
+
point: Vec2.of(2, 2),
|
27
|
+
},
|
28
|
+
{
|
29
|
+
kind: PathCommandType.MoveTo,
|
30
|
+
point: Vec2.of(3,3),
|
31
|
+
},
|
32
|
+
]);
|
33
|
+
expect(path3.startPoint).toMatchObject(Vec2.of(1, 1));
|
34
|
+
});
|
35
|
+
|
36
|
+
it('should properly handle relative moveTo commands', () => {
|
37
|
+
const path = Path.fromString('m1,1 m0,0 m 3,3');
|
38
|
+
expect(path.parts).toMatchObject([
|
39
|
+
{
|
40
|
+
kind: PathCommandType.MoveTo,
|
41
|
+
point: Vec2.of(1, 1),
|
42
|
+
},
|
43
|
+
{
|
44
|
+
kind: PathCommandType.MoveTo,
|
45
|
+
point: Vec2.of(4, 4),
|
46
|
+
},
|
47
|
+
]);
|
48
|
+
expect(path.startPoint).toMatchObject(Vec2.of(1, 1));
|
49
|
+
});
|
50
|
+
|
51
|
+
it('should handle lineTo commands', () => {
|
52
|
+
const path = Path.fromString('l1,2L-1,0l0.1,-1.0');
|
53
|
+
// l is a relative lineTo, but because there
|
54
|
+
// is no previous command, it should act like an
|
55
|
+
// absolute moveTo.
|
56
|
+
expect(path.startPoint).toMatchObject(Vec2.of(1, 2));
|
57
|
+
|
58
|
+
expect(path.parts).toMatchObject([
|
59
|
+
{
|
60
|
+
kind: PathCommandType.LineTo,
|
61
|
+
point: Vec2.of(-1, 0),
|
62
|
+
},
|
63
|
+
{
|
64
|
+
kind: PathCommandType.LineTo,
|
65
|
+
point: Vec2.of(-0.9, -1.0),
|
66
|
+
},
|
67
|
+
]);
|
68
|
+
});
|
69
|
+
|
70
|
+
it('"z" should close strokes', () => {
|
71
|
+
const path1 = Path.fromString('m3,3 l1,2 l1,1 z');
|
72
|
+
const path2 = Path.fromString('m3,3 l1,2 l1,1 Z');
|
73
|
+
|
74
|
+
expect(path1.startPoint).toMatchObject(Vec2.of(3,3));
|
75
|
+
expect(path2.startPoint).toMatchObject(path1.startPoint);
|
76
|
+
expect(path1.parts).toMatchObject(path2.parts);
|
77
|
+
expect(path1.parts).toMatchObject([
|
78
|
+
{
|
79
|
+
kind: PathCommandType.LineTo,
|
80
|
+
point: Vec2.of(4, 5),
|
81
|
+
},
|
82
|
+
{
|
83
|
+
kind: PathCommandType.LineTo,
|
84
|
+
point: Vec2.of(5, 6),
|
85
|
+
},
|
86
|
+
{
|
87
|
+
kind: PathCommandType.LineTo,
|
88
|
+
point: path1.startPoint,
|
89
|
+
}
|
90
|
+
]);
|
91
|
+
});
|
92
|
+
|
93
|
+
it('should break compoents at -s', () => {
|
94
|
+
const path = Path.fromString('m1-1 L-1-1-3-4-5-6,5-1');
|
95
|
+
expect(path.parts.length).toBe(4);
|
96
|
+
expect(path.parts).toMatchObject([
|
97
|
+
{
|
98
|
+
kind: PathCommandType.LineTo,
|
99
|
+
point: Vec2.of(-1, -1),
|
100
|
+
},
|
101
|
+
{
|
102
|
+
kind: PathCommandType.LineTo,
|
103
|
+
point: Vec2.of(-3, -4),
|
104
|
+
},
|
105
|
+
{
|
106
|
+
kind: PathCommandType.LineTo,
|
107
|
+
point: Vec2.of(-5, -6),
|
108
|
+
},
|
109
|
+
{
|
110
|
+
kind: PathCommandType.LineTo,
|
111
|
+
point: Vec2.of(5, -1),
|
112
|
+
},
|
113
|
+
]);
|
114
|
+
});
|
115
|
+
|
116
|
+
it('should properly handle cubic Bézier curves', () => {
|
117
|
+
const path = Path.fromString('m1,1 c1,1 0-3 4 5 C1,1 0.1, 0.1 0, 0');
|
118
|
+
expect(path.parts.length).toBe(2);
|
119
|
+
expect(path.parts).toMatchObject([
|
120
|
+
{
|
121
|
+
kind: PathCommandType.CubicBezierTo,
|
122
|
+
controlPoint1: Vec2.of(2, 2),
|
123
|
+
controlPoint2: Vec2.of(1, -2),
|
124
|
+
endPoint: Vec2.of(5, 6),
|
125
|
+
},
|
126
|
+
{
|
127
|
+
kind: PathCommandType.CubicBezierTo,
|
128
|
+
controlPoint1: Vec2.of(1, 1),
|
129
|
+
controlPoint2: Vec2.of(0.1, 0.1),
|
130
|
+
endPoint: Vec2.zero,
|
131
|
+
}
|
132
|
+
]);
|
133
|
+
});
|
134
|
+
|
135
|
+
it('should handle quadratic Bézier curves', () => {
|
136
|
+
const path = Path.fromString(' Q1 1,2 3 q-1 -2,-3 -4 Q 1 2,3 4');
|
137
|
+
expect(path.parts).toMatchObject([
|
138
|
+
{
|
139
|
+
kind: PathCommandType.QuadraticBezierTo,
|
140
|
+
controlPoint: Vec2.of(1, 1),
|
141
|
+
endPoint: Vec2.of(2, 3),
|
142
|
+
},
|
143
|
+
{
|
144
|
+
kind: PathCommandType.QuadraticBezierTo,
|
145
|
+
controlPoint: Vec2.of(1, 1),
|
146
|
+
endPoint: Vec2.of(-1, -1),
|
147
|
+
},
|
148
|
+
{
|
149
|
+
kind: PathCommandType.QuadraticBezierTo,
|
150
|
+
controlPoint: Vec2.of(1, 2),
|
151
|
+
endPoint: Vec2.of(3, 4),
|
152
|
+
},
|
153
|
+
]);
|
154
|
+
expect(path.startPoint).toMatchObject(Vec2.of(1, 1));
|
155
|
+
});
|
156
|
+
|
157
|
+
it('should correctly handle a command followed by multiple sets of arguments', () => {
|
158
|
+
// Commands followed by multiple sets of arguments, for example,
|
159
|
+
// l 5,10 5,4 3,2,
|
160
|
+
// should be interpreted as multiple commands. Our example, is therefore equivalent to,
|
161
|
+
// l 5,10 l 5,4 l 3,2
|
162
|
+
|
163
|
+
const path = Path.fromString(`
|
164
|
+
L5,10 1,1
|
165
|
+
2,2 -3,-1
|
166
|
+
q 1,2 1,1
|
167
|
+
-1,-1 -3,-4
|
168
|
+
h -4 -1
|
169
|
+
V 3 5 1
|
170
|
+
`);
|
171
|
+
expect(path.parts).toMatchObject([
|
172
|
+
{
|
173
|
+
kind: PathCommandType.LineTo,
|
174
|
+
point: Vec2.of(1, 1),
|
175
|
+
},
|
176
|
+
{
|
177
|
+
kind: PathCommandType.LineTo,
|
178
|
+
point: Vec2.of(2, 2),
|
179
|
+
},
|
180
|
+
{
|
181
|
+
kind: PathCommandType.LineTo,
|
182
|
+
point: Vec2.of(-3, -1),
|
183
|
+
},
|
184
|
+
|
185
|
+
// q 1,2 1,1 -1,-1 -3,-4
|
186
|
+
{
|
187
|
+
kind: PathCommandType.QuadraticBezierTo,
|
188
|
+
controlPoint: Vec2.of(-2, 1),
|
189
|
+
endPoint: Vec2.of(-2, 0),
|
190
|
+
},
|
191
|
+
{
|
192
|
+
kind: PathCommandType.QuadraticBezierTo,
|
193
|
+
controlPoint: Vec2.of(-3, -1),
|
194
|
+
endPoint: Vec2.of(-5, -4),
|
195
|
+
},
|
196
|
+
|
197
|
+
// h -4 -1
|
198
|
+
{
|
199
|
+
kind: PathCommandType.LineTo,
|
200
|
+
point: Vec2.of(-9, -4),
|
201
|
+
},
|
202
|
+
{
|
203
|
+
kind: PathCommandType.LineTo,
|
204
|
+
point: Vec2.of(-10, -4),
|
205
|
+
},
|
206
|
+
|
207
|
+
// V 3 5 1
|
208
|
+
{
|
209
|
+
kind: PathCommandType.LineTo,
|
210
|
+
point: Vec2.of(-10, 3),
|
211
|
+
},
|
212
|
+
{
|
213
|
+
kind: PathCommandType.LineTo,
|
214
|
+
point: Vec2.of(-10, 5),
|
215
|
+
},
|
216
|
+
{
|
217
|
+
kind: PathCommandType.LineTo,
|
218
|
+
point: Vec2.of(-10, 1),
|
219
|
+
},
|
220
|
+
]);
|
221
|
+
expect(path.startPoint).toMatchObject(Vec2.of(5, 10));
|
222
|
+
});
|
223
|
+
});
|