@widgetic/canvas 0.5.45 → 0.5.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/canvas/DomCanvas.svelte +1 -2
- package/dist/canvas/autosaveScheduler.js +37 -89
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +7 -19
- package/dist/canvas/chromeLayout.js +19 -21
- package/dist/canvas/eventScope.js +10 -14
- package/dist/canvas/host/CanvasHost.d.ts +6 -5
- package/dist/canvas/host/CanvasHost.js +1664 -1861
- package/dist/canvas/host/CanvasHostApi.js +4 -19
- package/dist/canvas/host/boardFiles.js +35 -51
- package/dist/canvas/host/browserServices.js +108 -196
- package/dist/canvas/host/conversion.js +82 -170
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.js +18 -21
- package/dist/canvas/host/pageEvents.js +5 -5
- package/dist/canvas/host/pauseCollector.d.ts +18 -0
- package/dist/canvas/host/pauseCollector.js +45 -0
- package/dist/canvas/host/pictureSaves.js +9 -11
- package/dist/canvas/host/screenRects.js +28 -31
- package/dist/canvas/host/storedPictures.js +149 -243
- package/dist/canvas/host/strokeSnap.js +88 -143
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +6 -7
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +13 -25
- package/dist/canvas/shapes/ShapeLibrary.js +138 -148
- package/dist/canvas/shapes/shapeImageStore.js +4 -4
- package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/types.d.ts +7 -1
- package/dist/canvas/ui/CanvasContextMenu.svelte +40 -3
- package/dist/canvas/ui/CanvasHint.svelte +10 -9
- package/dist/canvas/ui/SelectionPanel.svelte +14 -12
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +0 -2
- package/dist/canvas/ui/ShapesMenu.svelte +6 -4
- package/dist/canvas/ui/ToolButton.svelte +7 -6
- package/dist/canvas/ui/colorModel.js +21 -32
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +28 -8
- package/dist/canvas/ui/floatingCard.js +48 -28
- package/dist/canvas/ui/floatingLayer.js +5 -6
- package/dist/canvas/ui/keyHints.js +9 -11
- package/dist/canvas/ui/popoverSide.js +2 -3
- package/dist/canvas/ui/selectionTraits.d.ts +8 -4
- package/dist/canvas/ui/selectionTraits.js +44 -58
- package/dist/canvas/view/CanvasStage.svelte +1 -1
- package/dist/canvas/view/SelectionOverlay.svelte +2 -2
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +72 -91
- package/dist/canvas/view/liftedScene.js +24 -36
- package/dist/canvas/view/mountedScene.js +76 -79
- package/dist/components/CanvasBoardPlaceholder.svelte +68 -10
- package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +10 -2
- package/dist/components/CanvasToolbarPlaceholder.svelte +25 -11
- package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +6 -0
- package/dist/components/boardLoaderDelay.d.ts +39 -0
- package/dist/components/boardLoaderDelay.js +71 -0
- package/dist/components/input-controls/ColorIC.svelte +1 -1
- package/dist/components/input-controls/FontSelectorIC.svelte +1 -1
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +42 -10
- package/dist/engine/EngineCore.js +843 -916
- package/dist/engine/codec/canvasDocument.js +192 -155
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +26 -38
- package/dist/engine/core/arrow.js +79 -92
- package/dist/engine/core/arrowBinding.js +98 -116
- package/dist/engine/core/arrowBindingRecords.js +23 -38
- package/dist/engine/core/brush.d.ts +24 -0
- package/dist/engine/core/brush.js +223 -103
- package/dist/engine/core/cameraMove.js +39 -51
- package/dist/engine/core/defaults.js +92 -51
- package/dist/engine/core/freehand.js +147 -163
- package/dist/engine/core/geometry.js +47 -54
- package/dist/engine/core/history.js +38 -55
- package/dist/engine/core/hitTest.js +68 -81
- package/dist/engine/core/matrix.js +18 -20
- package/dist/engine/core/pathData.js +183 -210
- package/dist/engine/core/rotationReset.js +5 -6
- package/dist/engine/core/scene.js +160 -224
- package/dist/engine/core/scribble.js +59 -84
- package/dist/engine/core/shapePaths.js +12 -15
- package/dist/engine/core/shapeTools.d.ts +23 -18
- package/dist/engine/core/shapeTools.js +104 -67
- package/dist/engine/core/snapping.js +65 -117
- package/dist/engine/core/style.d.ts +18 -2
- package/dist/engine/core/style.js +79 -80
- package/dist/engine/core/styleMemory.d.ts +88 -0
- package/dist/engine/core/styleMemory.js +189 -0
- package/dist/engine/core/transform.js +84 -95
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +23 -36
- package/dist/engine/input/PointerController.js +513 -526
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.d.ts +8 -3
- package/dist/engine/input/gestures.js +378 -346
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.js +42 -41
- package/dist/engine/input/selectionHandles.js +45 -50
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +86 -158
- package/dist/engine/state.js +6 -17
- package/dist/engine/text/layoutText.js +43 -62
- package/dist/engine/text/textMetrics.js +8 -10
- package/dist/engine/widgets.js +101 -137
- package/dist/fonts/interFont.js +30 -83
- package/dist/fonts/workspaceFonts.js +33 -92
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.js +1 -1
- package/dist/i18n/shortcuts.js +14 -14
- package/dist/index.d.ts +1 -1
- package/dist/poster/boardPlacement.d.ts +4 -1
- package/dist/poster/boardPlacement.js +34 -33
- package/dist/poster/boardPoster.js +58 -83
- package/dist/poster/paintBoardPoster.js +16 -39
- package/dist/poster/posterPictures.js +27 -43
- package/dist/settings/rememberedStyles.d.ts +22 -0
- package/dist/settings/rememberedStyles.js +47 -0
- package/dist/settings/rememberedTool.d.ts +50 -0
- package/dist/settings/rememberedTool.js +68 -0
- package/dist/settings/workspaceToolSettings.d.ts +25 -0
- package/dist/settings/workspaceToolSettings.js +38 -48
- package/dist/tools/components/catalog.js +64 -74
- package/dist/tools/components/grouping.js +6 -28
- package/dist/tools/definitions.js +5 -5
- package/dist/tools/executors.js +137 -169
- package/dist/tools/hostAdapter.js +10 -13
- package/dist/tools/sceneSummary.js +43 -57
- package/dist/tools/sketchIntent.js +13 -21
- package/dist/tools/styleArguments.js +19 -21
- package/dist/tools/types.js +1 -1
- package/package.json +5 -5
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Rotation is clockwise on screen (y grows downward), which is what CSS `rotate()` does.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
|
|
10
10
|
/** Converts degrees to radians. */
|
|
11
11
|
export function degreesToRadians(degrees) {
|
|
12
12
|
return (degrees * Math.PI) / 180;
|
|
@@ -17,25 +17,24 @@ export function radiansToDegrees(radians) {
|
|
|
17
17
|
}
|
|
18
18
|
/** Brings an angle into [0, 360). */
|
|
19
19
|
export function normalizeDegrees(degrees) {
|
|
20
|
-
|
|
20
|
+
const wrapped = degrees % 360;
|
|
21
21
|
return wrapped < 0 ? wrapped + 360 : wrapped;
|
|
22
22
|
}
|
|
23
23
|
/** Brings an angle into (-180, 180]: the shortest signed turn. */
|
|
24
24
|
export function normalizeSignedDegrees(degrees) {
|
|
25
|
-
|
|
25
|
+
const wrapped = normalizeDegrees(degrees);
|
|
26
26
|
return wrapped > 180 ? wrapped - 360 : wrapped;
|
|
27
27
|
}
|
|
28
28
|
export function translationMatrix(translateX, translateY) {
|
|
29
29
|
return [1, 0, 0, 1, translateX, translateY];
|
|
30
30
|
}
|
|
31
|
-
export function scalingMatrix(scaleX, scaleY) {
|
|
32
|
-
if (scaleY === void 0) { scaleY = scaleX; }
|
|
31
|
+
export function scalingMatrix(scaleX, scaleY = scaleX) {
|
|
33
32
|
return [scaleX, 0, 0, scaleY, 0, 0];
|
|
34
33
|
}
|
|
35
34
|
export function rotationMatrix(degrees) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const radians = degreesToRadians(degrees);
|
|
36
|
+
const cosine = Math.cos(radians);
|
|
37
|
+
const sine = Math.sin(radians);
|
|
39
38
|
return [cosine, sine, -sine, cosine, 0, 0];
|
|
40
39
|
}
|
|
41
40
|
/** Rotation about a point other than the origin. */
|
|
@@ -47,8 +46,8 @@ export function rotationAboutMatrix(degrees, centerX, centerY) {
|
|
|
47
46
|
* (the same order as `DOMMatrix.multiply`).
|
|
48
47
|
*/
|
|
49
48
|
export function multiplyMatrices(first, second) {
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const [a1, b1, c1, d1, e1, f1] = first;
|
|
50
|
+
const [a2, b2, c2, d2, e2, f2] = second;
|
|
52
51
|
return [
|
|
53
52
|
a1 * a2 + c1 * b2,
|
|
54
53
|
b1 * a2 + d1 * b2,
|
|
@@ -60,11 +59,11 @@ export function multiplyMatrices(first, second) {
|
|
|
60
59
|
}
|
|
61
60
|
/** The matrix that undoes `matrix`, or null when it flattens the plane (zero determinant). */
|
|
62
61
|
export function invertMatrix(matrix) {
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const [a, b, c, d, e, f] = matrix;
|
|
63
|
+
const determinant = a * d - b * c;
|
|
65
64
|
if (Math.abs(determinant) < 1e-12)
|
|
66
65
|
return null;
|
|
67
|
-
|
|
66
|
+
const inverseDeterminant = 1 / determinant;
|
|
68
67
|
return [
|
|
69
68
|
d * inverseDeterminant,
|
|
70
69
|
-b * inverseDeterminant,
|
|
@@ -75,12 +74,12 @@ export function invertMatrix(matrix) {
|
|
|
75
74
|
];
|
|
76
75
|
}
|
|
77
76
|
export function applyMatrixToPoint(matrix, point) {
|
|
78
|
-
|
|
77
|
+
const [a, b, c, d, e, f] = matrix;
|
|
79
78
|
return { x: a * point.x + c * point.y + e, y: b * point.x + d * point.y + f };
|
|
80
79
|
}
|
|
81
80
|
/** The scale the matrix applies along each axis (ignores skew, which the board never produces). */
|
|
82
81
|
export function matrixScale(matrix) {
|
|
83
|
-
|
|
82
|
+
const [a, b, c, d] = matrix;
|
|
84
83
|
return { scaleX: Math.hypot(a, b), scaleY: Math.hypot(c, d) };
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
@@ -88,14 +87,13 @@ export function matrixScale(matrix) {
|
|
|
88
87
|
* width by height) onto the world.
|
|
89
88
|
*/
|
|
90
89
|
export function boxToWorldMatrix(box) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return multiplyMatrices(translationMatrix(box.x + halfWidth, box.y + halfHeight), multiplyMatrices(rotationMatrix((_a = box.rotation) !== null && _a !== void 0 ? _a : 0), translationMatrix(-halfWidth, -halfHeight)));
|
|
90
|
+
const halfWidth = box.width / 2;
|
|
91
|
+
const halfHeight = box.height / 2;
|
|
92
|
+
return multiplyMatrices(translationMatrix(box.x + halfWidth, box.y + halfHeight), multiplyMatrices(rotationMatrix(box.rotation ?? 0), translationMatrix(-halfWidth, -halfHeight)));
|
|
95
93
|
}
|
|
96
94
|
/** The CSS value of a matrix, with the digits trimmed so a style string does not grow for nothing. */
|
|
97
95
|
export function matrixToCss(matrix) {
|
|
98
|
-
return
|
|
96
|
+
return `matrix(${matrix.map((value) => Number(value.toFixed(5))).join(', ')})`;
|
|
99
97
|
}
|
|
100
98
|
/** The six numbers of a matrix as a fresh array (for JSON). */
|
|
101
99
|
export function matrixToArray(matrix) {
|