@motionscript/math 0.1.0-alpha.5 → 0.1.0-alpha.6

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 (233) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +39 -33
  3. package/dist/annotate/angle-mark.d.ts +52 -27
  4. package/dist/annotate/angle-mark.d.ts.map +1 -1
  5. package/dist/annotate/angle-mark.js +80 -115
  6. package/dist/annotate/angle-mark.js.map +1 -1
  7. package/dist/annotate/curly-brace.d.ts +59 -25
  8. package/dist/annotate/curly-brace.d.ts.map +1 -1
  9. package/dist/annotate/curly-brace.js +85 -100
  10. package/dist/annotate/curly-brace.js.map +1 -1
  11. package/dist/annotate/emphasis-mark.d.ts +43 -9
  12. package/dist/annotate/emphasis-mark.d.ts.map +1 -1
  13. package/dist/annotate/emphasis-mark.js +33 -34
  14. package/dist/annotate/emphasis-mark.js.map +1 -1
  15. package/dist/browser/chunks/chunk-ABYBW64J.js +2 -0
  16. package/dist/browser/chunks/chunk-ABYBW64J.js.map +7 -0
  17. package/dist/browser/chunks/chunk-K77KLQX4.js +2 -0
  18. package/dist/browser/chunks/chunk-K77KLQX4.js.map +7 -0
  19. package/dist/browser/index.js +1 -1
  20. package/dist/browser/index.js.map +3 -3
  21. package/dist/browser/kit.js +1 -1
  22. package/dist/browser/manifest.json +1 -1
  23. package/dist/browser/tex.js +1 -1
  24. package/dist/browser/tex.js.map +2 -2
  25. package/dist/engine.d.ts +26 -19
  26. package/dist/engine.d.ts.map +1 -1
  27. package/dist/engine.js +17 -14
  28. package/dist/engine.js.map +1 -1
  29. package/dist/kit/component.d.ts +51 -0
  30. package/dist/kit/component.d.ts.map +1 -0
  31. package/dist/kit/component.js +30 -0
  32. package/dist/kit/component.js.map +1 -0
  33. package/dist/kit/curve.d.ts +22 -11
  34. package/dist/kit/curve.d.ts.map +1 -1
  35. package/dist/kit/curve.js +25 -18
  36. package/dist/kit/curve.js.map +1 -1
  37. package/dist/kit/field-mark.d.ts +58 -35
  38. package/dist/kit/field-mark.d.ts.map +1 -1
  39. package/dist/kit/field-mark.js +100 -120
  40. package/dist/kit/field-mark.js.map +1 -1
  41. package/dist/kit/follow.d.ts +67 -29
  42. package/dist/kit/follow.d.ts.map +1 -1
  43. package/dist/kit/follow.js +114 -110
  44. package/dist/kit/follow.js.map +1 -1
  45. package/dist/kit/furniture.d.ts +3 -1
  46. package/dist/kit/furniture.d.ts.map +1 -1
  47. package/dist/kit/furniture.js +5 -0
  48. package/dist/kit/furniture.js.map +1 -1
  49. package/dist/kit/graph.d.ts +46 -0
  50. package/dist/kit/graph.d.ts.map +1 -0
  51. package/dist/kit/graph.js +90 -0
  52. package/dist/kit/graph.js.map +1 -0
  53. package/dist/kit/mark.d.ts +64 -39
  54. package/dist/kit/mark.d.ts.map +1 -1
  55. package/dist/kit/mark.js +80 -96
  56. package/dist/kit/mark.js.map +1 -1
  57. package/dist/kit/place.d.ts +10 -8
  58. package/dist/kit/place.d.ts.map +1 -1
  59. package/dist/kit/place.js +28 -30
  60. package/dist/kit/place.js.map +1 -1
  61. package/dist/kit/system.d.ts +27 -29
  62. package/dist/kit/system.d.ts.map +1 -1
  63. package/dist/kit/system.js +62 -58
  64. package/dist/kit/system.js.map +1 -1
  65. package/dist/kit/withdrawn.d.ts +3 -3
  66. package/dist/kit/withdrawn.js +3 -3
  67. package/dist/kit/withdrawn.js.map +1 -1
  68. package/dist/marks/curve-area.d.ts +24 -18
  69. package/dist/marks/curve-area.d.ts.map +1 -1
  70. package/dist/marks/curve-area.js +50 -73
  71. package/dist/marks/curve-area.js.map +1 -1
  72. package/dist/marks/drop-lines.d.ts +28 -10
  73. package/dist/marks/drop-lines.d.ts.map +1 -1
  74. package/dist/marks/drop-lines.js +37 -52
  75. package/dist/marks/drop-lines.js.map +1 -1
  76. package/dist/marks/plot-point.d.ts +37 -20
  77. package/dist/marks/plot-point.d.ts.map +1 -1
  78. package/dist/marks/plot-point.js +65 -91
  79. package/dist/marks/plot-point.js.map +1 -1
  80. package/dist/marks/riemann-sum.d.ts +30 -26
  81. package/dist/marks/riemann-sum.d.ts.map +1 -1
  82. package/dist/marks/riemann-sum.js +57 -85
  83. package/dist/marks/riemann-sum.js.map +1 -1
  84. package/dist/marks/tangent-line.d.ts +38 -14
  85. package/dist/marks/tangent-line.d.ts.map +1 -1
  86. package/dist/marks/tangent-line.js +73 -87
  87. package/dist/marks/tangent-line.js.map +1 -1
  88. package/dist/marks/vector-arrow.d.ts +30 -20
  89. package/dist/marks/vector-arrow.d.ts.map +1 -1
  90. package/dist/marks/vector-arrow.js +58 -78
  91. package/dist/marks/vector-arrow.js.map +1 -1
  92. package/dist/nodes.d.ts +13 -5
  93. package/dist/nodes.d.ts.map +1 -1
  94. package/dist/nodes.js +0 -6
  95. package/dist/nodes.js.map +1 -1
  96. package/dist/plots/function-plot.d.ts +107 -43
  97. package/dist/plots/function-plot.d.ts.map +1 -1
  98. package/dist/plots/function-plot.js +146 -177
  99. package/dist/plots/function-plot.js.map +1 -1
  100. package/dist/plots/points-plot.d.ts +34 -19
  101. package/dist/plots/points-plot.d.ts.map +1 -1
  102. package/dist/plots/points-plot.js +31 -58
  103. package/dist/plots/points-plot.js.map +1 -1
  104. package/dist/plots/stream-lines.d.ts +38 -19
  105. package/dist/plots/stream-lines.d.ts.map +1 -1
  106. package/dist/plots/stream-lines.js +60 -79
  107. package/dist/plots/stream-lines.js.map +1 -1
  108. package/dist/plots/traced-path.d.ts +34 -15
  109. package/dist/plots/traced-path.d.ts.map +1 -1
  110. package/dist/plots/traced-path.js +33 -48
  111. package/dist/plots/traced-path.js.map +1 -1
  112. package/dist/plots/vector-field.d.ts +31 -11
  113. package/dist/plots/vector-field.d.ts.map +1 -1
  114. package/dist/plots/vector-field.js +50 -64
  115. package/dist/plots/vector-field.js.map +1 -1
  116. package/dist/structures/network-graph.d.ts +99 -49
  117. package/dist/structures/network-graph.d.ts.map +1 -1
  118. package/dist/structures/network-graph.js +168 -217
  119. package/dist/structures/network-graph.js.map +1 -1
  120. package/dist/structures/sample-space.d.ts +69 -38
  121. package/dist/structures/sample-space.d.ts.map +1 -1
  122. package/dist/structures/sample-space.js +132 -170
  123. package/dist/structures/sample-space.js.map +1 -1
  124. package/dist/systems/axes2d.d.ts +126 -37
  125. package/dist/systems/axes2d.d.ts.map +1 -1
  126. package/dist/systems/axes2d.js +147 -183
  127. package/dist/systems/axes2d.js.map +1 -1
  128. package/dist/systems/number-line.d.ts +51 -28
  129. package/dist/systems/number-line.d.ts.map +1 -1
  130. package/dist/systems/number-line.js +82 -118
  131. package/dist/systems/number-line.js.map +1 -1
  132. package/dist/systems/number-plane.d.ts +92 -31
  133. package/dist/systems/number-plane.d.ts.map +1 -1
  134. package/dist/systems/number-plane.js +142 -149
  135. package/dist/systems/number-plane.js.map +1 -1
  136. package/dist/systems/polar-plane.d.ts +47 -26
  137. package/dist/systems/polar-plane.d.ts.map +1 -1
  138. package/dist/systems/polar-plane.js +107 -133
  139. package/dist/systems/polar-plane.js.map +1 -1
  140. package/dist/tex/index.d.ts.map +1 -1
  141. package/dist/tex/index.js +1 -0
  142. package/dist/tex/index.js.map +1 -1
  143. package/dist/tex/matrix.d.ts +56 -18
  144. package/dist/tex/matrix.d.ts.map +1 -1
  145. package/dist/tex/matrix.js +33 -50
  146. package/dist/tex/matrix.js.map +1 -1
  147. package/dist/tex/node.d.ts +55 -201
  148. package/dist/tex/node.d.ts.map +1 -1
  149. package/dist/tex/node.js +23 -593
  150. package/dist/tex/node.js.map +1 -1
  151. package/dist/tex/typeset.d.ts +133 -0
  152. package/dist/tex/typeset.d.ts.map +1 -0
  153. package/dist/tex/typeset.js +403 -0
  154. package/dist/tex/typeset.js.map +1 -0
  155. package/dist/three/axes3d.d.ts +140 -54
  156. package/dist/three/axes3d.d.ts.map +1 -1
  157. package/dist/three/axes3d.js +159 -204
  158. package/dist/three/axes3d.js.map +1 -1
  159. package/dist/three/curve-plot3d.d.ts +70 -42
  160. package/dist/three/curve-plot3d.d.ts.map +1 -1
  161. package/dist/three/curve-plot3d.js +97 -132
  162. package/dist/three/curve-plot3d.js.map +1 -1
  163. package/dist/three/entries.d.ts +17 -0
  164. package/dist/three/entries.d.ts.map +1 -0
  165. package/dist/three/entries.js +15 -0
  166. package/dist/three/entries.js.map +1 -0
  167. package/dist/three/plot-point3d.d.ts +57 -12
  168. package/dist/three/plot-point3d.d.ts.map +1 -1
  169. package/dist/three/plot-point3d.js +27 -53
  170. package/dist/three/plot-point3d.js.map +1 -1
  171. package/dist/three/space.d.ts +17 -2
  172. package/dist/three/space.d.ts.map +1 -1
  173. package/dist/three/space.js +19 -8
  174. package/dist/three/space.js.map +1 -1
  175. package/dist/three/surface-plot3d.d.ts +131 -49
  176. package/dist/three/surface-plot3d.d.ts.map +1 -1
  177. package/dist/three/surface-plot3d.js +227 -261
  178. package/dist/three/surface-plot3d.js.map +1 -1
  179. package/dist/three/vector-arrow3d.d.ts +58 -16
  180. package/dist/three/vector-arrow3d.d.ts.map +1 -1
  181. package/dist/three/vector-arrow3d.js +48 -67
  182. package/dist/three/vector-arrow3d.js.map +1 -1
  183. package/package.json +4 -4
  184. package/src/annotate/angle-mark.ts +95 -105
  185. package/src/annotate/curly-brace.ts +107 -85
  186. package/src/annotate/emphasis-mark.ts +55 -26
  187. package/src/engine.ts +35 -21
  188. package/src/kit/component.ts +57 -0
  189. package/src/kit/curve.ts +38 -20
  190. package/src/kit/field-mark.ts +124 -108
  191. package/src/kit/follow.ts +146 -120
  192. package/src/kit/furniture.ts +6 -1
  193. package/src/kit/graph.ts +116 -0
  194. package/src/kit/mark.ts +135 -114
  195. package/src/kit/place.ts +32 -56
  196. package/src/kit/system.ts +77 -71
  197. package/src/kit/withdrawn.ts +3 -3
  198. package/src/marks/curve-area.ts +65 -65
  199. package/src/marks/drop-lines.ts +50 -42
  200. package/src/marks/plot-point.ts +77 -82
  201. package/src/marks/riemann-sum.ts +73 -72
  202. package/src/marks/tangent-line.ts +87 -71
  203. package/src/marks/vector-arrow.ts +73 -73
  204. package/src/nodes.ts +41 -5
  205. package/src/plots/function-plot.ts +155 -171
  206. package/src/plots/points-plot.ts +46 -50
  207. package/src/plots/stream-lines.ts +75 -66
  208. package/src/plots/traced-path.ts +51 -33
  209. package/src/plots/vector-field.ts +68 -49
  210. package/src/structures/network-graph.ts +168 -185
  211. package/src/structures/sample-space.ts +149 -148
  212. package/src/systems/axes2d.ts +165 -156
  213. package/src/systems/number-line.ts +91 -92
  214. package/src/systems/number-plane.ts +149 -120
  215. package/src/systems/polar-plane.ts +117 -116
  216. package/src/tex/index.ts +2 -1
  217. package/src/tex/matrix.ts +62 -40
  218. package/src/tex/node.ts +54 -621
  219. package/src/tex/typeset.ts +461 -0
  220. package/src/three/axes3d.ts +182 -161
  221. package/src/three/curve-plot3d.ts +107 -110
  222. package/src/three/entries.ts +42 -0
  223. package/src/three/plot-point3d.ts +42 -45
  224. package/src/three/space.ts +34 -9
  225. package/src/three/surface-plot3d.ts +312 -323
  226. package/src/three/vector-arrow3d.ts +65 -54
  227. package/dist/browser/chunks/chunk-3GJB6AVO.js +0 -2
  228. package/dist/browser/chunks/chunk-3GJB6AVO.js.map +0 -7
  229. package/dist/browser/chunks/chunk-D5WHCVBC.js +0 -2
  230. package/dist/browser/chunks/chunk-D5WHCVBC.js.map +0 -7
  231. package/dist/browser/chunks/chunk-WL4KEX7Y.js +0 -2
  232. package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +0 -7
  233. package/src/kit/placement.ts +0 -8
