js-draw 0.18.2 → 0.20.0
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/.eslintrc.js +1 -0
- package/CHANGELOG.md +10 -0
- package/dist/bundle.js +2 -2
- package/dist/bundledStyles.js +1 -0
- package/dist/cjs/src/Color4.d.ts +8 -0
- package/dist/cjs/src/Color4.js +67 -0
- package/dist/cjs/src/Editor.d.ts +2 -2
- package/dist/cjs/src/Editor.js +7 -7
- package/dist/cjs/src/SVGLoader.js +77 -12
- package/dist/cjs/src/Viewport.d.ts +2 -0
- package/dist/cjs/src/Viewport.js +6 -2
- package/dist/cjs/src/components/AbstractComponent.d.ts +2 -2
- package/dist/cjs/src/components/AbstractComponent.js +3 -3
- package/dist/cjs/src/components/{ImageBackground.d.ts → BackgroundComponent.d.ts} +23 -3
- package/dist/cjs/src/components/BackgroundComponent.js +309 -0
- package/dist/cjs/src/components/RestylableComponent.d.ts +21 -2
- package/dist/cjs/src/components/Stroke.d.ts +35 -0
- package/dist/cjs/src/components/Stroke.js +37 -3
- package/dist/cjs/src/components/TextComponent.d.ts +27 -17
- package/dist/cjs/src/components/TextComponent.js +23 -1
- package/dist/cjs/src/components/lib.d.ts +4 -3
- package/dist/cjs/src/components/lib.js +2 -2
- package/dist/cjs/src/components/util/StrokeSmoother.js +25 -15
- package/dist/cjs/src/lib.d.ts +30 -0
- package/dist/cjs/src/lib.js +30 -0
- package/dist/cjs/src/localizations/de.js +1 -1
- package/dist/cjs/src/localizations/es.js +1 -1
- package/dist/cjs/src/math/Path.js +1 -1
- package/dist/cjs/src/math/polynomial/QuadraticBezier.d.ts +28 -0
- package/dist/cjs/src/math/polynomial/QuadraticBezier.js +115 -0
- package/dist/cjs/src/math/polynomial/solveQuadratic.d.ts +6 -0
- package/dist/cjs/src/math/polynomial/solveQuadratic.js +36 -0
- package/dist/cjs/src/rendering/RenderingStyle.d.ts +4 -4
- package/dist/cjs/src/rendering/TextRenderingStyle.d.ts +10 -10
- package/dist/cjs/src/rendering/lib.d.ts +2 -0
- package/dist/cjs/src/rendering/renderers/AbstractRenderer.d.ts +2 -2
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.d.ts +2 -2
- package/dist/cjs/src/rendering/renderers/CanvasRenderer.js +5 -3
- package/dist/cjs/src/rendering/renderers/DummyRenderer.d.ts +2 -2
- package/dist/cjs/src/rendering/renderers/SVGRenderer.d.ts +2 -2
- package/dist/cjs/src/rendering/renderers/SVGRenderer.js +15 -6
- package/dist/cjs/src/rendering/renderers/TextOnlyRenderer.d.ts +2 -2
- package/dist/cjs/src/toolbar/IconProvider.d.ts +2 -2
- package/dist/cjs/src/toolbar/localization.d.ts +2 -1
- package/dist/cjs/src/toolbar/localization.js +3 -2
- package/dist/cjs/src/toolbar/widgets/BaseWidget.js +1 -1
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +5 -0
- package/dist/cjs/src/toolbar/widgets/DocumentPropertiesWidget.js +77 -2
- package/dist/cjs/src/toolbar/widgets/PenToolWidget.js +1 -1
- package/dist/cjs/src/tools/FindTool.js +1 -1
- package/dist/cjs/src/tools/SoundUITool.d.ts +24 -0
- package/dist/cjs/src/tools/SoundUITool.js +164 -0
- package/dist/cjs/src/tools/TextTool.d.ts +2 -2
- package/dist/cjs/src/tools/ToolController.js +6 -1
- package/dist/cjs/src/tools/lib.d.ts +1 -0
- package/dist/cjs/src/tools/lib.js +3 -1
- package/dist/cjs/src/tools/localization.d.ts +3 -0
- package/dist/cjs/src/tools/localization.js +3 -0
- package/dist/mjs/src/Color4.d.ts +8 -0
- package/dist/mjs/src/Color4.mjs +64 -0
- package/dist/mjs/src/Editor.d.ts +2 -2
- package/dist/mjs/src/Editor.mjs +6 -6
- package/dist/mjs/src/SVGLoader.mjs +76 -11
- package/dist/mjs/src/Viewport.d.ts +2 -0
- package/dist/mjs/src/Viewport.mjs +6 -2
- package/dist/mjs/src/components/AbstractComponent.d.ts +2 -2
- package/dist/mjs/src/components/AbstractComponent.mjs +3 -3
- package/dist/mjs/src/components/{ImageBackground.d.ts → BackgroundComponent.d.ts} +23 -3
- package/dist/mjs/src/components/BackgroundComponent.mjs +279 -0
- package/dist/mjs/src/components/RestylableComponent.d.ts +21 -2
- package/dist/mjs/src/components/Stroke.d.ts +35 -0
- package/dist/mjs/src/components/Stroke.mjs +37 -3
- package/dist/mjs/src/components/TextComponent.d.ts +27 -17
- package/dist/mjs/src/components/TextComponent.mjs +23 -1
- package/dist/mjs/src/components/lib.d.ts +4 -3
- package/dist/mjs/src/components/lib.mjs +2 -2
- package/dist/mjs/src/components/util/StrokeSmoother.mjs +25 -15
- package/dist/mjs/src/lib.d.ts +30 -0
- package/dist/mjs/src/lib.mjs +30 -0
- package/dist/mjs/src/localizations/de.mjs +1 -1
- package/dist/mjs/src/localizations/es.mjs +1 -1
- package/dist/mjs/src/math/Path.mjs +1 -1
- package/dist/mjs/src/math/polynomial/QuadraticBezier.d.ts +28 -0
- package/dist/mjs/src/math/polynomial/QuadraticBezier.mjs +109 -0
- package/dist/mjs/src/math/polynomial/solveQuadratic.d.ts +6 -0
- package/dist/mjs/src/math/polynomial/solveQuadratic.mjs +34 -0
- package/dist/mjs/src/rendering/RenderingStyle.d.ts +4 -4
- package/dist/mjs/src/rendering/TextRenderingStyle.d.ts +10 -10
- package/dist/mjs/src/rendering/lib.d.ts +2 -0
- package/dist/mjs/src/rendering/renderers/AbstractRenderer.d.ts +2 -2
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.d.ts +2 -2
- package/dist/mjs/src/rendering/renderers/CanvasRenderer.mjs +5 -3
- package/dist/mjs/src/rendering/renderers/DummyRenderer.d.ts +2 -2
- package/dist/mjs/src/rendering/renderers/SVGRenderer.d.ts +2 -2
- package/dist/mjs/src/rendering/renderers/SVGRenderer.mjs +15 -6
- package/dist/mjs/src/rendering/renderers/TextOnlyRenderer.d.ts +2 -2
- package/dist/mjs/src/toolbar/IconProvider.d.ts +2 -2
- package/dist/mjs/src/toolbar/localization.d.ts +2 -1
- package/dist/mjs/src/toolbar/localization.mjs +3 -2
- package/dist/mjs/src/toolbar/widgets/BaseWidget.mjs +1 -1
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.d.ts +5 -0
- package/dist/mjs/src/toolbar/widgets/DocumentPropertiesWidget.mjs +54 -2
- package/dist/mjs/src/toolbar/widgets/PenToolWidget.mjs +1 -1
- package/dist/mjs/src/tools/FindTool.mjs +1 -1
- package/dist/mjs/src/tools/SoundUITool.d.ts +24 -0
- package/dist/mjs/src/tools/SoundUITool.mjs +158 -0
- package/dist/mjs/src/tools/TextTool.d.ts +2 -2
- package/dist/mjs/src/tools/ToolController.mjs +6 -1
- package/dist/mjs/src/tools/lib.d.ts +1 -0
- package/dist/mjs/src/tools/lib.mjs +1 -0
- package/dist/mjs/src/tools/localization.d.ts +3 -0
- package/dist/mjs/src/tools/localization.mjs +3 -0
- package/jest.config.js +1 -1
- package/package.json +19 -17
- package/src/Editor.css +2 -2
- package/src/tools/SoundUITool.css +15 -0
- package/src/tools/tools.css +4 -0
- package/dist/cjs/src/components/ImageBackground.js +0 -146
- package/dist/mjs/src/components/ImageBackground.mjs +0 -139
- package/src/Color4.test.ts +0 -40
- package/src/Color4.ts +0 -236
- package/src/Editor.loadFrom.test.ts +0 -24
- package/src/Editor.toSVG.test.ts +0 -111
- package/src/Editor.ts +0 -1122
- package/src/EditorImage.test.ts +0 -120
- package/src/EditorImage.ts +0 -603
- package/src/EventDispatcher.test.ts +0 -123
- package/src/EventDispatcher.ts +0 -71
- package/src/Pointer.ts +0 -127
- package/src/SVGLoader.test.ts +0 -114
- package/src/SVGLoader.ts +0 -511
- package/src/UndoRedoHistory.test.ts +0 -33
- package/src/UndoRedoHistory.ts +0 -102
- package/src/Viewport.ts +0 -319
- package/src/bundle/bundled.ts +0 -7
- package/src/commands/Command.ts +0 -45
- package/src/commands/Duplicate.ts +0 -48
- package/src/commands/Erase.ts +0 -74
- package/src/commands/SerializableCommand.ts +0 -49
- package/src/commands/UnresolvedCommand.ts +0 -37
- package/src/commands/invertCommand.ts +0 -51
- package/src/commands/lib.ts +0 -16
- package/src/commands/localization.ts +0 -47
- package/src/commands/uniteCommands.test.ts +0 -23
- package/src/commands/uniteCommands.ts +0 -135
- package/src/components/AbstractComponent.transformBy.test.ts +0 -22
- package/src/components/AbstractComponent.ts +0 -364
- package/src/components/ImageBackground.test.ts +0 -35
- package/src/components/ImageBackground.ts +0 -176
- package/src/components/ImageComponent.ts +0 -171
- package/src/components/RestylableComponent.ts +0 -142
- package/src/components/SVGGlobalAttributesObject.ts +0 -81
- package/src/components/Stroke.test.ts +0 -139
- package/src/components/Stroke.ts +0 -245
- package/src/components/TextComponent.test.ts +0 -99
- package/src/components/TextComponent.ts +0 -315
- package/src/components/UnknownSVGObject.test.ts +0 -10
- package/src/components/UnknownSVGObject.ts +0 -60
- package/src/components/builders/ArrowBuilder.ts +0 -107
- package/src/components/builders/FreehandLineBuilder.ts +0 -212
- package/src/components/builders/LineBuilder.ts +0 -77
- package/src/components/builders/PressureSensitiveFreehandLineBuilder.ts +0 -454
- package/src/components/builders/RectangleBuilder.ts +0 -74
- package/src/components/builders/types.ts +0 -15
- package/src/components/lib.ts +0 -25
- package/src/components/localization.ts +0 -22
- package/src/components/util/StrokeSmoother.ts +0 -293
- package/src/components/util/describeComponentList.ts +0 -18
- package/src/lib.ts +0 -37
- package/src/localization.ts +0 -34
- package/src/localizations/de.ts +0 -98
- package/src/localizations/en.ts +0 -8
- package/src/localizations/es.ts +0 -74
- package/src/localizations/getLocalizationTable.test.ts +0 -27
- package/src/localizations/getLocalizationTable.ts +0 -55
- package/src/math/LineSegment2.test.ts +0 -99
- package/src/math/LineSegment2.ts +0 -160
- package/src/math/Mat33.test.ts +0 -244
- package/src/math/Mat33.ts +0 -437
- package/src/math/Path.fromString.test.ts +0 -223
- package/src/math/Path.test.ts +0 -198
- package/src/math/Path.toString.test.ts +0 -77
- package/src/math/Path.ts +0 -790
- package/src/math/Rect2.test.ts +0 -204
- package/src/math/Rect2.ts +0 -315
- package/src/math/Triangle.ts +0 -29
- package/src/math/Vec2.test.ts +0 -30
- package/src/math/Vec2.ts +0 -18
- package/src/math/Vec3.test.ts +0 -44
- package/src/math/Vec3.ts +0 -218
- package/src/math/lib.ts +0 -15
- package/src/math/rounding.test.ts +0 -65
- package/src/math/rounding.ts +0 -156
- package/src/rendering/Display.ts +0 -249
- package/src/rendering/RenderingStyle.test.ts +0 -68
- package/src/rendering/RenderingStyle.ts +0 -55
- package/src/rendering/TextRenderingStyle.ts +0 -45
- package/src/rendering/caching/CacheRecord.test.ts +0 -49
- package/src/rendering/caching/CacheRecord.ts +0 -77
- package/src/rendering/caching/CacheRecordManager.ts +0 -71
- package/src/rendering/caching/RenderingCache.test.ts +0 -44
- package/src/rendering/caching/RenderingCache.ts +0 -66
- package/src/rendering/caching/RenderingCacheNode.ts +0 -405
- package/src/rendering/caching/testUtils.ts +0 -35
- package/src/rendering/caching/types.ts +0 -34
- package/src/rendering/lib.ts +0 -6
- package/src/rendering/localization.ts +0 -20
- package/src/rendering/renderers/AbstractRenderer.ts +0 -222
- package/src/rendering/renderers/CanvasRenderer.ts +0 -296
- package/src/rendering/renderers/DummyRenderer.test.ts +0 -42
- package/src/rendering/renderers/DummyRenderer.ts +0 -136
- package/src/rendering/renderers/SVGRenderer.ts +0 -354
- package/src/rendering/renderers/TextOnlyRenderer.ts +0 -70
- package/src/testing/beforeEachFile.ts +0 -8
- package/src/testing/createEditor.ts +0 -11
- package/src/testing/global.d.ts +0 -17
- package/src/testing/lib.ts +0 -3
- package/src/testing/loadExpectExtensions.ts +0 -25
- package/src/testing/sendPenEvent.ts +0 -31
- package/src/testing/sendTouchEvent.ts +0 -78
- package/src/toolbar/HTMLToolbar.ts +0 -492
- package/src/toolbar/IconProvider.ts +0 -736
- package/src/toolbar/lib.ts +0 -4
- package/src/toolbar/localization.ts +0 -106
- package/src/toolbar/makeColorInput.ts +0 -145
- package/src/toolbar/types.ts +0 -5
- package/src/toolbar/widgets/ActionButtonWidget.ts +0 -39
- package/src/toolbar/widgets/BaseToolWidget.ts +0 -56
- package/src/toolbar/widgets/BaseWidget.ts +0 -377
- package/src/toolbar/widgets/DocumentPropertiesWidget.ts +0 -167
- package/src/toolbar/widgets/EraserToolWidget.ts +0 -85
- package/src/toolbar/widgets/HandToolWidget.ts +0 -250
- package/src/toolbar/widgets/InsertImageWidget.ts +0 -223
- package/src/toolbar/widgets/OverflowWidget.ts +0 -92
- package/src/toolbar/widgets/PenToolWidget.ts +0 -288
- package/src/toolbar/widgets/SelectionToolWidget.ts +0 -190
- package/src/toolbar/widgets/TextToolWidget.ts +0 -145
- package/src/toolbar/widgets/lib.ts +0 -13
- package/src/tools/BaseTool.ts +0 -76
- package/src/tools/Eraser.test.ts +0 -103
- package/src/tools/Eraser.ts +0 -139
- package/src/tools/FindTool.ts +0 -152
- package/src/tools/PanZoom.test.ts +0 -310
- package/src/tools/PanZoom.ts +0 -520
- package/src/tools/PasteHandler.ts +0 -95
- package/src/tools/Pen.test.ts +0 -194
- package/src/tools/Pen.ts +0 -226
- package/src/tools/PipetteTool.ts +0 -55
- package/src/tools/SelectionTool/SelectAllShortcutHandler.ts +0 -28
- package/src/tools/SelectionTool/Selection.ts +0 -607
- package/src/tools/SelectionTool/SelectionHandle.ts +0 -108
- package/src/tools/SelectionTool/SelectionTool.test.ts +0 -261
- package/src/tools/SelectionTool/SelectionTool.ts +0 -480
- package/src/tools/SelectionTool/TransformMode.ts +0 -114
- package/src/tools/SelectionTool/types.ts +0 -11
- package/src/tools/TextTool.ts +0 -326
- package/src/tools/ToolController.ts +0 -178
- package/src/tools/ToolEnabledGroup.ts +0 -14
- package/src/tools/ToolSwitcherShortcut.ts +0 -39
- package/src/tools/ToolbarShortcutHandler.ts +0 -34
- package/src/tools/UndoRedoShortcut.test.ts +0 -56
- package/src/tools/UndoRedoShortcut.ts +0 -25
- package/src/tools/lib.ts +0 -21
- package/src/tools/localization.ts +0 -66
- package/src/types.ts +0 -234
- package/src/util/assertions.ts +0 -55
- package/src/util/fileToBase64.ts +0 -18
- package/src/util/untilNextAnimationFrame.ts +0 -9
- package/src/util/waitForTimeout.ts +0 -9
@@ -3,3 +3,5 @@ export { default as DummyRenderer } from './renderers/DummyRenderer';
|
|
3
3
|
export { default as SVGRenderer } from './renderers/SVGRenderer';
|
4
4
|
export { default as CanvasRenderer } from './renderers/CanvasRenderer';
|
5
5
|
export { default as Display, RenderingMode } from './Display';
|
6
|
+
export { default as TextRenderingStyle } from './TextRenderingStyle';
|
7
|
+
export { default as RenderingStyle } from './RenderingStyle';
|
@@ -6,7 +6,7 @@ import Rect2 from '../../math/Rect2';
|
|
6
6
|
import { Point2, Vec2 } from '../../math/Vec2';
|
7
7
|
import Viewport from '../../Viewport';
|
8
8
|
import RenderingStyle from '../RenderingStyle';
|
9
|
-
import
|
9
|
+
import TextRenderingStyle from '../TextRenderingStyle';
|
10
10
|
export interface RenderablePathSpec {
|
11
11
|
startPoint: Point2;
|
12
12
|
commands: PathCommand[];
|
@@ -33,7 +33,7 @@ export default abstract class AbstractRenderer {
|
|
33
33
|
protected abstract moveTo(point: Point2): void;
|
34
34
|
protected abstract traceCubicBezierCurve(p1: Point2, p2: Point2, p3: Point2): void;
|
35
35
|
protected abstract traceQuadraticBezierCurve(controlPoint: Point2, endPoint: Point2): void;
|
36
|
-
abstract drawText(text: string, transform: Mat33, style:
|
36
|
+
abstract drawText(text: string, transform: Mat33, style: TextRenderingStyle): void;
|
37
37
|
abstract drawImage(image: RenderableImage): void;
|
38
38
|
abstract isTooSmallToRender(rect: Rect2): boolean;
|
39
39
|
setDraftMode(_draftMode: boolean): void;
|
@@ -4,7 +4,7 @@ import { Point2, Vec2 } from '../../math/Vec2';
|
|
4
4
|
import Vec3 from '../../math/Vec3';
|
5
5
|
import Viewport from '../../Viewport';
|
6
6
|
import RenderingStyle from '../RenderingStyle';
|
7
|
-
import
|
7
|
+
import TextRenderingStyle from '../TextRenderingStyle';
|
8
8
|
import AbstractRenderer, { RenderableImage, RenderablePathSpec } from './AbstractRenderer';
|
9
9
|
/**
|
10
10
|
* Renders onto a `CanvasRenderingContext2D`.
|
@@ -53,7 +53,7 @@ export default class CanvasRenderer extends AbstractRenderer {
|
|
53
53
|
protected traceCubicBezierCurve(p1: Point2, p2: Point2, p3: Point2): void;
|
54
54
|
protected traceQuadraticBezierCurve(controlPoint: Vec3, endPoint: Vec3): void;
|
55
55
|
drawPath(path: RenderablePathSpec): void;
|
56
|
-
drawText(text: string, transform: Mat33, style:
|
56
|
+
drawText(text: string, transform: Mat33, style: TextRenderingStyle): void;
|
57
57
|
drawImage(image: RenderableImage): void;
|
58
58
|
private clipLevels;
|
59
59
|
startObject(boundingBox: Rect2, clip?: boolean): void;
|
@@ -186,14 +186,16 @@ export default class CanvasRenderer extends AbstractRenderer {
|
|
186
186
|
}
|
187
187
|
}
|
188
188
|
endObject() {
|
189
|
+
// Cache this.objectLevel — it may be decremented by super.endObject.
|
190
|
+
const objectLevel = this.objectLevel;
|
191
|
+
this.currentObjectBBox = null;
|
192
|
+
super.endObject();
|
189
193
|
if (!this.ignoringObject && this.clipLevels.length > 0) {
|
190
|
-
if (this.clipLevels[this.clipLevels.length - 1] ===
|
194
|
+
if (this.clipLevels[this.clipLevels.length - 1] === objectLevel) {
|
191
195
|
this.ctx.restore();
|
192
196
|
this.clipLevels.pop();
|
193
197
|
}
|
194
198
|
}
|
195
|
-
this.currentObjectBBox = null;
|
196
|
-
super.endObject();
|
197
199
|
// If exiting an object with a too-small-to-draw bounding box,
|
198
200
|
if (this.ignoreObjectsAboveLevel !== null && this.getNestingLevel() <= this.ignoreObjectsAboveLevel) {
|
199
201
|
this.ignoreObjectsAboveLevel = null;
|
@@ -4,7 +4,7 @@ import { Point2, Vec2 } from '../../math/Vec2';
|
|
4
4
|
import Vec3 from '../../math/Vec3';
|
5
5
|
import Viewport from '../../Viewport';
|
6
6
|
import RenderingStyle from '../RenderingStyle';
|
7
|
-
import
|
7
|
+
import TextRenderingStyle from '../TextRenderingStyle';
|
8
8
|
import AbstractRenderer, { RenderableImage } from './AbstractRenderer';
|
9
9
|
export default class DummyRenderer extends AbstractRenderer {
|
10
10
|
clearedCount: number;
|
@@ -25,7 +25,7 @@ export default class DummyRenderer extends AbstractRenderer {
|
|
25
25
|
protected traceCubicBezierCurve(p1: Vec3, p2: Vec3, p3: Vec3): void;
|
26
26
|
protected traceQuadraticBezierCurve(controlPoint: Vec3, endPoint: Vec3): void;
|
27
27
|
drawPoints(..._points: Vec3[]): void;
|
28
|
-
drawText(text: string, _transform: Mat33, _style:
|
28
|
+
drawText(text: string, _transform: Mat33, _style: TextRenderingStyle): void;
|
29
29
|
drawImage(image: RenderableImage): void;
|
30
30
|
startObject(boundingBox: Rect2, _clip: boolean): void;
|
31
31
|
endObject(): void;
|
@@ -4,7 +4,7 @@ import Rect2 from '../../math/Rect2';
|
|
4
4
|
import { Point2, Vec2 } from '../../math/Vec2';
|
5
5
|
import Viewport from '../../Viewport';
|
6
6
|
import RenderingStyle from '../RenderingStyle';
|
7
|
-
import
|
7
|
+
import TextRenderingStyle from '../TextRenderingStyle';
|
8
8
|
import AbstractRenderer, { RenderableImage, RenderablePathSpec } from './AbstractRenderer';
|
9
9
|
export declare const renderedStylesheetId = "js-draw-style-sheet";
|
10
10
|
/**
|
@@ -36,7 +36,7 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
36
36
|
private textContainer;
|
37
37
|
private textContainerTransform;
|
38
38
|
private textParentStyle;
|
39
|
-
drawText(text: string, transform: Mat33, style:
|
39
|
+
drawText(text: string, transform: Mat33, style: TextRenderingStyle): void;
|
40
40
|
drawImage(image: RenderableImage): void;
|
41
41
|
startObject(boundingBox: Rect2): void;
|
42
42
|
endObject(loaderData?: LoadSaveDataTable, elemClassNames?: string[]): void;
|
@@ -3,6 +3,7 @@ import Path from '../../math/Path.mjs';
|
|
3
3
|
import { toRoundedString } from '../../math/rounding.mjs';
|
4
4
|
import { Vec2 } from '../../math/Vec2.mjs';
|
5
5
|
import { svgAttributesDataKey, svgStyleAttributesDataKey } from '../../SVGLoader.mjs';
|
6
|
+
import { stylesEqual } from '../RenderingStyle.mjs';
|
6
7
|
import AbstractRenderer from './AbstractRenderer.mjs';
|
7
8
|
export const renderedStylesheetId = 'js-draw-style-sheet';
|
8
9
|
const svgNameSpace = 'http://www.w3.org/2000/svg';
|
@@ -108,11 +109,10 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
108
109
|
(_a = this.objectElems) === null || _a === void 0 ? void 0 : _a.push(pathElem);
|
109
110
|
}
|
110
111
|
drawPath(pathSpec) {
|
111
|
-
var _a;
|
112
112
|
const style = pathSpec.style;
|
113
113
|
const path = Path.fromRenderable(pathSpec).transformedBy(this.getCanvasToScreenTransform());
|
114
114
|
// Try to extend the previous path, if possible
|
115
|
-
if (
|
115
|
+
if (this.lastPathString.length === 0 || !this.lastPathStyle || !stylesEqual(this.lastPathStyle, style)) {
|
116
116
|
this.addPathToSVG();
|
117
117
|
this.lastPathStyle = style;
|
118
118
|
this.lastPathString = [];
|
@@ -226,7 +226,7 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
226
226
|
this.objectElems = [];
|
227
227
|
}
|
228
228
|
endObject(loaderData, elemClassNames) {
|
229
|
-
var _a
|
229
|
+
var _a;
|
230
230
|
super.endObject(loaderData);
|
231
231
|
// Don't extend paths across objects
|
232
232
|
this.addPathToSVG();
|
@@ -248,9 +248,18 @@ export default class SVGRenderer extends AbstractRenderer {
|
|
248
248
|
}
|
249
249
|
}
|
250
250
|
// Add class names to the object, if given.
|
251
|
-
if (elemClassNames) {
|
252
|
-
|
253
|
-
|
251
|
+
if (elemClassNames && this.objectElems) {
|
252
|
+
if (this.objectElems.length === 1) {
|
253
|
+
this.objectElems[0].classList.add(...elemClassNames);
|
254
|
+
}
|
255
|
+
else {
|
256
|
+
const wrapper = document.createElementNS(svgNameSpace, 'g');
|
257
|
+
wrapper.classList.add(...elemClassNames);
|
258
|
+
for (const elem of this.objectElems) {
|
259
|
+
elem.remove();
|
260
|
+
wrapper.appendChild(elem);
|
261
|
+
}
|
262
|
+
this.elem.appendChild(wrapper);
|
254
263
|
}
|
255
264
|
}
|
256
265
|
}
|
@@ -4,7 +4,7 @@ import Vec3 from '../../math/Vec3';
|
|
4
4
|
import Viewport from '../../Viewport';
|
5
5
|
import { TextRendererLocalization } from '../localization';
|
6
6
|
import RenderingStyle from '../RenderingStyle';
|
7
|
-
import
|
7
|
+
import TextRenderingStyle from '../TextRenderingStyle';
|
8
8
|
import AbstractRenderer, { RenderableImage } from './AbstractRenderer';
|
9
9
|
export default class TextOnlyRenderer extends AbstractRenderer {
|
10
10
|
private localizationTable;
|
@@ -22,7 +22,7 @@ export default class TextOnlyRenderer extends AbstractRenderer {
|
|
22
22
|
protected moveTo(_point: Vec3): void;
|
23
23
|
protected traceCubicBezierCurve(_p1: Vec3, _p2: Vec3, _p3: Vec3): void;
|
24
24
|
protected traceQuadraticBezierCurve(_controlPoint: Vec3, _endPoint: Vec3): void;
|
25
|
-
drawText(text: string, _transform: Mat33, _style:
|
25
|
+
drawText(text: string, _transform: Mat33, _style: TextRenderingStyle): void;
|
26
26
|
drawImage(image: RenderableImage): void;
|
27
27
|
isTooSmallToRender(rect: Rect2): boolean;
|
28
28
|
drawPoints(..._points: Vec3[]): void;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import Color4 from '../Color4';
|
2
2
|
import { ComponentBuilderFactory } from '../components/builders/types';
|
3
|
-
import
|
3
|
+
import TextRenderingStyle from '../rendering/TextRenderingStyle';
|
4
4
|
import Pen from '../tools/Pen';
|
5
5
|
export type IconType = HTMLImageElement | SVGElement;
|
6
6
|
/**
|
@@ -47,7 +47,7 @@ export default class IconProvider {
|
|
47
47
|
makeZoomIcon(): IconType;
|
48
48
|
makeRotationLockIcon(): IconType;
|
49
49
|
makeInsertImageIcon(): IconType;
|
50
|
-
makeTextIcon(textStyle:
|
50
|
+
makeTextIcon(textStyle: TextRenderingStyle): IconType;
|
51
51
|
makePenIcon(strokeSize: number, color: string | Color4, rounded?: boolean): IconType;
|
52
52
|
makeIconFromFactory(pen: Pen, factory: ComponentBuilderFactory): IconType;
|
53
53
|
makePipetteIcon(color?: Color4): IconType;
|
@@ -14,7 +14,7 @@ export interface ToolbarLocalization {
|
|
14
14
|
submit: string;
|
15
15
|
freehandPen: string;
|
16
16
|
pressureSensitiveFreehandPen: string;
|
17
|
-
|
17
|
+
selectPenType: string;
|
18
18
|
colorLabel: string;
|
19
19
|
pen: string;
|
20
20
|
eraser: string;
|
@@ -37,6 +37,7 @@ export interface ToolbarLocalization {
|
|
37
37
|
backgroundColor: string;
|
38
38
|
imageWidthOption: string;
|
39
39
|
imageHeightOption: string;
|
40
|
+
useGridOption: string;
|
40
41
|
toggleOverflow: string;
|
41
42
|
errorImageHasZeroSize: string;
|
42
43
|
dropdownShown: (toolName: string) => string;
|
@@ -20,14 +20,15 @@ export const defaultToolbarLocalization = {
|
|
20
20
|
duplicateSelection: 'Duplicate selection',
|
21
21
|
undo: 'Undo',
|
22
22
|
redo: 'Redo',
|
23
|
-
|
23
|
+
selectPenType: 'Pen type: ',
|
24
24
|
pickColorFromScreen: 'Pick color from screen',
|
25
25
|
clickToPickColorAnnouncement: 'Click on the screen to pick a color',
|
26
26
|
selectionToolKeyboardShortcuts: 'Selection tool: Use arrow keys to move selected items, lowercase/uppercase ‘i’ and ‘o’ to resize.',
|
27
|
-
documentProperties: '
|
27
|
+
documentProperties: 'Page',
|
28
28
|
backgroundColor: 'Background Color: ',
|
29
29
|
imageWidthOption: 'Width: ',
|
30
30
|
imageHeightOption: 'Height: ',
|
31
|
+
useGridOption: 'Grid: ',
|
31
32
|
toggleOverflow: 'More',
|
32
33
|
touchPanning: 'Touchscreen panning',
|
33
34
|
freehandPen: 'Freehand',
|
@@ -122,7 +122,7 @@ export default class BaseWidget {
|
|
122
122
|
}
|
123
123
|
// Add a listener that is triggered when a key is pressed.
|
124
124
|
// Listeners will fire regardless of whether this widget is selected and require that
|
125
|
-
// {@link
|
125
|
+
// {@link Editor.toolController} to have an enabled {@link ToolbarShortcutHandler} tool.
|
126
126
|
onKeyPress(_event) {
|
127
127
|
return false;
|
128
128
|
}
|
@@ -12,6 +12,11 @@ export default class DocumentPropertiesWidget extends BaseWidget {
|
|
12
12
|
private updateDropdown;
|
13
13
|
private setBackgroundColor;
|
14
14
|
private getBackgroundColor;
|
15
|
+
private removeBackgroundComponents;
|
16
|
+
/** Replace existing background components with a background of the given type. */
|
17
|
+
private setBackgroundType;
|
18
|
+
/** Returns the type of the topmost background component */
|
19
|
+
private getBackgroundType;
|
15
20
|
private updateImportExportRectSize;
|
16
21
|
private static idCounter;
|
17
22
|
protected fillDropdown(dropdown: HTMLElement): boolean;
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import Erase from '../../commands/Erase.mjs';
|
2
|
+
import uniteCommands from '../../commands/uniteCommands.mjs';
|
3
|
+
import BackgroundComponent, { BackgroundType } from '../../components/BackgroundComponent.mjs';
|
1
4
|
import { EditorImageEventType } from '../../EditorImage.mjs';
|
2
5
|
import Rect2 from '../../math/Rect2.mjs';
|
3
6
|
import { EditorEventType } from '../../types.mjs';
|
@@ -6,7 +9,7 @@ import makeColorInput from '../makeColorInput.mjs';
|
|
6
9
|
import BaseWidget from './BaseWidget.mjs';
|
7
10
|
export default class DocumentPropertiesWidget extends BaseWidget {
|
8
11
|
constructor(editor, localizationTable) {
|
9
|
-
super(editor, '
|
12
|
+
super(editor, 'document-properties-widget', localizationTable);
|
10
13
|
this.updateDropdownContent = () => { };
|
11
14
|
this.dropdownUpdateQueued = false;
|
12
15
|
// Make it possible to open the dropdown, even if this widget isn't selected.
|
@@ -46,6 +49,33 @@ export default class DocumentPropertiesWidget extends BaseWidget {
|
|
46
49
|
getBackgroundColor() {
|
47
50
|
return this.editor.estimateBackgroundColor();
|
48
51
|
}
|
52
|
+
removeBackgroundComponents() {
|
53
|
+
const previousBackgrounds = [];
|
54
|
+
for (const component of this.editor.image.getBackgroundComponents()) {
|
55
|
+
if (component instanceof BackgroundComponent) {
|
56
|
+
previousBackgrounds.push(component);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return new Erase(previousBackgrounds);
|
60
|
+
}
|
61
|
+
/** Replace existing background components with a background of the given type. */
|
62
|
+
setBackgroundType(backgroundType) {
|
63
|
+
const prevBackgroundColor = this.editor.estimateBackgroundColor();
|
64
|
+
const newBackground = new BackgroundComponent(backgroundType, prevBackgroundColor);
|
65
|
+
const addBackgroundCommand = this.editor.image.addElement(newBackground);
|
66
|
+
return uniteCommands([this.removeBackgroundComponents(), addBackgroundCommand]);
|
67
|
+
}
|
68
|
+
/** Returns the type of the topmost background component */
|
69
|
+
getBackgroundType() {
|
70
|
+
const backgroundComponents = this.editor.image.getBackgroundComponents();
|
71
|
+
for (let i = backgroundComponents.length - 1; i >= 0; i--) {
|
72
|
+
const component = backgroundComponents[i];
|
73
|
+
if (component instanceof BackgroundComponent) {
|
74
|
+
return component.getBackgroundType();
|
75
|
+
}
|
76
|
+
}
|
77
|
+
return BackgroundType.None;
|
78
|
+
}
|
49
79
|
updateImportExportRectSize(size) {
|
50
80
|
const filterDimension = (dim) => {
|
51
81
|
if (dim !== undefined && (!isFinite(dim) || dim <= 0)) {
|
@@ -74,6 +104,27 @@ export default class DocumentPropertiesWidget extends BaseWidget {
|
|
74
104
|
colorInput.id = `${toolbarCSSPrefix}docPropertiesColorInput-${DocumentPropertiesWidget.idCounter++}`;
|
75
105
|
backgroundColorLabel.htmlFor = colorInput.id;
|
76
106
|
backgroundColorRow.replaceChildren(backgroundColorLabel, backgroundColorInputContainer);
|
107
|
+
const useGridRow = document.createElement('div');
|
108
|
+
const useGridLabel = document.createElement('label');
|
109
|
+
const useGridCheckbox = document.createElement('input');
|
110
|
+
useGridCheckbox.id = `${toolbarCSSPrefix}docPropertiesUseGridCheckbox-${DocumentPropertiesWidget.idCounter++}`;
|
111
|
+
useGridLabel.htmlFor = useGridCheckbox.id;
|
112
|
+
useGridCheckbox.type = 'checkbox';
|
113
|
+
useGridLabel.innerText = this.localizationTable.useGridOption;
|
114
|
+
useGridCheckbox.oninput = () => {
|
115
|
+
const prevBackgroundType = this.getBackgroundType();
|
116
|
+
const wasGrid = prevBackgroundType === BackgroundType.Grid;
|
117
|
+
if (wasGrid === useGridCheckbox.checked) {
|
118
|
+
// Already the requested background type.
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
let newBackgroundType = BackgroundType.SolidColor;
|
122
|
+
if (useGridCheckbox.checked) {
|
123
|
+
newBackgroundType = BackgroundType.Grid;
|
124
|
+
}
|
125
|
+
this.editor.dispatch(this.setBackgroundType(newBackgroundType));
|
126
|
+
};
|
127
|
+
useGridRow.replaceChildren(useGridLabel, useGridCheckbox);
|
77
128
|
const addDimensionRow = (labelContent, onChange) => {
|
78
129
|
const row = document.createElement('div');
|
79
130
|
const label = document.createElement('label');
|
@@ -110,9 +161,10 @@ export default class DocumentPropertiesWidget extends BaseWidget {
|
|
110
161
|
const importExportRect = this.editor.getImportExportRect();
|
111
162
|
imageWidthRow.setValue(importExportRect.width);
|
112
163
|
imageHeightRow.setValue(importExportRect.height);
|
164
|
+
useGridCheckbox.checked = this.getBackgroundType() === BackgroundType.Grid;
|
113
165
|
};
|
114
166
|
this.updateDropdownContent();
|
115
|
-
container.replaceChildren(backgroundColorRow, imageWidthRow.element, imageHeightRow.element);
|
167
|
+
container.replaceChildren(backgroundColorRow, useGridRow, imageWidthRow.element, imageHeightRow.element);
|
116
168
|
dropdown.replaceChildren(container);
|
117
169
|
return true;
|
118
170
|
}
|
@@ -110,7 +110,7 @@ export default class PenToolWidget extends BaseToolWidget {
|
|
110
110
|
objectTypeSelect.id = `${toolbarCSSPrefix}penBuilderSelect${PenToolWidget.idCounter++}`;
|
111
111
|
thicknessLabel.innerText = this.localizationTable.thicknessLabel;
|
112
112
|
thicknessLabel.setAttribute('for', thicknessInput.id);
|
113
|
-
objectSelectLabel.innerText = this.localizationTable.
|
113
|
+
objectSelectLabel.innerText = this.localizationTable.selectPenType;
|
114
114
|
objectSelectLabel.setAttribute('for', objectTypeSelect.id);
|
115
115
|
// Use a logarithmic scale for thicknessInput (finer control over thinner strokewidths.)
|
116
116
|
const inverseThicknessInputFn = (t) => Math.log10(t);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import Editor from '../Editor';
|
2
|
+
import { PointerEvt } from '../types';
|
3
|
+
import BaseTool from './BaseTool';
|
4
|
+
/**
|
5
|
+
* This tool, when enabled, plays a sound representing the color of the portion of the display
|
6
|
+
* currently under the cursor. This tool adds a button that can be navigated to with the tab key
|
7
|
+
* that enables/disables the tool.
|
8
|
+
*
|
9
|
+
* This allows the user to explore the content of the display without a working screen.
|
10
|
+
*/
|
11
|
+
export default class SoundUITool extends BaseTool {
|
12
|
+
private editor;
|
13
|
+
private soundFeedback;
|
14
|
+
private toggleButton;
|
15
|
+
private toggleButtonContainer;
|
16
|
+
constructor(editor: Editor, description: string);
|
17
|
+
private updateToggleButtonText;
|
18
|
+
setEnabled(enabled: boolean): void;
|
19
|
+
private lastPointerPos;
|
20
|
+
onPointerDown({ current, allPointers }: PointerEvt): boolean;
|
21
|
+
onPointerMove({ current }: PointerEvt): void;
|
22
|
+
onPointerUp(_event: PointerEvt): void;
|
23
|
+
onGestureCancel(): void;
|
24
|
+
}
|
@@ -0,0 +1,158 @@
|
|
1
|
+
import Color4 from '../Color4.mjs';
|
2
|
+
import LineSegment2 from '../math/LineSegment2.mjs';
|
3
|
+
import BaseTool from './BaseTool.mjs';
|
4
|
+
class SoundFeedback {
|
5
|
+
constructor() {
|
6
|
+
this.closed = false;
|
7
|
+
// No AudioContext? Exit!
|
8
|
+
if (!window.AudioContext) {
|
9
|
+
console.warn('Accessibility sound UI: Unable to open AudioContext.');
|
10
|
+
this.closed = true;
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
this.ctx = new AudioContext();
|
14
|
+
// Color oscillator and gain
|
15
|
+
this.colorOscHue = this.ctx.createOscillator();
|
16
|
+
this.colorOscValue = this.ctx.createOscillator();
|
17
|
+
this.colorOscSaturation = this.ctx.createOscillator();
|
18
|
+
this.colorOscHue.type = 'triangle';
|
19
|
+
this.colorOscSaturation.type = 'sine';
|
20
|
+
this.colorOscValue.type = 'sawtooth';
|
21
|
+
this.valueGain = this.ctx.createGain();
|
22
|
+
this.colorOscValue.connect(this.valueGain);
|
23
|
+
this.valueGain.gain.setValueAtTime(0.18, this.ctx.currentTime);
|
24
|
+
this.colorGain = this.ctx.createGain();
|
25
|
+
this.colorOscHue.connect(this.colorGain);
|
26
|
+
this.valueGain.connect(this.colorGain);
|
27
|
+
this.colorOscSaturation.connect(this.colorGain);
|
28
|
+
this.colorGain.connect(this.ctx.destination);
|
29
|
+
// Boundary oscillator and gain
|
30
|
+
this.boundaryGain = this.ctx.createGain();
|
31
|
+
this.boundaryOsc = this.ctx.createOscillator();
|
32
|
+
this.boundaryOsc.type = 'sawtooth';
|
33
|
+
this.boundaryGain.gain.setValueAtTime(0, this.ctx.currentTime);
|
34
|
+
this.boundaryOsc.connect(this.boundaryGain);
|
35
|
+
this.boundaryGain.connect(this.ctx.destination);
|
36
|
+
// Prepare for the first announcement/feedback.
|
37
|
+
this.colorOscHue.start();
|
38
|
+
this.colorOscSaturation.start();
|
39
|
+
this.colorOscValue.start();
|
40
|
+
this.boundaryOsc.start();
|
41
|
+
this.pause();
|
42
|
+
}
|
43
|
+
pause() {
|
44
|
+
if (this.closed)
|
45
|
+
return;
|
46
|
+
this.colorGain.gain.setValueAtTime(0, this.ctx.currentTime);
|
47
|
+
void this.ctx.suspend();
|
48
|
+
}
|
49
|
+
play() {
|
50
|
+
if (this.closed)
|
51
|
+
return;
|
52
|
+
void this.ctx.resume();
|
53
|
+
}
|
54
|
+
setColor(color) {
|
55
|
+
const hsv = color.asHSV();
|
56
|
+
// Choose frequencies that roughly correspond to hue, saturation, and value.
|
57
|
+
const hueFrequency = (-Math.cos(hsv.x / 2)) * 220 + 440;
|
58
|
+
const saturationFrequency = hsv.y * 440 + 220;
|
59
|
+
const valueFrequency = (hsv.z + 0.1) * 440;
|
60
|
+
// Sigmoid with maximum 0.25 * alpha.
|
61
|
+
// Louder for greater value.
|
62
|
+
const gain = 0.25 * Math.min(1, color.a) / (1 + Math.exp(-(hsv.z - 0.5) * 3));
|
63
|
+
this.colorOscHue.frequency.setValueAtTime(hueFrequency, this.ctx.currentTime);
|
64
|
+
this.colorOscSaturation.frequency.setValueAtTime(saturationFrequency, this.ctx.currentTime);
|
65
|
+
this.colorOscValue.frequency.setValueAtTime(valueFrequency, this.ctx.currentTime);
|
66
|
+
this.valueGain.gain.setValueAtTime((1 - hsv.z) * 0.4, this.ctx.currentTime);
|
67
|
+
this.colorGain.gain.setValueAtTime(gain, this.ctx.currentTime);
|
68
|
+
}
|
69
|
+
announceBoundaryCross(boundaryCrossCount) {
|
70
|
+
this.boundaryGain.gain.cancelScheduledValues(this.ctx.currentTime);
|
71
|
+
this.boundaryGain.gain.setValueAtTime(0, this.ctx.currentTime);
|
72
|
+
this.boundaryGain.gain.linearRampToValueAtTime(0.018, this.ctx.currentTime + 0.1);
|
73
|
+
this.boundaryOsc.frequency.setValueAtTime(440 + Math.atan(boundaryCrossCount / 2) * 100, this.ctx.currentTime);
|
74
|
+
this.boundaryGain.gain.linearRampToValueAtTime(0, this.ctx.currentTime + 0.25);
|
75
|
+
}
|
76
|
+
close() {
|
77
|
+
this.ctx.close();
|
78
|
+
this.closed = true;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* This tool, when enabled, plays a sound representing the color of the portion of the display
|
83
|
+
* currently under the cursor. This tool adds a button that can be navigated to with the tab key
|
84
|
+
* that enables/disables the tool.
|
85
|
+
*
|
86
|
+
* This allows the user to explore the content of the display without a working screen.
|
87
|
+
*/
|
88
|
+
export default class SoundUITool extends BaseTool {
|
89
|
+
constructor(editor, description) {
|
90
|
+
super(editor.notifier, description);
|
91
|
+
this.editor = editor;
|
92
|
+
this.soundFeedback = null;
|
93
|
+
// Create a screen-reader-usable method of toggling the tool:
|
94
|
+
this.toggleButtonContainer = document.createElement('div');
|
95
|
+
this.toggleButtonContainer.classList.add('js-draw-sound-ui-toggle');
|
96
|
+
this.toggleButton = document.createElement('button');
|
97
|
+
this.toggleButton.onclick = () => {
|
98
|
+
this.setEnabled(!this.isEnabled());
|
99
|
+
};
|
100
|
+
this.toggleButtonContainer.appendChild(this.toggleButton);
|
101
|
+
this.updateToggleButtonText();
|
102
|
+
editor.createHTMLOverlay(this.toggleButtonContainer);
|
103
|
+
}
|
104
|
+
updateToggleButtonText() {
|
105
|
+
const containerEnabledClass = 'sound-ui-tool-enabled';
|
106
|
+
if (this.isEnabled()) {
|
107
|
+
this.toggleButton.innerText = this.editor.localization.disableAccessibilityExploreTool;
|
108
|
+
this.toggleButtonContainer.classList.add(containerEnabledClass);
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
this.toggleButton.innerText = this.editor.localization.enableAccessibilityExploreTool;
|
112
|
+
this.toggleButtonContainer.classList.remove(containerEnabledClass);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
setEnabled(enabled) {
|
116
|
+
var _a;
|
117
|
+
super.setEnabled(enabled);
|
118
|
+
if (!enabled) {
|
119
|
+
(_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.close();
|
120
|
+
this.soundFeedback = null;
|
121
|
+
}
|
122
|
+
this.updateToggleButtonText();
|
123
|
+
}
|
124
|
+
onPointerDown({ current, allPointers }) {
|
125
|
+
var _a, _b, _c;
|
126
|
+
if (!this.soundFeedback) {
|
127
|
+
this.soundFeedback = new SoundFeedback();
|
128
|
+
}
|
129
|
+
// Allow two-finger gestures to move the screen.
|
130
|
+
if (allPointers.length >= 2) {
|
131
|
+
return false;
|
132
|
+
}
|
133
|
+
// Accept multiple cursors -- some screen readers require multiple (touch) pointers to interact with
|
134
|
+
// an image instead of using the built-in navigation features.
|
135
|
+
(_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.play();
|
136
|
+
(_b = this.soundFeedback) === null || _b === void 0 ? void 0 : _b.setColor((_c = this.editor.display.getColorAt(current.screenPos)) !== null && _c !== void 0 ? _c : Color4.black);
|
137
|
+
this.lastPointerPos = current.canvasPos;
|
138
|
+
return true;
|
139
|
+
}
|
140
|
+
onPointerMove({ current }) {
|
141
|
+
var _a, _b, _c;
|
142
|
+
(_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.setColor((_b = this.editor.display.getColorAt(current.screenPos)) !== null && _b !== void 0 ? _b : Color4.black);
|
143
|
+
const pointerMotionLine = new LineSegment2(this.lastPointerPos, current.canvasPos);
|
144
|
+
const collisions = this.editor.image.getElementsIntersectingRegion(pointerMotionLine.bbox).filter(component => component.intersects(pointerMotionLine));
|
145
|
+
this.lastPointerPos = current.canvasPos;
|
146
|
+
if (collisions.length > 0) {
|
147
|
+
(_c = this.soundFeedback) === null || _c === void 0 ? void 0 : _c.announceBoundaryCross(collisions.length);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
onPointerUp(_event) {
|
151
|
+
var _a;
|
152
|
+
(_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.pause();
|
153
|
+
}
|
154
|
+
onGestureCancel() {
|
155
|
+
var _a;
|
156
|
+
(_a = this.soundFeedback) === null || _a === void 0 ? void 0 : _a.pause();
|
157
|
+
}
|
158
|
+
}
|
@@ -3,7 +3,7 @@ import Editor from '../Editor';
|
|
3
3
|
import { PointerEvt } from '../types';
|
4
4
|
import BaseTool from './BaseTool';
|
5
5
|
import { ToolLocalization } from './localization';
|
6
|
-
import
|
6
|
+
import TextRenderingStyle from '../rendering/TextRenderingStyle';
|
7
7
|
export default class TextTool extends BaseTool {
|
8
8
|
private editor;
|
9
9
|
private localizationTable;
|
@@ -28,6 +28,6 @@ export default class TextTool extends BaseTool {
|
|
28
28
|
setFontFamily(fontFamily: string): void;
|
29
29
|
setColor(color: Color4): void;
|
30
30
|
setFontSize(size: number): void;
|
31
|
-
getTextStyle():
|
31
|
+
getTextStyle(): TextRenderingStyle;
|
32
32
|
private setTextStyle;
|
33
33
|
}
|
@@ -14,6 +14,7 @@ import ToolbarShortcutHandler from './ToolbarShortcutHandler.mjs';
|
|
14
14
|
import { makePressureSensitiveFreehandLineBuilder } from '../components/builders/PressureSensitiveFreehandLineBuilder.mjs';
|
15
15
|
import FindTool from './FindTool.mjs';
|
16
16
|
import SelectAllShortcutHandler from './SelectionTool/SelectAllShortcutHandler.mjs';
|
17
|
+
import SoundUITool from './SoundUITool.mjs';
|
17
18
|
export default class ToolController {
|
18
19
|
/** @internal */
|
19
20
|
constructor(editor, localization) {
|
@@ -32,10 +33,14 @@ export default class ToolController {
|
|
32
33
|
new Eraser(editor, localization.eraserTool),
|
33
34
|
new SelectionTool(editor, localization.selectionTool),
|
34
35
|
new TextTool(editor, localization.textTool, localization),
|
35
|
-
new PanZoom(editor, PanZoomMode.SinglePointerGestures, localization.anyDevicePanning)
|
36
|
+
new PanZoom(editor, PanZoomMode.SinglePointerGestures, localization.anyDevicePanning),
|
36
37
|
];
|
38
|
+
// Accessibility tools
|
39
|
+
const soundExplorer = new SoundUITool(editor, localization.soundExplorer);
|
40
|
+
soundExplorer.setEnabled(false);
|
37
41
|
this.tools = [
|
38
42
|
new PipetteTool(editor, localization.pipetteTool),
|
43
|
+
soundExplorer,
|
39
44
|
panZoomTool,
|
40
45
|
...primaryTools,
|
41
46
|
keyboardPanZoomTool,
|
@@ -13,4 +13,5 @@ export { default as SelectionTool } from './SelectionTool/SelectionTool';
|
|
13
13
|
export { default as SelectAllShortcutHandler } from './SelectionTool/SelectAllShortcutHandler';
|
14
14
|
export { default as EraserTool } from './Eraser';
|
15
15
|
export { default as PasteHandler } from './PasteHandler';
|
16
|
+
export { default as SoundUITool } from './SoundUITool';
|
16
17
|
export { default as ToolbarShortcutHandler } from './ToolbarShortcutHandler';
|
@@ -13,4 +13,5 @@ export { default as SelectionTool } from './SelectionTool/SelectionTool.mjs';
|
|
13
13
|
export { default as SelectAllShortcutHandler } from './SelectionTool/SelectAllShortcutHandler.mjs';
|
14
14
|
export { default as EraserTool } from './Eraser.mjs';
|
15
15
|
export { default as PasteHandler } from './PasteHandler.mjs';
|
16
|
+
export { default as SoundUITool } from './SoundUITool.mjs';
|
16
17
|
export { default as ToolbarShortcutHandler } from './ToolbarShortcutHandler.mjs';
|
@@ -13,6 +13,9 @@ export interface ToolLocalization {
|
|
13
13
|
enterTextToInsert: string;
|
14
14
|
changeTool: string;
|
15
15
|
pasteHandler: string;
|
16
|
+
soundExplorer: string;
|
17
|
+
disableAccessibilityExploreTool: string;
|
18
|
+
enableAccessibilityExploreTool: string;
|
16
19
|
findLabel: string;
|
17
20
|
toNextMatch: string;
|
18
21
|
closeFindDialog: string;
|
@@ -13,6 +13,9 @@ export const defaultToolLocalization = {
|
|
13
13
|
enterTextToInsert: 'Text to insert',
|
14
14
|
changeTool: 'Change tool',
|
15
15
|
pasteHandler: 'Copy paste handler',
|
16
|
+
soundExplorer: 'Sound-based image exploration',
|
17
|
+
disableAccessibilityExploreTool: 'Disable sound-based exploration',
|
18
|
+
enableAccessibilityExploreTool: 'Enable sound-based exploration',
|
16
19
|
findLabel: 'Find',
|
17
20
|
toNextMatch: 'Next',
|
18
21
|
closeFindDialog: 'Close',
|
package/jest.config.js
CHANGED