@widgetic/canvas 0.5.35 → 0.5.37

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.
Files changed (210) hide show
  1. package/README.md +105 -36
  2. package/dist/canvas/DomCanvas.svelte +449 -0
  3. package/dist/canvas/DomCanvas.svelte.d.ts +221 -0
  4. package/dist/canvas/boardFrame.d.ts +13 -0
  5. package/dist/canvas/boardFrame.js +13 -0
  6. package/dist/canvas/boardSurface.d.ts +9 -0
  7. package/dist/canvas/boardSurface.js +9 -0
  8. package/dist/canvas/chromeLayout.d.ts +76 -0
  9. package/dist/canvas/chromeLayout.js +121 -0
  10. package/dist/canvas/emptyBoardHint.d.ts +17 -0
  11. package/dist/canvas/emptyBoardHint.js +12 -0
  12. package/dist/canvas/eventScope.d.ts +1 -1
  13. package/dist/canvas/eventScope.js +1 -1
  14. package/dist/canvas/host/CanvasHost.d.ts +348 -0
  15. package/dist/canvas/host/CanvasHost.js +1715 -0
  16. package/dist/canvas/host/CanvasHostApi.d.ts +30 -0
  17. package/dist/canvas/host/CanvasHostApi.js +95 -0
  18. package/dist/canvas/host/browserServices.d.ts +46 -0
  19. package/dist/canvas/host/browserServices.js +167 -0
  20. package/dist/canvas/host/conversion.d.ts +53 -0
  21. package/dist/canvas/host/conversion.js +125 -0
  22. package/dist/canvas/host/hostObject.d.ts +40 -0
  23. package/dist/canvas/host/hostObject.js +93 -0
  24. package/dist/canvas/host/pageEvents.d.ts +24 -0
  25. package/dist/canvas/host/pageEvents.js +35 -0
  26. package/dist/canvas/host/screenRects.d.ts +66 -0
  27. package/dist/canvas/host/screenRects.js +102 -0
  28. package/dist/canvas/host/strokeSnap.d.ts +67 -0
  29. package/dist/canvas/host/strokeSnap.js +165 -0
  30. package/dist/canvas/index.d.ts +7 -7
  31. package/dist/canvas/index.js +8 -8
  32. package/dist/canvas/openMarks.d.ts +17 -0
  33. package/dist/canvas/openMarks.js +26 -0
  34. package/dist/canvas/panZoomPosition.d.ts +15 -0
  35. package/dist/canvas/panZoomPosition.js +16 -0
  36. package/dist/canvas/preferredTextFont.d.ts +12 -0
  37. package/dist/canvas/preferredTextFont.js +38 -0
  38. package/dist/canvas/shapes/ShapeLibrary.d.ts +1 -1
  39. package/dist/canvas/shapes/ShapeLibrary.js +13 -1
  40. package/dist/canvas/shapes/strokeShapeSnap.d.ts +14 -12
  41. package/dist/canvas/shapes/strokeShapeSnap.js +10 -8
  42. package/dist/canvas/toolbarPosition.d.ts +11 -11
  43. package/dist/canvas/toolbarPosition.js +11 -24
  44. package/dist/canvas/types.d.ts +14 -0
  45. package/dist/canvas/ui/CanvasContextMenu.svelte +173 -0
  46. package/dist/canvas/ui/CanvasContextMenu.svelte.d.ts +12 -0
  47. package/dist/canvas/ui/CanvasHint.svelte +21 -0
  48. package/dist/canvas/ui/CanvasHint.svelte.d.ts +18 -0
  49. package/dist/canvas/ui/CanvasToolbar.svelte +95 -0
  50. package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +14 -0
  51. package/dist/canvas/ui/ColorField.svelte +156 -0
  52. package/dist/canvas/ui/ColorField.svelte.d.ts +14 -0
  53. package/dist/canvas/ui/LoadNotice.svelte +39 -0
  54. package/dist/canvas/ui/LoadNotice.svelte.d.ts +8 -0
  55. package/dist/canvas/ui/SelectionPanel.svelte +300 -0
  56. package/dist/canvas/ui/SelectionPanel.svelte.d.ts +20 -0
  57. package/dist/canvas/ui/SelectorBar.svelte +82 -0
  58. package/dist/canvas/ui/SelectorBar.svelte.d.ts +12 -0
  59. package/dist/canvas/ui/ShapesMenu.svelte +185 -0
  60. package/dist/canvas/ui/ShapesMenu.svelte.d.ts +15 -0
  61. package/dist/canvas/ui/ShortcutsPanel.svelte +124 -0
  62. package/dist/canvas/ui/ShortcutsPanel.svelte.d.ts +7 -0
  63. package/dist/canvas/ui/ToolButton.svelte +78 -0
  64. package/dist/canvas/ui/ToolButton.svelte.d.ts +20 -0
  65. package/dist/canvas/ui/WidgetActions.svelte +145 -0
  66. package/dist/canvas/ui/WidgetActions.svelte.d.ts +19 -0
  67. package/dist/canvas/ui/ZoomControl.svelte +89 -0
  68. package/dist/canvas/ui/ZoomControl.svelte.d.ts +18 -0
  69. package/dist/canvas/ui/colorModel.d.ts +18 -0
  70. package/dist/canvas/ui/colorModel.js +85 -0
  71. package/dist/canvas/ui/colorPickerMessages.d.ts +5 -0
  72. package/dist/canvas/ui/colorPickerMessages.js +15 -0
  73. package/dist/canvas/ui/floatingCard.d.ts +107 -0
  74. package/dist/canvas/ui/floatingCard.js +107 -0
  75. package/dist/canvas/ui/floatingLayer.d.ts +21 -0
  76. package/dist/canvas/ui/floatingLayer.js +52 -0
  77. package/dist/canvas/ui/icons.d.ts +12 -0
  78. package/dist/canvas/ui/icons.js +7 -0
  79. package/dist/canvas/ui/keyHints.d.ts +27 -0
  80. package/dist/canvas/ui/keyHints.js +43 -0
  81. package/dist/canvas/ui/popoverSide.d.ts +5 -0
  82. package/dist/canvas/ui/popoverSide.js +20 -0
  83. package/dist/canvas/ui/selectionTraits.d.ts +61 -0
  84. package/dist/canvas/ui/selectionTraits.js +99 -0
  85. package/dist/canvas/view/CanvasStage.svelte +132 -0
  86. package/dist/canvas/view/CanvasStage.svelte.d.ts +21 -0
  87. package/dist/canvas/view/EraserTrail.svelte +50 -0
  88. package/dist/canvas/view/EraserTrail.svelte.d.ts +9 -0
  89. package/dist/canvas/view/ObjectView.svelte +245 -0
  90. package/dist/canvas/view/ObjectView.svelte.d.ts +21 -0
  91. package/dist/canvas/view/SelectionOverlay.svelte +487 -0
  92. package/dist/canvas/view/SelectionOverlay.svelte.d.ts +17 -0
  93. package/dist/canvas/view/TextEditor.svelte +76 -0
  94. package/dist/canvas/view/TextEditor.svelte.d.ts +9 -0
  95. package/dist/canvas/view/WidgetChromeLayer.svelte +83 -0
  96. package/dist/canvas/view/WidgetChromeLayer.svelte.d.ts +13 -0
  97. package/dist/canvas/view/erasingMarks.d.ts +13 -0
  98. package/dist/canvas/view/erasingMarks.js +34 -0
  99. package/dist/canvas/view/geometry.d.ts +169 -0
  100. package/dist/canvas/view/geometry.js +272 -0
  101. package/dist/components/CanvasBoardPlaceholder.svelte +5 -3
  102. package/dist/components/CanvasBoardPlaceholder.svelte.d.ts +3 -3
  103. package/dist/components/index.js +1 -1
  104. package/dist/components/input-controls/ColorIC.svelte +2 -2
  105. package/dist/engine/EngineCore.d.ts +273 -0
  106. package/dist/engine/EngineCore.js +1051 -0
  107. package/dist/engine/codec/canvasDocument.d.ts +57 -0
  108. package/dist/engine/codec/canvasDocument.js +471 -0
  109. package/dist/engine/codec/hostReadableKeys.d.ts +25 -0
  110. package/dist/engine/codec/hostReadableKeys.js +25 -0
  111. package/dist/engine/core/arrange.d.ts +20 -0
  112. package/dist/engine/core/arrange.js +81 -0
  113. package/dist/engine/core/arrow.d.ts +91 -0
  114. package/dist/engine/core/arrow.js +182 -0
  115. package/dist/engine/core/brush.d.ts +68 -0
  116. package/dist/engine/core/brush.js +173 -0
  117. package/dist/engine/core/defaults.d.ts +70 -0
  118. package/dist/engine/core/defaults.js +158 -0
  119. package/dist/engine/core/freehand.d.ts +130 -0
  120. package/dist/engine/core/freehand.js +430 -0
  121. package/dist/engine/core/geometry.d.ts +44 -0
  122. package/dist/engine/core/geometry.js +216 -0
  123. package/dist/engine/core/history.d.ts +39 -0
  124. package/dist/engine/core/history.js +69 -0
  125. package/dist/engine/core/hitTest.d.ts +54 -0
  126. package/dist/engine/core/hitTest.js +298 -0
  127. package/dist/engine/core/matrix.d.ts +47 -0
  128. package/dist/engine/core/matrix.js +101 -0
  129. package/dist/engine/core/pathData.d.ts +50 -0
  130. package/dist/engine/core/pathData.js +550 -0
  131. package/dist/engine/core/rotationReset.d.ts +10 -0
  132. package/dist/engine/core/rotationReset.js +17 -0
  133. package/dist/engine/core/scene.d.ts +99 -0
  134. package/dist/engine/core/scene.js +450 -0
  135. package/dist/engine/core/scribble.d.ts +64 -0
  136. package/dist/engine/core/scribble.js +121 -0
  137. package/dist/engine/core/shapePaths.d.ts +34 -0
  138. package/dist/engine/core/shapePaths.js +69 -0
  139. package/dist/engine/core/shapeTools.d.ts +80 -0
  140. package/dist/engine/core/shapeTools.js +161 -0
  141. package/dist/engine/core/snapping.d.ts +64 -0
  142. package/dist/engine/core/snapping.js +164 -0
  143. package/dist/engine/core/style.d.ts +40 -0
  144. package/dist/engine/core/style.js +151 -0
  145. package/dist/engine/core/transform.d.ts +79 -0
  146. package/dist/engine/core/transform.js +258 -0
  147. package/dist/engine/core/types.d.ts +238 -0
  148. package/dist/engine/core/types.js +31 -0
  149. package/dist/engine/core/viewport.d.ts +32 -0
  150. package/dist/engine/core/viewport.js +84 -0
  151. package/dist/engine/input/PointerController.d.ts +38 -0
  152. package/dist/engine/input/PointerController.js +545 -0
  153. package/dist/engine/input/arrowHandles.d.ts +38 -0
  154. package/dist/engine/input/arrowHandles.js +60 -0
  155. package/dist/engine/input/gestures.d.ts +79 -0
  156. package/dist/engine/input/gestures.js +769 -0
  157. package/dist/engine/input/hoverCursor.d.ts +29 -0
  158. package/dist/engine/input/hoverCursor.js +23 -0
  159. package/dist/engine/input/keyboard.d.ts +75 -0
  160. package/dist/engine/input/keyboard.js +264 -0
  161. package/dist/engine/input/selectionHandles.d.ts +89 -0
  162. package/dist/engine/input/selectionHandles.js +169 -0
  163. package/dist/engine/input/types.d.ts +82 -0
  164. package/dist/engine/input/types.js +5 -0
  165. package/dist/engine/render/rasterize.d.ts +74 -0
  166. package/dist/engine/render/rasterize.js +273 -0
  167. package/dist/engine/state.d.ts +124 -0
  168. package/dist/engine/state.js +47 -0
  169. package/dist/engine/text/layoutText.d.ts +53 -0
  170. package/dist/engine/text/layoutText.js +170 -0
  171. package/dist/engine/widgets.d.ts +124 -0
  172. package/dist/engine/widgets.js +345 -0
  173. package/dist/i18n/labels.d.ts +4 -15
  174. package/dist/i18n/labels.js +33 -53
  175. package/dist/i18n/language.d.ts +3 -3
  176. package/dist/i18n/messages.d.ts +52 -124
  177. package/dist/i18n/messages.js +59 -133
  178. package/dist/i18n/shortcuts.d.ts +0 -1
  179. package/dist/i18n/shortcuts.js +2 -11
  180. package/dist/index.d.ts +4 -2
  181. package/dist/index.js +5 -3
  182. package/package.json +30 -5
  183. package/dist/canvas/Canvas.svelte +0 -13363
  184. package/dist/canvas/Canvas.svelte.d.ts +0 -286
  185. package/dist/canvas/CanvasToolbar.svelte +0 -1498
  186. package/dist/canvas/CanvasToolbar.svelte.d.ts +0 -69
  187. package/dist/canvas/ContextMenu.svelte +0 -305
  188. package/dist/canvas/ContextMenu.svelte.d.ts +0 -42
  189. package/dist/canvas/PanZoomPanel.svelte +0 -478
  190. package/dist/canvas/PanZoomPanel.svelte.d.ts +0 -38
  191. package/dist/canvas/WidgetSelectionLayer.svelte +0 -156
  192. package/dist/canvas/WidgetSelectionLayer.svelte.d.ts +0 -11
  193. package/dist/canvas/props-panel/PropsPanel.svelte +0 -2075
  194. package/dist/canvas/props-panel/PropsPanel.svelte.d.ts +0 -84
  195. package/dist/canvas/props-panel/TextPropsICSection.svelte +0 -242
  196. package/dist/canvas/props-panel/TextPropsICSection.svelte.d.ts +0 -40
  197. package/dist/canvas/shadowRootText.d.ts +0 -5
  198. package/dist/canvas/shadowRootText.js +0 -43
  199. package/dist/canvas/shapes/FrameShape.d.ts +0 -97
  200. package/dist/canvas/shapes/FrameShape.js +0 -953
  201. package/dist/canvas/shapes/ImageShape.d.ts +0 -47
  202. package/dist/canvas/shapes/ImageShape.js +0 -339
  203. package/dist/canvas/shapes/WidgetShape.d.ts +0 -30
  204. package/dist/canvas/shapes/WidgetShape.js +0 -200
  205. package/dist/canvas/widgetPreviewGeometry.d.ts +0 -19
  206. package/dist/canvas/widgetPreviewGeometry.js +0 -66
  207. package/dist/i18n/shapeWords.d.ts +0 -30
  208. package/dist/i18n/shapeWords.js +0 -36
  209. package/dist/i18n/slots.d.ts +0 -20
  210. package/dist/i18n/slots.js +0 -40
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 2D affine matrices, in the order and meaning of CSS `matrix(a, b, c, d, e, f)`:
3
+ *
4
+ * x' = a·x + c·y + e
5
+ * y' = b·x + d·y + f
6
+ *
7
+ * Rotation is clockwise on screen (y grows downward), which is what CSS `rotate()` does.
8
+ */
9
+ import type { Matrix, Point, Rect } from './types.js';
10
+ export declare const IDENTITY_MATRIX: Matrix;
11
+ /** Converts degrees to radians. */
12
+ export declare function degreesToRadians(degrees: number): number;
13
+ /** Converts radians to degrees. */
14
+ export declare function radiansToDegrees(radians: number): number;
15
+ /** Brings an angle into [0, 360). */
16
+ export declare function normalizeDegrees(degrees: number): number;
17
+ /** Brings an angle into (-180, 180]: the shortest signed turn. */
18
+ export declare function normalizeSignedDegrees(degrees: number): number;
19
+ export declare function translationMatrix(translateX: number, translateY: number): Matrix;
20
+ export declare function scalingMatrix(scaleX: number, scaleY?: number): Matrix;
21
+ export declare function rotationMatrix(degrees: number): Matrix;
22
+ /** Rotation about a point other than the origin. */
23
+ export declare function rotationAboutMatrix(degrees: number, centerX: number, centerY: number): Matrix;
24
+ /**
25
+ * `first × second`: the result applies `second` to a point first, then `first`
26
+ * (the same order as `DOMMatrix.multiply`).
27
+ */
28
+ export declare function multiplyMatrices(first: Matrix, second: Matrix): Matrix;
29
+ /** The matrix that undoes `matrix`, or null when it flattens the plane (zero determinant). */
30
+ export declare function invertMatrix(matrix: Matrix): Matrix | null;
31
+ export declare function applyMatrixToPoint(matrix: Matrix, point: Point): Point;
32
+ /** The scale the matrix applies along each axis (ignores skew, which the board never produces). */
33
+ export declare function matrixScale(matrix: Matrix): {
34
+ scaleX: number;
35
+ scaleY: number;
36
+ };
37
+ /**
38
+ * The matrix that maps the local space of a box (0, 0 at the top-left of the unrotated box, spanning
39
+ * width by height) onto the world.
40
+ */
41
+ export declare function boxToWorldMatrix(box: Rect & {
42
+ rotation?: number;
43
+ }): Matrix;
44
+ /** The CSS value of a matrix, with the digits trimmed so a style string does not grow for nothing. */
45
+ export declare function matrixToCss(matrix: Matrix): string;
46
+ /** The six numbers of a matrix as a fresh array (for JSON). */
47
+ export declare function matrixToArray(matrix: Matrix): number[];
@@ -0,0 +1,101 @@
1
+ /**
2
+ * 2D affine matrices, in the order and meaning of CSS `matrix(a, b, c, d, e, f)`:
3
+ *
4
+ * x' = a·x + c·y + e
5
+ * y' = b·x + d·y + f
6
+ *
7
+ * Rotation is clockwise on screen (y grows downward), which is what CSS `rotate()` does.
8
+ */
9
+ export const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
10
+ /** Converts degrees to radians. */
11
+ export function degreesToRadians(degrees) {
12
+ return (degrees * Math.PI) / 180;
13
+ }
14
+ /** Converts radians to degrees. */
15
+ export function radiansToDegrees(radians) {
16
+ return (radians * 180) / Math.PI;
17
+ }
18
+ /** Brings an angle into [0, 360). */
19
+ export function normalizeDegrees(degrees) {
20
+ const wrapped = degrees % 360;
21
+ return wrapped < 0 ? wrapped + 360 : wrapped;
22
+ }
23
+ /** Brings an angle into (-180, 180]: the shortest signed turn. */
24
+ export function normalizeSignedDegrees(degrees) {
25
+ const wrapped = normalizeDegrees(degrees);
26
+ return wrapped > 180 ? wrapped - 360 : wrapped;
27
+ }
28
+ export function translationMatrix(translateX, translateY) {
29
+ return [1, 0, 0, 1, translateX, translateY];
30
+ }
31
+ export function scalingMatrix(scaleX, scaleY = scaleX) {
32
+ return [scaleX, 0, 0, scaleY, 0, 0];
33
+ }
34
+ export function rotationMatrix(degrees) {
35
+ const radians = degreesToRadians(degrees);
36
+ const cosine = Math.cos(radians);
37
+ const sine = Math.sin(radians);
38
+ return [cosine, sine, -sine, cosine, 0, 0];
39
+ }
40
+ /** Rotation about a point other than the origin. */
41
+ export function rotationAboutMatrix(degrees, centerX, centerY) {
42
+ return multiplyMatrices(translationMatrix(centerX, centerY), multiplyMatrices(rotationMatrix(degrees), translationMatrix(-centerX, -centerY)));
43
+ }
44
+ /**
45
+ * `first × second`: the result applies `second` to a point first, then `first`
46
+ * (the same order as `DOMMatrix.multiply`).
47
+ */
48
+ export function multiplyMatrices(first, second) {
49
+ const [a1, b1, c1, d1, e1, f1] = first;
50
+ const [a2, b2, c2, d2, e2, f2] = second;
51
+ return [
52
+ a1 * a2 + c1 * b2,
53
+ b1 * a2 + d1 * b2,
54
+ a1 * c2 + c1 * d2,
55
+ b1 * c2 + d1 * d2,
56
+ a1 * e2 + c1 * f2 + e1,
57
+ b1 * e2 + d1 * f2 + f1
58
+ ];
59
+ }
60
+ /** The matrix that undoes `matrix`, or null when it flattens the plane (zero determinant). */
61
+ export function invertMatrix(matrix) {
62
+ const [a, b, c, d, e, f] = matrix;
63
+ const determinant = a * d - b * c;
64
+ if (Math.abs(determinant) < 1e-12)
65
+ return null;
66
+ const inverseDeterminant = 1 / determinant;
67
+ return [
68
+ d * inverseDeterminant,
69
+ -b * inverseDeterminant,
70
+ -c * inverseDeterminant,
71
+ a * inverseDeterminant,
72
+ (c * f - d * e) * inverseDeterminant,
73
+ (b * e - a * f) * inverseDeterminant
74
+ ];
75
+ }
76
+ export function applyMatrixToPoint(matrix, point) {
77
+ const [a, b, c, d, e, f] = matrix;
78
+ return { x: a * point.x + c * point.y + e, y: b * point.x + d * point.y + f };
79
+ }
80
+ /** The scale the matrix applies along each axis (ignores skew, which the board never produces). */
81
+ export function matrixScale(matrix) {
82
+ const [a, b, c, d] = matrix;
83
+ return { scaleX: Math.hypot(a, b), scaleY: Math.hypot(c, d) };
84
+ }
85
+ /**
86
+ * The matrix that maps the local space of a box (0, 0 at the top-left of the unrotated box, spanning
87
+ * width by height) onto the world.
88
+ */
89
+ export function boxToWorldMatrix(box) {
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)));
93
+ }
94
+ /** The CSS value of a matrix, with the digits trimmed so a style string does not grow for nothing. */
95
+ export function matrixToCss(matrix) {
96
+ return `matrix(${matrix.map((value) => Number(value.toFixed(5))).join(', ')})`;
97
+ }
98
+ /** The six numbers of a matrix as a fresh array (for JSON). */
99
+ export function matrixToArray(matrix) {
100
+ return [matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]];
101
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * SVG path data as a list of absolute commands, and what the canvas does with one: read any `d` string
3
+ * (relative commands, H, V, S, T and arcs included), write it back compactly, measure it exactly, move,
4
+ * scale and mirror it, and flatten it into polylines for hit testing.
5
+ *
6
+ * A command is `['M', x, y]`, `['L', x, y]`, `['Q', x1, y1, x, y]`, `['C', x1, y1, x2, y2, x, y]` or `['Z']`.
7
+ * Every other command of the SVG grammar is turned into one of these when it is read, so everything
8
+ * downstream handles five cases.
9
+ */
10
+ import type { Matrix, Point, Rect } from './types.js';
11
+ export type PathCommand = ['M', number, number] | ['L', number, number] | ['Q', number, number, number, number] | ['C', number, number, number, number, number, number] | ['Z'];
12
+ /** One connected piece of a flattened path. */
13
+ export interface FlatSubpath {
14
+ points: Point[];
15
+ closed: boolean;
16
+ }
17
+ /**
18
+ * Reads SVG path data into absolute `M`, `L`, `Q`, `C` and `Z` commands.
19
+ * Anything it cannot read ends the path where it stands (the part before it is kept), like a browser does.
20
+ */
21
+ export declare function parsePathData(data: string): PathCommand[];
22
+ /** Writes commands as compact path data: `M0 0L10 10Z`. */
23
+ export declare function serializePathData(commands: readonly PathCommand[], decimals?: number): string;
24
+ export declare function transformPathCommands(commands: readonly PathCommand[], matrix: Matrix): PathCommand[];
25
+ export declare function translatePathCommands(commands: readonly PathCommand[], deltaX: number, deltaY: number): PathCommand[];
26
+ export declare function scalePathCommands(commands: readonly PathCommand[], scaleX: number, scaleY: number): PathCommand[];
27
+ /** Mirrors the path inside a box of the given size, about the box's vertical and/or horizontal middle line. */
28
+ export declare function mirrorPathCommands(commands: readonly PathCommand[], width: number, height: number, flipX: boolean, flipY: boolean): PathCommand[];
29
+ /** The exact bounding box of a path (curves measured at their extrema, not by their control points). Null when empty. */
30
+ export declare function pathBounds(commands: readonly PathCommand[]): Rect | null;
31
+ /**
32
+ * Cuts a path into polylines. Curves are cut every `segmentLength` units of their control polygon
33
+ * (at least 2 and at most 48 pieces), which is plenty for hit tests and the eraser.
34
+ */
35
+ export declare function flattenPath(commands: readonly PathCommand[], segmentLength?: number): FlatSubpath[];
36
+ /**
37
+ * Moves and scales a path so that its tight bounding box becomes exactly 0..width by 0..height.
38
+ * A flat axis (a straight horizontal or vertical line) is centred in its axis instead of scaled.
39
+ */
40
+ export declare function fitPathToBox(commands: readonly PathCommand[], width: number, height: number): PathCommand[];
41
+ /**
42
+ * Moves a path so that its bounding box starts at 0, 0 and reports where the box was.
43
+ * This is how a drawn stroke becomes an object: the path is local, the box says where it stands.
44
+ */
45
+ export declare function localizePath(commands: readonly PathCommand[]): {
46
+ commands: PathCommand[];
47
+ bounds: Rect;
48
+ } | null;
49
+ /** A polyline (or polygon) as path commands. */
50
+ export declare function polylineToPathCommands(points: readonly Point[], closed: boolean): PathCommand[];