@@ -1,11 +1,5 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { command, node, property } from "@motionscript/sdk";
8
- import { Latex } from "./node.js";
1
+ import { component2d, Types, } from "@motionscript/sdk";
2
+ import { drawFormula, formula, formulaFrame, layoutFormula, lerpMorph, loadFormula, measureFormula, morphOf, TYPESET, TYPESET_COMMANDS, } from "./typeset.js";
9
3
  const ENVIRONMENT = {
10
4
  square: "bmatrix",
11
5
  round: "pmatrix",
@@ -14,6 +8,7 @@ const ENVIRONMENT = {
14
8
  curly: "Bmatrix",
15
9
  none: "matrix",
16
10
  };
11
+ const BRACKETS = ["square", "round", "bar", "double", "curly", "none"];
17
12
  /** The LaTeX a matrix of `entries` is typeset from; empty for one with no entries. */
18
13
  export function matrixSource(entries, brackets = "square") {
19
14
  const rows = entries.filter((row) => Array.isArray(row) && row.length > 0);
@@ -22,52 +17,40 @@ export function matrixSource(entries, brackets = "square") {
22
17
  const environment = ENVIRONMENT[brackets] ?? ENVIRONMENT.square;
23
18
  return `\\begin{${environment}} ${rows.map((row) => row.join(" & ")).join(" \\\\ ")} \\end{${environment}}`;
24
19
  }
25
- // A list of rows is a whole value: it changes at the end of a tween, and the morph draws the way there.
26
- // (A function, not a generic arrow: a copied component is compiled as TSX, where `<T>(` opens an element.)
27
- function atTheEnd(from, to, t) {
28
- return t < 1 ? from : to;
20
+ /** The matrix's source now: mid-tween of its entries or its brackets, both ends of it. */
21
+ function sourceOf(s) {
22
+ return morphOf([s.entries, s.brackets], ([entries, brackets]) => matrixSource(entries, brackets));
29
23
  }
24
+ const state = {
25
+ ...TYPESET,
26
+ // Unused by the matrix's own drawing: its entries say what it writes.
27
+ latex: Types.custom("", {
28
+ kind: "text", multiline: true, lerp: lerpMorph,
29
+ }),
30
+ /** A list of rows is a whole value: mid-tween it holds both, and the morph draws the way there. */
31
+ entries: Types.custom([["a", "b"], ["c", "d"]], { lerp: lerpMorph }),
32
+ brackets: Types.custom("square", {
33
+ options: BRACKETS, animatable: false, lerp: lerpMorph,
34
+ }),
35
+ };
30
36
  /**
31
37
  * A matrix typeset from its entries, row by row, inside the brackets it is
32
38
  * given. Each entry is a piece of LaTeX and is one of the formula's parts, so
33
39
  * it can be painted, boxed or braced by its own source.
34
40
  */
35
- let LatexMatrix = class LatexMatrix extends Latex {
36
- constructor(props) {
37
- super(props);
38
- }
39
- /** Change the entries: the ones both matrices write travel, the rest fade. */
40
- entriesTo(args) {
41
- const entries = args.data?.entries;
42
- return this.to({ data: (entries === undefined ? {} : { entries }), duration: args.duration, easing: args.easing });
43
- }
44
- _source(next = {}) {
45
- return matrixSource(next.entries ?? this.entries, next.brackets ?? this.brackets);
46
- }
47
- _sourceProps(next = {}) {
48
- return { entries: next.entries ?? this.entries, brackets: next.brackets ?? this.brackets };
49
- }
50
- _resets(next) {
51
- return next.entries !== undefined || next.brackets !== undefined || next.fontSize !== undefined;
52
- }
53
- };
54
- __decorate([
55
- property({ default: [["a", "b"], ["c", "d"]], tween: atTheEnd })
56
- ], LatexMatrix.prototype, "entries", void 0);
57
- __decorate([
58
- property({ default: "square", options: ["square", "round", "bar", "double", "curly", "none"], animatable: false })
59
- ], LatexMatrix.prototype, "brackets", void 0);
60
- __decorate([
61
- command({ args: ["entries"] })
62
- ], LatexMatrix.prototype, "entriesTo", null);
63
- LatexMatrix = __decorate([
64
- node({
65
- key: "latexMatrix",
66
- parentKey: "latex",
67
- forkable: true,
68
- layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: true },
69
- seed: { fill: [{ type: "solid", color: [0.412, 0.565, 0.867, 1], opacity: 1, enabled: true }] },
70
- })
71
- ], LatexMatrix);
72
- export { LatexMatrix };
41
+ export const LatexMatrix = formula(component2d({
42
+ key: "latexMatrix",
43
+ state,
44
+ defaults: { width: "hug", height: "hug" },
45
+ load: (loader) => loadFormula(loader),
46
+ commands: {
47
+ ...TYPESET_COMMANDS,
48
+ morphTo: { args: ["latex"] },
49
+ /** Change the entries: the ones both matrices write travel, the rest fade. */
50
+ entriesTo: { args: ["entries"] },
51
+ },
52
+ measure: (_measurer, s) => measureFormula(formulaFrame(sourceOf(s), s.fontSize, s.partFills), s),
53
+ layout: (box, s, children) => layoutFormula(box, s, children),
54
+ render: (ctx, s) => drawFormula(ctx, s, formulaFrame(sourceOf(s), s.fontSize, s.partFills)),
55
+ }), sourceOf);
73
56
  //# sourceMappingURL=matrix.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../src/tex/matrix.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAmD,MAAM,mBAAmB,CAAC;AAC7G,OAAO,EAAE,KAAK,EAAmB,MAAM,QAAQ,CAAC;AAShD,MAAM,WAAW,GAAmC;IAChD,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,QAAQ;CACjB,CAAC;AAEF,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,OAAuC,EAAE,WAA2B,QAAQ;IACrG,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3E,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC;IAChE,OAAO,WAAW,WAAW,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,WAAW,GAAG,CAAC;AAChH,CAAC;AAED,wGAAw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E,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;4CAA6B;AAEtF;IADP,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;6CAClF;AAQjC;IADC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;4CAI9B;AAdQ,WAAW;IAPvB,IAAI,CAAC;QACF,GAAG,EAAE,aAAa;QAClB,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE;QAC1G,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;KAClG,CAAC;GACW,WAAW,CA2BvB","sourcesContent":["import { command, node, property, type Command, type CommandArgs, type NodeConfig } from \"@motionscript/sdk\";\r\nimport { Latex, type LatexProps } from \"./node\";\r\n\r\nexport type MatrixBrackets = \"square\" | \"round\" | \"bar\" | \"double\" | \"curly\" | \"none\";\r\n\r\nexport interface LatexMatrixProps extends LatexProps {\r\n entries: string[][];\r\n brackets: MatrixBrackets;\r\n}\r\n\r\nconst ENVIRONMENT: Record<MatrixBrackets, string> = {\r\n square: \"bmatrix\",\r\n round: \"pmatrix\",\r\n bar: \"vmatrix\",\r\n double: \"Vmatrix\",\r\n curly: \"Bmatrix\",\r\n none: \"matrix\",\r\n};\r\n\r\n/** The LaTeX a matrix of `entries` is typeset from; empty for one with no entries. */\r\nexport function matrixSource(entries: readonly (readonly string[])[], brackets: MatrixBrackets = \"square\"): string {\r\n const rows = entries.filter((row) => Array.isArray(row) && row.length > 0);\r\n if (rows.length === 0) return \"\";\r\n const environment = ENVIRONMENT[brackets] ?? ENVIRONMENT.square;\r\n return `\\\\begin{${environment}} ${rows.map((row) => row.join(\" & \")).join(\" \\\\\\\\ \")} \\\\end{${environment}}`;\r\n}\r\n\r\n// A list of rows is a whole value: it changes at the end of a tween, and the morph draws the way there.\r\n// (A function, not a generic arrow: a copied component is compiled as TSX, where `<T>(` opens an element.)\r\nfunction atTheEnd<T>(from: T, to: T, t: number): T {\r\n return t < 1 ? from : to;\r\n}\r\n\r\ntype MatrixNext = Partial<LatexMatrixProps>;\r\n\r\n/**\r\n * A matrix typeset from its entries, row by row, inside the brackets it is\r\n * given. Each entry is a piece of LaTeX and is one of the formula's parts, so\r\n * it can be painted, boxed or braced by its own source.\r\n */\r\n@node({\r\n key: \"latexMatrix\",\r\n parentKey: \"latex\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"hug\", defaultHeightMode: \"hug\", acceptsChildren: true },\r\n seed: { fill: [{ type: \"solid\", color: [0.412, 0.565, 0.867, 1], opacity: 1, enabled: true }] },\r\n})\r\nexport class LatexMatrix extends Latex {\r\n @property({ default: [[\"a\", \"b\"], [\"c\", \"d\"]], tween: atTheEnd }) declare entries: string[][];\r\n @property({ default: \"square\", options: [\"square\", \"round\", \"bar\", \"double\", \"curly\", \"none\"], animatable: false })\r\n declare brackets: MatrixBrackets;\r\n\r\n constructor(props?: NodeConfig<LatexMatrix, LatexMatrixProps>) {\r\n super(props as never);\r\n }\r\n\r\n /** Change the entries: the ones both matrices write travel, the rest fade. */\r\n @command({ args: [\"entries\"] })\r\n entriesTo(args: CommandArgs<{ entries: string[][] }> & { duration: number }): Command<LatexProps> {\r\n const entries = args.data?.entries;\r\n return this.to({ data: (entries === undefined ? {} : { entries }) as Partial<LatexProps>, duration: args.duration, easing: args.easing });\r\n }\r\n\r\n override _source(next: MatrixNext = {}): string {\r\n return matrixSource(next.entries ?? this.entries, next.brackets ?? this.brackets);\r\n }\r\n\r\n override _sourceProps(next: MatrixNext = {}): Partial<LatexProps> {\r\n return { entries: next.entries ?? this.entries, brackets: next.brackets ?? this.brackets } as Partial<LatexProps>;\r\n }\r\n\r\n override _resets(next: MatrixNext): boolean {\r\n return next.entries !== undefined || next.brackets !== undefined || next.fontSize !== undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"matrix.js","sourceRoot":"","sources":["../../src/tex/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAiBR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACH,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAEhI,MAAM,WAAW,CAAC;AASnB,MAAM,WAAW,GAAmC;IAChD,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAEhF,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,OAAuC,EAAE,WAA2B,QAAQ;IACrG,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3E,IAAI,IA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AAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;IACzC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;IACrC,QAAQ,EAAE;QACN,GAAG,gBAAgB;QACnB,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE;QAC5B,8EAA8E;QAC9E,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;KACnC;IACD,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAChG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;CAC9F,CAAC,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import {\r\n component2d,\r\n Types,\r\n type EntryOptions,\r\n type NodeOf,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Alignment as _Alignment,\r\n type Fill as _Fill,\r\n type FillResolved as _FillResolved,\r\n type FlowMode as _FlowMode,\r\n type FlowResolved as _FlowResolved,\r\n type GapSize as _GapSize,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n type Stroke as _Stroke,\r\n type StrokeResolved as _StrokeResolved,\r\n type Vector2 as _Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport type { LatexProps } from \"./node\";\r\nimport {\r\n drawFormula, formula, formulaFrame, layoutFormula, lerpMorph, loadFormula, measureFormula, morphOf, TYPESET, TYPESET_COMMANDS,\r\n type Morphing,\r\n} from \"./typeset\";\r\n\r\nexport type MatrixBrackets = \"square\" | \"round\" | \"bar\" | \"double\" | \"curly\" | \"none\";\r\n\r\nexport interface LatexMatrixProps extends LatexProps {\r\n entries: string[][];\r\n brackets: MatrixBrackets;\r\n}\r\n\r\nconst ENVIRONMENT: Record<MatrixBrackets, string> = {\r\n square: \"bmatrix\",\r\n round: \"pmatrix\",\r\n bar: \"vmatrix\",\r\n double: \"Vmatrix\",\r\n curly: \"Bmatrix\",\r\n none: \"matrix\",\r\n};\r\n\r\nconst BRACKETS = [\"square\", \"round\", \"bar\", \"double\", \"curly\", \"none\"] as const;\r\n\r\n/** The LaTeX a matrix of `entries` is typeset from; empty for one with no entries. */\r\nexport function matrixSource(entries: readonly (readonly string[])[], brackets: MatrixBrackets = \"square\"): string {\r\n const rows = entries.filter((row) => Array.isArray(row) && row.length > 0);\r\n if (rows.length === 0) return \"\";\r\n const environment = ENVIRONMENT[brackets] ?? ENVIRONMENT.square;\r\n return `\\\\begin{${environment}} ${rows.map((row) => row.join(\" & \")).join(\" \\\\\\\\ \")} \\\\end{${environment}}`;\r\n}\r\n\r\ninterface MatrixValues {\r\n readonly entries: Morphing<string[][]>;\r\n readonly brackets: Morphing<MatrixBrackets>;\r\n}\r\n\r\n/** The matrix's source now: mid-tween of its entries or its brackets, both ends of it. */\r\nfunction sourceOf(s: MatrixValues): Morphing<string> {\r\n return morphOf([s.entries, s.brackets], ([entries, brackets]) => matrixSource(entries as string[][], brackets as MatrixBrackets));\r\n}\r\n\r\nconst state = {\r\n ...TYPESET,\r\n // Unused by the matrix's own drawing: its entries say what it writes.\r\n latex: Types.custom<string, Morphing<string>, EntryOptions & { readonly kind: \"text\"; readonly multiline: true }>(\"\", {\r\n kind: \"text\", multiline: true, lerp: lerpMorph,\r\n }),\r\n /** A list of rows is a whole value: mid-tween it holds both, and the morph draws the way there. */\r\n entries: Types.custom<string[][], Morphing<string[][]>>([[\"a\", \"b\"], [\"c\", \"d\"]], { lerp: lerpMorph }),\r\n brackets: Types.custom<MatrixBrackets, Morphing<MatrixBrackets>, EntryOptions & { readonly options: typeof BRACKETS }>(\"square\", {\r\n options: BRACKETS, animatable: false, lerp: lerpMorph,\r\n }),\r\n};\r\n\r\n/**\r\n * A matrix typeset from its entries, row by row, inside the brackets it is\r\n * given. Each entry is a piece of LaTeX and is one of the formula's parts, so\r\n * it can be painted, boxed or braced by its own source.\r\n */\r\nexport const LatexMatrix = formula(component2d({\r\n key: \"latexMatrix\",\r\n state,\r\n defaults: { width: \"hug\", height: \"hug\" },\r\n load: (loader) => loadFormula(loader),\r\n commands: {\r\n ...TYPESET_COMMANDS,\r\n morphTo: { args: [\"latex\"] },\r\n /** Change the entries: the ones both matrices write travel, the rest fade. */\r\n entriesTo: { args: [\"entries\"] },\r\n },\r\n measure: (_measurer, s) => measureFormula(formulaFrame(sourceOf(s), s.fontSize, s.partFills), s),\r\n layout: (box, s, children) => layoutFormula(box, s, children),\r\n render: (ctx, s) => drawFormula(ctx, s, formulaFrame(sourceOf(s), s.fontSize, s.partFills)),\r\n}), sourceOf);\r\n\r\nexport type LatexMatrix = NodeOf<typeof LatexMatrix>;\r\n"]}
@@ -1,6 +1,7 @@
1
- import { RenderContext2D, EasingFunction, NodeConfig, ShapeNode, ShapeProps, InsetsProps, Size2D, SizeConstraints, InsetsResolved, type AssetScope, type BoxBounds, type Command, type CommandArgs, type Fill } from "@motionscript/sdk";
2
- import { type LatexMorphStrategy } from "./tween.js";
3
- import { type PartFill } from "../kit/part-fills.js";
1
+ import { type InsetsProps, type NodeOf, type ShapeProps, type Alignment as _Alignment, type Fill as _Fill, type FillResolved as _FillResolved, type FlowMode as _FlowMode, type FlowResolved as _FlowResolved, type GapSize as _GapSize, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved, type Vector2 as _Vector2 } from "@motionscript/sdk";
2
+ import type { PartFill } from "../kit/part-fills.js";
3
+ import { type Morphing } from "./typeset.js";
4
+ import type { LatexMorphStrategy } from "./tween.js";
4
5
  export interface LatexProps extends ShapeProps {
5
6
  latex: string;
6
7
  fontSize: number;
@@ -9,207 +10,60 @@ export interface LatexProps extends ShapeProps {
9
10
  written: number;
10
11
  }
11
12
  /**
12
- * Construction-time-only options: pluggable engine behavior, set once when
13
- * the node is created. Deliberately *not* part of {@link LatexProps} — every
14
- * `@property` field accepts either a value or a zero-arg reactive binding
15
- * (`value | (() => value)`, see `PropInputs`), and the node's own reactive
16
- * write path (`_writeProp`) treats any function value as the latter. A
17
- * strategy *is* a function, so it can't be told apart from a binding that
18
- * computes one — it has to stay outside the reactive prop system entirely.
13
+ * How a formula morphs, for a node built on the `Typeset` helpers: they take it
14
+ * as an argument (`formulaFrame(source, fontSize, partFills, morph)`).
19
15
  */
20
16
  export interface LatexStrategies {
21
17
  /** How the node morphs between two formulas. Defaults to `defaultLatexMorph`. */
22
18
  morph?: LatexMorphStrategy;
23
19
  }
24
- export declare class Latex extends ShapeNode<LatexProps> {
25
- readonly latex: string;
26
- readonly fontSize: number;
27
- readonly padding: InsetsResolved;
28
- /** Paints for parts of the formula, named by their source. Later entries win where two name a glyph. */
29
- partFills: PartFill[];
30
- /**
31
- * How much of the formula is written, 0 to 1: its glyphs are drawn one after
32
- * another, each outlined and then filled.
33
- */
34
- written: number;
35
- /**
36
- * How this node morphs between two formulas. Construction-time-only (see
37
- * {@link LatexStrategies}) — resolved once here rather than left as
38
- * `?? defaultLatexMorph` at every call site.
39
- */
40
- private readonly morph;
41
- private _intrinsicWidth;
42
- private _intrinsicHeight;
43
- /**
44
- * Shared center frame for all current tokens, [minX, minY, maxX, maxY] in
45
- * token space. Passed to every per-token path so glyphs keep their relative
46
- * layout instead of each centering on its own bbox.
47
- */
48
- private _bounds;
49
- /** Current tokens to render. Each has its own opacity for tween transitions. */
50
- private _tokens;
51
- /** The parts of the formula `_tokens` was built from; empty while a morph holds the tokens. */
52
- private _parts;
53
- /** While a morph holds the tokens: each end's colours by token, and how far between them it is. */
54
- private _morphFills;
55
- /**
56
- * How far through a morph the playhead is, in `(0, 1)` while one is
57
- * driving frames and `0` otherwise: the node's own signal, not a prop an
58
- * author states.
59
- *
60
- * A prop rather than a field because it is the one thing the timeline
61
- * restores. The morph writes the tokens, the box and the intrinsic size
62
- * straight onto the node, so nothing else says whether what is on screen is
63
- * a morph frame; and a seek from inside a morph to a time before it
64
- * evaluates no command at all. Restored to `0` with every other prop, this
65
- * is how the node learns the playhead has left the morph.
66
- */
67
- morphProgress: number;
68
- /** Suppresses retokenization while a custom to() is driving frames. */
69
- private _animating;
70
- /** The `fontSize|latex` the live tokens were built from. See {@link _ensureTokens}. */
71
- private _tokenizedFrom;
72
- constructor(props?: NodeConfig<Latex, LatexProps> & LatexStrategies);
73
- /**
74
- * Rebuild the token list when the formula or size has moved since it last
75
- * was built.
76
- *
77
- * Pulled from every reader rather than pushed from a prop write, because
78
- * `latex` can be a binding — and a binding has no write to hang a
79
- * subscription on. The key is what the current tokens were built from;
80
- * `_animating` hands ownership to the morph command for its open interval.
81
- */
82
- private _ensureTokens;
83
- /** MathJax, before this node is laid out: a scene with no formula in it never loads it. */
84
- declareAssets(assets: AssetScope): void;
85
- /** @internal The formula typeset once `next` is laid over the node's own props: `latex` here, a subclass's own props there. */
86
- _source(next?: Partial<LatexProps>): string;
87
- /** @internal The props that state the formula, as `next` leaves them: what a morph commits at its end. */
88
- _sourceProps(next?: Partial<LatexProps>): Partial<LatexProps>;
89
- /** @internal Whether `next` re-sets the glyphs, and so is a morph rather than an ordinary tween. */
90
- _resets(next: Partial<LatexProps>): boolean;
91
- private _updateTokens;
92
- private _clearTokens;
93
- measure(constraints: SizeConstraints): Partial<Size2D>;
94
- /**
95
- * A LaTeX morph — one {@link Command}, like every other `to()`.
96
- *
97
- * Sequence two of them with `sequence(...)` rather than chaining: the chain
98
- * builder this used to return existed only so `latexRef().to(a, 1).to(b, 1)`
99
- * would read as two steps, and it could not compose with anything that was
100
- * not another Latex morph.
101
- */
102
- to<D extends Partial<LatexProps> = Partial<LatexProps>>(args: CommandArgs<D> & {
103
- duration: number;
104
- }): Command<LatexProps>;
105
- /**
106
- * Morph this formula into another — a document-facing name for {@link to},
107
- * which already routes through {@link _buildMorph}.
108
- */
109
- morphTo(args: CommandArgs<{
110
- latex: string;
111
- }> & {
112
- duration: number;
113
- }): Command<LatexProps>;
114
- /** Write the formula on, or off: its glyphs one after another, each outlined and then filled. */
115
- writeTo(args: CommandArgs<{
116
- written: number;
117
- }> & {
118
- duration: number;
119
- }): Command<LatexProps>;
120
- /** Paint one part of the formula, leaving the rest as it is. */
121
- partFillTo(args: CommandArgs<{
122
- part: string;
123
- fill: Fill;
124
- occurrence?: number;
125
- }> & {
126
- duration: number;
127
- }): Command<LatexProps>;
128
- /**
129
- * The box around one part of the formula, centred on the node's own centre
130
- * and y-up, or `null` when the formula does not write `part`. `occurrence`
131
- * counts from 1.
132
- */
133
- partBounds(part: string, occurrence?: number): BoxBounds | null;
134
- /**
135
- * Build a single LaTeX morph as a {@link Command}: every ordinary
136
- * `ShapeProps` field (via the inherited `_prepareStep`), plus the
137
- * intrinsic size, shared center frame and per-glyph token list — state a
138
- * plain `set()` can't reach — driven together by one eased `t`, matching
139
- * the concurrent `parallel` the generator version ran.
140
- *
141
- * The "from" snapshot (`fromTokens`, `fromLatex`, …) is captured
142
- * **lazily, on the command's first evaluation**, not when this is called.
143
- * That is what lets two morphs be sequenced: `commandSequence` settles each
144
- * prior step before evaluating the next, so a second morph's "from" reads
145
- * the first one's end state rather than whatever the node held before either
146
- * of them ran.
147
- *
148
- * `_animating` suppresses {@link _ensureTokens} for the open interval, and
149
- * both ends commit: `t === 1`
150
- * lands on the target formula, `t === 0` restores the source one — the same
151
- * "membership for the open interval, commit at either end" shape
152
- * `packages/components/code`'s `runTransition` uses, so seeking into either
153
- * side of the morph (not just running it forward) shows the right thing.
154
- *
155
- * `@internal` — the entry point for authors is {@link to}.
156
- */
157
- _buildMorph(to: Partial<LatexProps>, duration: number, easing?: EasingFunction): Command<LatexProps>;
158
- /**
159
- * The shadow op comes **first**, as it does on every other painted node.
160
- *
161
- * The renderer does not draw a shadow when it sees one: `.shadow()` stores
162
- * it pending and the *next* fill or stroke op casts it (`_shadow` →
163
- * `storePendingShadows`, `_fill`/`_stroke` → `takePendingShadows`). Appended
164
- * last, it was stored by every token and then thrown away by the reset at
165
- * the end of the draw — a shadow set on a LaTeX node simply never appeared,
166
- * with no error to say why. Same failure {@link PaintedNode.renderStroke}
167
- * documents for a fill-less stroked shape, and the same one-op fix.
168
- *
169
- * Order also carries the fill-less case for free: an empty fill returns
170
- * before it takes the pending shadow, so the stroke below casts it from the
171
- * glyph outlines instead — which is what `castsShadowFromStroke` arranges on
172
- * a plain shape.
173
- */
174
- protected renderSelf(ctx: RenderContext2D): void;
175
- /** Each token's part fill: by its place in the formula at rest, by both ends' mid-morph. */
176
- private _tokenFills;
177
- /**
178
- * How far each glyph is written at the node's `written`: its outline first,
179
- * then its fill, each glyph starting before the one ahead of it is done.
180
- * `null` once the whole formula is.
181
- */
182
- private _writing;
183
- /**
184
- * The overlay, painted *through* the glyphs.
185
- *
186
- * `ShapeNode`'s inherited overlay pass fills whatever {@link
187
- * ShapeNode.shapeGraphics} describes, and this node describes nothing there:
188
- * a formula has no single fillable silhouette — its silhouette *is* the list
189
- * of token paths, which is why `renderSelf` is overridden rather than a
190
- * `shapeGraphics` supplied. So the generic pass drew nothing and an overlay
191
- * set on a LaTeX node simply never appeared, with no error to say why.
192
- *
193
- * Painted the same way the fill is: one `Graphics2D` per token, all sharing the
194
- * centre frame, each scaled by its token's animated opacity — so a morph
195
- * carries the overlay along with the glyph it is laid over instead of leaving
196
- * a wash hanging over glyphs that have faded out.
197
- *
198
- * The stroke is *not* re-drawn here. `renderSelf` already strokes each token
199
- * (there is no silhouette for the deferred {@link ShapeNode.renderStroke} to
200
- * outline), so it is painted under the overlay rather than over it — the one
201
- * place this node's draw order differs from a plain shape's, and the price of
202
- * a stroke that follows glyphs rather than a box.
203
- */
204
- protected renderOverlay(ctx: RenderContext2D): void;
205
- /**
206
- * Draws every visible token's path once, handing each one to `paint` to have
207
- * its paint ops appended.
208
- *
209
- * A fresh `Graphics2D` per token per pass, because `.fill()`/`.stroke()` push
210
- * onto one op list and return `this` — a silhouette shared between the fill
211
- * pass and the overlay pass would accumulate both.
212
- */
213
- private eachToken;
214
- }
20
+ /** A LaTeX formula drawn as glyph paths, morphing token by token between formulas. */
21
+ export declare const Latex: import("@motionscript/sdk").Component<"latex", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
22
+ /** The formula. Mid-tween it holds both ends, and the glyphs morph from the one into the other. */
23
+ latex: import("@motionscript/sdk").Type<string, Morphing<string>, false>;
24
+ fontSize: number;
25
+ partFills: import("@motionscript/sdk").Type<PartFill[], import("../index.js").PartFillResolved[], false>;
26
+ written: import("@motionscript/sdk").Type<number, number, false>;
27
+ morphProgress: import("@motionscript/sdk").Type<number, number, false>;
28
+ flow: import("@motionscript/sdk").Type<_FlowMode, _FlowResolved, false>;
29
+ gap: import("@motionscript/sdk").Type<_GapSize, _GapSize, false>;
30
+ wrap: boolean;
31
+ crossGap: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
32
+ columns: import("@motionscript/sdk").Type<number, number, false>;
33
+ align: import("@motionscript/sdk").Attribute<_Alignment, _Vector2>;
34
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
35
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
36
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
37
+ overlay: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
38
+ }>, {
39
+ readonly morphTo: readonly ["latex"];
40
+ readonly writeTo: readonly ["written"];
41
+ readonly partFillTo: {
42
+ readonly part: import("@motionscript/sdk").Type<string, string, false>;
43
+ readonly fill: import("@motionscript/sdk").Type<_Fill, _Fill, false>;
44
+ readonly occurrence: import("@motionscript/sdk").Type<number, number, false>;
45
+ };
46
+ readonly overlayTo: readonly ["overlay"];
47
+ readonly fillTo: readonly ["fill"];
48
+ readonly strokeTo: readonly ["stroke"];
49
+ readonly shadowTo: readonly ["shadow"];
50
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
51
+ /** The formula. Mid-tween it holds both ends, and the glyphs morph from the one into the other. */
52
+ latex: import("@motionscript/sdk").Type<string, Morphing<string>, false>;
53
+ fontSize: number;
54
+ partFills: import("@motionscript/sdk").Type<PartFill[], import("../index.js").PartFillResolved[], false>;
55
+ written: import("@motionscript/sdk").Type<number, number, false>;
56
+ morphProgress: import("@motionscript/sdk").Type<number, number, false>;
57
+ flow: import("@motionscript/sdk").Type<_FlowMode, _FlowResolved, false>;
58
+ gap: import("@motionscript/sdk").Type<_GapSize, _GapSize, false>;
59
+ wrap: boolean;
60
+ crossGap: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
61
+ columns: import("@motionscript/sdk").Type<number, number, false>;
62
+ align: import("@motionscript/sdk").Attribute<_Alignment, _Vector2>;
63
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
64
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
65
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
66
+ overlay: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
67
+ }>, null>>;
68
+ export type Latex = NodeOf<typeof Latex>;
215
69
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/tex/node.ts"],"names":[],"m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