@motionscript/math 0.1.0-alpha.4 → 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 +132 -92
  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
package/CHANGELOG.md CHANGED
@@ -1,92 +1,132 @@
1
- # @motionscript/math
2
-
3
- ## 0.1.0-alpha.4
4
-
5
- ### Minor Changes
6
-
7
- - 7f8b4d0: `@motionscript/math` is a new kit, and the `Latex` node now lives in it. Import it from there:
8
-
9
- ```diff
10
- - import { Latex, NODES } from "@motionscript/latex";
11
- + import { Latex, NODES } from "@motionscript/math";
12
- ```
13
-
14
- - The node, its `latex` key, its props, `morphTo` and the helpers (`buildLatexPath`, `LatexError`, `defaultLatexMorph`) are unchanged, so a document that names `latex` needs no edit. `ms add latex` now copies a node that imports `@motionscript/math`.
15
- - `@motionscript/math/kit` holds what a copied node imports rather than copies, and `@motionscript/math/tex` the typeset-math half alone.
16
- - `@motionscript/latex` and `@motionscript/plot` are no longer released. Their published versions stay on npm as they are.
17
-
18
- - 7f8b4d0: 3D graphs, and named commands for 3D scenes.
19
-
20
- - `@motionscript/math` gains `axes3d` (a 3D graph that is its own viewport, a `canvas3d` with its camera, lights and `orbitTo`, so it goes straight on a 2D stage: three axes through a box of graph coordinates, z up, with ticks, tips, numbers and titles), `surfacePlot3d` (a height over x and y, or three parts in u and v; coloured by height with `colorScale`, ruled with `meshLines`), `curvePlot3d` (a space curve, drawn on with `progressTo`), `plotPoint3d` (rides a surface it is put inside) and `vectorArrow3d`. Anything inside the axes sits at graph coordinates and keeps its own size.
21
- - Every 3D node has `moveTo`, `rotateTo` and `scaleTo`. A `canvas3d` has `orbitTo` for its default camera, and a `camera3d` has `orbitTo` and `lookTo`.
22
- - A 3D parent can place its children in coordinates of its own (`Node3D._spaceOf`, `ChildSpace3D`), as a 2D one already could, and so can a `canvas3d` for the 3D nodes directly inside it (`Canvas3D._spaceOf`).
23
- - The SDK exports `MaterialShorthand3D`, what a mesh node of your own returns from `materialShorthand()`.
24
-
25
- - 7f8b4d0: `@motionscript/math` gains coordinate systems, plots and the marks that go on a graph.
26
-
27
- - `numberLine`, `axes2d` and `numberPlane` are coordinate systems: a child's `x`/`y` are graph units whatever the child is, so a text or an image sits on a graph at its own size, `moveTo` moves it in graph units, and `rangeTo` pans and zooms everything inside.
28
- - `functionPlot` draws an equation and reads its kind from how it is written: `sin(x)`, `x = y^2`, `r = 1 + cos(theta)`, `(cos(t), sin(t))`. `morphTo` bends one curve into another, and curves break at asymptotes and domain edges. A name the equation does not know is a named value: 1 until `params` gives it one, bindable to a variable by a formula, listed by `equationParams`.
29
- - `pointsPlot`, `plotPoint`, `vectorArrow`, `curveArea`, `riemannSum`, `tangentLine` and `dropLines` are drawn in graph coordinates. The ones that ride a plot name it by id in `on`.
30
- - `@motionscript/math/kit` exports `CoordinateSystem`, `Mark`, the coordinate map, the equation language and the sampler for a custom system or mark.
31
- - The SDK exports the `Extents` type that `pathOps.bounds` already returned.
32
-
33
- - 7f8b4d0: A formula's parts can be named, and marks can be drawn on them.
34
-
35
- - Every piece of a `latex` formula's source is a part: `partColors` colours one by its source (`{ part: 'x^2', color: '#facc15' }`), `colorTo` animates that, and `partBounds(part)` says where it is. A morph now carries a term both formulas write as one, with its colour.
36
- - `written` writes a formula on glyph by glyph, each outlined and then filled; `writeTo` animates it.
37
- - `latexMatrix` typesets a matrix from its `entries` in the `brackets` it is given; each entry is a part, and `entriesTo` morphs to new ones.
38
- - `curlyBrace`, `emphasisMark` (box, circle, underline, cross) and `angleMark` annotate. The first two follow a node, or one part of a formula, by id and slide to another with `retargetTo`; a brace with no target spans two points.
39
- - A label written between dollar signs is typeset: on a brace, an angle, a plot point, and an axis.
40
- - `@motionscript/math/kit` exports `FollowMark`, `quadOf` and `findLatexParts` for a custom mark.
41
-
42
- - 7f8b4d0: MathJax loads only when a scene typesets a formula.
43
-
44
- - MathJax and its font are a module of their own, imported once by `loadMathJax()`. A formula node, and a graph, point, brace or angle whose label is written between dollar signs, declares the `math:mathjax` loader (`MATHJAX_LOADER`), which a host waits for before layout; a scene without one never downloads or parses MathJax.
45
- - Code that typesets outside a scene awaits `loadMathJax()` first. Before then `buildLatexPath` throws `LatexNotLoaded`, `latexPartNames` returns nothing, and `mathJaxLoaded()` says whether it has arrived.
46
-
47
- - 7f8b4d0: Network graphs and sample spaces.
48
-
49
- - `networkGraph`: vertices and edges arranged in a circle, by springs, as a tree or in a grid, directed or not. `arrangeTo` moves every vertex to where another arrangement puts it, and `colorTo` colours a vertex or an edge (`a-b`).
50
- - `sampleSpace`: a probability's whole cut into parts whose areas are their probabilities, named by braces, with `divideTo` to move the cuts.
51
-
52
- - 217ae88: A node type can withdraw what it inherits, and the math nodes take only the paints they draw.
53
-
54
- - `@withdraw(...keys)` drops inherited properties and commands from a node class. A withdrawn property is left out of `describe()` and holds its default whatever is written to it; a withdrawn command is left out of `commandKeys()` but still runs for a stored document, changing nothing. A subclass that declares the key again takes it back.
55
- - `Registry.takesCommand(type, key)` says whether a node type takes a command: its own, or a node-less one unless that runs a method the type lacks or withdrew. `addCommand` takes a `method` for that; the paint commands name theirs.
56
- - Math: a plot, a tangent, drop lines, an arrow, a brace, an emphasis mark and an angle mark have no `fill`; a curve area has no `stroke`; a formula, a traced path, a field, a curve area, a Riemann sum, a plot point and a sample space have no outline trim (`start`, `end`, `progressTo`, `flash`). An open `pointsPlot` draws no fill.
57
- - Math: `partColors` and `colorTo` on `latex`, `latexMatrix` and `networkGraph` are now `partFills` and `partFillTo`, each part taking any paint (`{ part, fill }`). A vector field's and stream lines' `colorScale` is now `strengthFills`, and a sample space's `colors` is now `columnFills`, both lists of paints.
58
- - Math: a vector field's and stream lines' shadow is cast when they are painted by strength too, not only in one paint.
59
-
60
- - 7f8b4d0: Planes that transform, fields, polar planes, implicit curves and trails.
61
-
62
- - `numberPlane` gains `matrix` and `transformTo` (a linear map of the whole plane), `warp` and `warpTo` (a bend by a function of its points), and a faint `ghost` of itself while it is transformed. The grid, the axes and everything on the plane go with it.
63
- - New nodes: `polarPlane` (rings and spokes; plots and marks go on it as on axes), `vectorField` (arrows of a field `(P, Q)`, coloured by strength with `colorScale`), `streamLines` (the lines the field carries a point along, sent flowing with `flowTo`) and `tracedPath` (the trail a point leaves as a value changes).
64
- - A `functionPlot` draws an implicit equation, such as `x^2 + y^2 = 4`, where it holds.
65
- - A `Camera` can `follow` a node of its world by id, with `lookAt` as an offset from it.
66
-
67
- - 7f8b4d0: A node can name points an editor may drag to set its `Vector2` props. It answers `_handles()` with each prop and where it sits in its own frame, and `_handleValue(prop, at)` with the value that puts it somewhere else. `nodeHandlesAt` and `handleValueAt` (exported from the SDK), and `nodeHandles`/`handleValue` on the player, answer in viewport space. A math `vectorArrow` offers its two ends in graph units, and a `curlyBrace` that spans two points offers those.
68
- - 7f8b4d0: A node type can say where it goes, so a host can offer it only where it works.
69
-
70
- - `@node({ within, beside, closed })`: `within` names the types a node goes inside (a name covers every type built on it), `beside` the types it needs at least one of as a sibling, and `closed` marks a parent that takes only children that name it. Nothing checks them at build.
71
- - `parentIssue`, `siblingIssue` and `placementIssues` answer them for a host, together with the 2D/3D seam and `acceptsChildren`; `nodeTypeIsA` walks `parentKey`.
72
- - In `@motionscript/math` a `functionPlot` holds the marks that are of it: a `tangentLine`, and a `plotPoint` or `dropLines` put inside it follow its curve with no `on`. `curveArea` and `riemannSum` sit beside the plots they read and name them in `on`. Plots, arrows and marks go inside a coordinate system.
73
-
74
- ### Patch Changes
75
-
76
- - `@motionscript/math/kit` loads when it is the first part of the kit imported. The `Latex` node reached the kit barrel back for its helpers, so a host entering through `./kit` (a browser build loaded by import map, say) ran its decorators before `OUTLINE_TRIM` existed and the import failed with `OUTLINE_TRIM is not iterable`.
77
- - 217ae88: A transformed `numberPlane` rules its grid at most four times as far as its own ranges reach, so a plane squeezed onto a line folds its grid into a narrowing band. Before, as the determinant neared zero, the grid's range grew as one over it, the box filled with lines (a solid wash, and slow frames), and then jumped back to the plain ranges once the plane was flat.
78
- - ad28707: Component kit fixes.
79
-
80
- - Charts: a bar chart maps its columns across the plot panel as laid out (and takes the line chart's top headroom), so a column ends on its marker's grid line. A pie chart's wedges, labels and legend follow `data` and the palette once they are set. A restated value-axis or y/x-axis `range` or `ticks` in `to()` rescales continuously from the axis as drawn, instead of cutting at the midpoint. Without a legend (or without series) the entrance keeps that beat's share, so the call-out and legend land where the slot lays them out. A constant line series gets a scale with width, a `NaN` or infinite cell reads as 0, and tick captions gain decimals when the step is finer than 0.1.
81
- - Code: the compiled highlighter is cached per style object, so two styles sharing a name no longer colour alike. A `CodeRanges` chain serialises as its ranges, so a stored `highlight` target selects what it did before it was saved.
82
- - LaTeX: seeking from inside a morph to a time before it restores the source formula instead of leaving the last morph frame.
83
- - Geo: custom border rings are wound for d3, so a GeoJSON counter-clockwise ring draws as the small region it encloses; a great-circle path between antipodal points runs over the north pole instead of wherever rounding lands.
84
- - Audio: bottom-aligned waveform bars stand on the floor of the box instead of hanging from the top.
85
- - `Code` and `Latex` take an optional props bag, so `new Registry({ nodes: NODES })` and `createBrowserEngine({ nodes: NODES })` type-check without a cast.
86
-
87
- - 1be0249: A formula MathJax cannot typeset now throws a `LatexError`, the same in a browser and in Node.
88
-
89
- MathJax does not throw on malformed TeX; it typesets an error box. In a browser `buildLatexPath` then returned no tokens for `\fra`, `\frac{a`, `{` or `\badcommand{x}`, so nothing was drawn and nothing was reported, while the DOM-free adaptor returned one wide token that drew as a filled bar. Both now detect MathJax's error node and throw `LatexError`, which carries the `latex` source and MathJax's `reason`. `\require` is an error too, since only the listed TeX packages are loaded. A `Latex` node whose formula cannot be typeset keeps throwing on every read instead of reading as blank after the first.
90
-
91
- - 55a1ed3: `to` and `morphTo` on a `Latex` node that is not in a tree run their duration and write nothing, as every other command does. They used to write `latex` on the loose node when driven directly; a document could not reach this, since the validator rejects a command that runs before its target is present.
92
- - 217ae88: A point, tangent or guide inside a `functionPlot` is drawn over the curve. A mark's stroke is its ink, so it is now painted before the mark's children; before, it was painted last, as a shape's outline is, and the curve ran across every dot and line riding it. A `Mark` subclass that strokes its ink its own way overrides the new `renderInk` hook rather than `renderStroke`, and one that paints no fill until its ink has an inside answers `paintsFill`.
1
+ # @motionscript/math
2
+
3
+ ## 0.1.0-alpha.6
4
+
5
+ ### Minor Changes
6
+
7
+ - 163b708: Node types are components: one spec object handed to `component2d`, `component3d` or `componentAudio`, with no classes, decorators or JSX.
8
+
9
+ - **Writing a node type.** A component is one object literal: `key`, `state` (literals and `Types`), `defaults`, `commands`, `children`, `allowedChildren`/`allowedParents`, `provide`, `load`, and its tree's own fields (`measure`, `layout`, `render` for 2D). Behaviour comes from modules you spread in and call: `Paint`, `Flow`, `Shapes`, `Typeface`, `TextLayout`, `Aim`, `Material`, `View3D`. ADR 0007 and the custom-node docs cover it.
10
+ - **Building nodes in code** uses calls: `Rect({ fill: 'tomato', children: [Text({ text: 'Hi' })] })`, or `new Rect({...})` for the node itself.
11
+ - **Every built-in and every kit node is a component**, under the same document key. Code that tested `instanceof` a class now uses the component's `.is`, or `instanceof X.node`. Changed members:
12
+ - `SurfacePlot3d.valueAt` and `FunctionPlot.valueAt` are now the functions `surfaceValueAt` and `curveValue`.
13
+ - A system's `coordinates` is replaced by `planeMap`/`axesMap`/`systemMap`.
14
+ - `PieChart.isSelected` is replaced by `isSliceSelected`.
15
+ - `ItemGrid` is a kit module (`ItemGrid.isGrid`, `ItemGrid.define`), not a base class.
16
+ - **The sdk no longer exports the class surface:**
17
+ - the decorators: `node`, `property` and every `*Property`, `command`, `withdraw`, `driveCommand`;
18
+ - the authoring bases: `PaintNode`, `ShapeNode`, `TextBase`, `Mesh3DBase`, `Canvas3DBase` and the `*Base` geometry classes;
19
+ - `asCommand`, `compose`, `drive` and `declarePaints` from `@motionscript/sdk/component`;
20
+ - the `jsx-runtime` and `jsx-dev-runtime` subpaths.
21
+ - `Node`, `Node2D`, `Node3D` and `NodeAudio` remain as types.
22
+ - **Editor metadata leaves the engine.** The kits no longer declare `parentKey`, `forkable`, `layout`, `seed`, `within`, `beside` or `closed`; a host keeps those in its own configs. `describe()` now reports `holds`, the trees a type takes children from, and the placement checks use it, so a 2D viewport of your own that takes 3D children places them.
23
+ - A command called from code with no argument runs, and a refused child is told what its parent takes (`allowedChildren`) or where it goes (`allowedParents`).
24
+
25
+ ## 0.1.0-alpha.5
26
+
27
+ ### Patch Changes
28
+
29
+ - da6f97a: Every package ships a `NOTICE`, and a browser build lists what it bundles.
30
+
31
+ - Each tarball carries the repository `NOTICE`: the copyright line and the MIT attributions for the noise functions in `skia-render`'s fractal-noise fill (David Hoskins' "Hash without Sine", Inigo Quilez's 2D simplex noise).
32
+ - `@motionscript/canvaskit` ships `THIRD_PARTY_NOTICES.txt` with the licences of the libraries compiled into the binary: FreeType, HarfBuzz, ICU 74, zlib, libpng, Brotli, WOFF2, Emscripten and musl.
33
+ - `dist/browser/manifest.json` gains `thirdParty`, the packages the browser build bundled (`name`, `version`, `license`), and their licence and NOTICE files are written to `dist/browser/THIRD_PARTY_LICENSES.txt`. `@motionscript/browser` bundles mediabunny (MPL-2.0, unmodified; source at https://github.com/Vanilagy/mediabunny), esbuild-wasm and three; `@motionscript/math` bundles MathJax.
34
+
35
+ - 1778355: The published packages carry what a user needs and say what they are.
36
+
37
+ - `@motionscript/code` no longer ships `dist/tests/diff.bench.*`, and `@motionscript/math` no longer ships `dist/tests/harness.*` or `mathjax.setup.*`: test helpers under a `tests` folder are left out of every package's build.
38
+ - `@motionscript/sdk`'s description no longer repeats core's, and `@motionscript/math`'s names the coordinate systems, plots, 3D graphs and network graphs it has as well as formulas.
39
+ - The READMEs of `@motionscript/canvaskit`, `@motionscript/charts`, `@motionscript/geo`, `@motionscript/grids`, `@motionscript/skia-render` and `@motionscript/geography` say what to install, and `@motionscript/sdk`'s example now opens the document in an engine and plays it. Links between packages point at the repository, so they work on npm.
40
+
41
+ - 62eb615: `surfacePlot3d` takes `floorShadow`: the opacity, 0 to 1, of a flat copy of the surface laid on the floor of its axes, coloured by the height above it. Zero, the default, draws none.
42
+
43
+ ## 0.1.0-alpha.4
44
+
45
+ ### Minor Changes
46
+
47
+ - 7f8b4d0: `@motionscript/math` is a new kit, and the `Latex` node now lives in it. Import it from there:
48
+
49
+ ```diff
50
+ - import { Latex, NODES } from "@motionscript/latex";
51
+ + import { Latex, NODES } from "@motionscript/math";
52
+ ```
53
+
54
+ - The node, its `latex` key, its props, `morphTo` and the helpers (`buildLatexPath`, `LatexError`, `defaultLatexMorph`) are unchanged, so a document that names `latex` needs no edit. `ms add latex` now copies a node that imports `@motionscript/math`.
55
+ - `@motionscript/math/kit` holds what a copied node imports rather than copies, and `@motionscript/math/tex` the typeset-math half alone.
56
+ - `@motionscript/latex` and `@motionscript/plot` are no longer released. Their published versions stay on npm as they are.
57
+
58
+ - 7f8b4d0: 3D graphs, and named commands for 3D scenes.
59
+
60
+ - `@motionscript/math` gains `axes3d` (a 3D graph that is its own viewport, a `canvas3d` with its camera, lights and `orbitTo`, so it goes straight on a 2D stage: three axes through a box of graph coordinates, z up, with ticks, tips, numbers and titles), `surfacePlot3d` (a height over x and y, or three parts in u and v; coloured by height with `colorScale`, ruled with `meshLines`), `curvePlot3d` (a space curve, drawn on with `progressTo`), `plotPoint3d` (rides a surface it is put inside) and `vectorArrow3d`. Anything inside the axes sits at graph coordinates and keeps its own size.
61
+ - Every 3D node has `moveTo`, `rotateTo` and `scaleTo`. A `canvas3d` has `orbitTo` for its default camera, and a `camera3d` has `orbitTo` and `lookTo`.
62
+ - A 3D parent can place its children in coordinates of its own (`Node3D._spaceOf`, `ChildSpace3D`), as a 2D one already could, and so can a `canvas3d` for the 3D nodes directly inside it (`Canvas3D._spaceOf`).
63
+ - The SDK exports `MaterialShorthand3D`, what a mesh node of your own returns from `materialShorthand()`.
64
+
65
+ - 7f8b4d0: `@motionscript/math` gains coordinate systems, plots and the marks that go on a graph.
66
+
67
+ - `numberLine`, `axes2d` and `numberPlane` are coordinate systems: a child's `x`/`y` are graph units whatever the child is, so a text or an image sits on a graph at its own size, `moveTo` moves it in graph units, and `rangeTo` pans and zooms everything inside.
68
+ - `functionPlot` draws an equation and reads its kind from how it is written: `sin(x)`, `x = y^2`, `r = 1 + cos(theta)`, `(cos(t), sin(t))`. `morphTo` bends one curve into another, and curves break at asymptotes and domain edges. A name the equation does not know is a named value: 1 until `params` gives it one, bindable to a variable by a formula, listed by `equationParams`.
69
+ - `pointsPlot`, `plotPoint`, `vectorArrow`, `curveArea`, `riemannSum`, `tangentLine` and `dropLines` are drawn in graph coordinates. The ones that ride a plot name it by id in `on`.
70
+ - `@motionscript/math/kit` exports `CoordinateSystem`, `Mark`, the coordinate map, the equation language and the sampler for a custom system or mark.
71
+ - The SDK exports the `Extents` type that `pathOps.bounds` already returned.
72
+
73
+ - 7f8b4d0: A formula's parts can be named, and marks can be drawn on them.
74
+
75
+ - Every piece of a `latex` formula's source is a part: `partColors` colours one by its source (`{ part: 'x^2', color: '#facc15' }`), `colorTo` animates that, and `partBounds(part)` says where it is. A morph now carries a term both formulas write as one, with its colour.
76
+ - `written` writes a formula on glyph by glyph, each outlined and then filled; `writeTo` animates it.
77
+ - `latexMatrix` typesets a matrix from its `entries` in the `brackets` it is given; each entry is a part, and `entriesTo` morphs to new ones.
78
+ - `curlyBrace`, `emphasisMark` (box, circle, underline, cross) and `angleMark` annotate. The first two follow a node, or one part of a formula, by id and slide to another with `retargetTo`; a brace with no target spans two points.
79
+ - A label written between dollar signs is typeset: on a brace, an angle, a plot point, and an axis.
80
+ - `@motionscript/math/kit` exports `FollowMark`, `quadOf` and `findLatexParts` for a custom mark.
81
+
82
+ - 7f8b4d0: MathJax loads only when a scene typesets a formula.
83
+
84
+ - MathJax and its font are a module of their own, imported once by `loadMathJax()`. A formula node, and a graph, point, brace or angle whose label is written between dollar signs, declares the `math:mathjax` loader (`MATHJAX_LOADER`), which a host waits for before layout; a scene without one never downloads or parses MathJax.
85
+ - Code that typesets outside a scene awaits `loadMathJax()` first. Before then `buildLatexPath` throws `LatexNotLoaded`, `latexPartNames` returns nothing, and `mathJaxLoaded()` says whether it has arrived.
86
+
87
+ - 7f8b4d0: Network graphs and sample spaces.
88
+
89
+ - `networkGraph`: vertices and edges arranged in a circle, by springs, as a tree or in a grid, directed or not. `arrangeTo` moves every vertex to where another arrangement puts it, and `colorTo` colours a vertex or an edge (`a-b`).
90
+ - `sampleSpace`: a probability's whole cut into parts whose areas are their probabilities, named by braces, with `divideTo` to move the cuts.
91
+
92
+ - 217ae88: A node type can withdraw what it inherits, and the math nodes take only the paints they draw.
93
+
94
+ - `@withdraw(...keys)` drops inherited properties and commands from a node class. A withdrawn property is left out of `describe()` and holds its default whatever is written to it; a withdrawn command is left out of `commandKeys()` but still runs for a stored document, changing nothing. A subclass that declares the key again takes it back.
95
+ - `Registry.takesCommand(type, key)` says whether a node type takes a command: its own, or a node-less one unless that runs a method the type lacks or withdrew. `addCommand` takes a `method` for that; the paint commands name theirs.
96
+ - Math: a plot, a tangent, drop lines, an arrow, a brace, an emphasis mark and an angle mark have no `fill`; a curve area has no `stroke`; a formula, a traced path, a field, a curve area, a Riemann sum, a plot point and a sample space have no outline trim (`start`, `end`, `progressTo`, `flash`). An open `pointsPlot` draws no fill.
97
+ - Math: `partColors` and `colorTo` on `latex`, `latexMatrix` and `networkGraph` are now `partFills` and `partFillTo`, each part taking any paint (`{ part, fill }`). A vector field's and stream lines' `colorScale` is now `strengthFills`, and a sample space's `colors` is now `columnFills`, both lists of paints.
98
+ - Math: a vector field's and stream lines' shadow is cast when they are painted by strength too, not only in one paint.
99
+
100
+ - 7f8b4d0: Planes that transform, fields, polar planes, implicit curves and trails.
101
+
102
+ - `numberPlane` gains `matrix` and `transformTo` (a linear map of the whole plane), `warp` and `warpTo` (a bend by a function of its points), and a faint `ghost` of itself while it is transformed. The grid, the axes and everything on the plane go with it.
103
+ - New nodes: `polarPlane` (rings and spokes; plots and marks go on it as on axes), `vectorField` (arrows of a field `(P, Q)`, coloured by strength with `colorScale`), `streamLines` (the lines the field carries a point along, sent flowing with `flowTo`) and `tracedPath` (the trail a point leaves as a value changes).
104
+ - A `functionPlot` draws an implicit equation, such as `x^2 + y^2 = 4`, where it holds.
105
+ - A `Camera` can `follow` a node of its world by id, with `lookAt` as an offset from it.
106
+
107
+ - 7f8b4d0: A node can name points an editor may drag to set its `Vector2` props. It answers `_handles()` with each prop and where it sits in its own frame, and `_handleValue(prop, at)` with the value that puts it somewhere else. `nodeHandlesAt` and `handleValueAt` (exported from the SDK), and `nodeHandles`/`handleValue` on the player, answer in viewport space. A math `vectorArrow` offers its two ends in graph units, and a `curlyBrace` that spans two points offers those.
108
+ - 7f8b4d0: A node type can say where it goes, so a host can offer it only where it works.
109
+
110
+ - `@node({ within, beside, closed })`: `within` names the types a node goes inside (a name covers every type built on it), `beside` the types it needs at least one of as a sibling, and `closed` marks a parent that takes only children that name it. Nothing checks them at build.
111
+ - `parentIssue`, `siblingIssue` and `placementIssues` answer them for a host, together with the 2D/3D seam and `acceptsChildren`; `nodeTypeIsA` walks `parentKey`.
112
+ - In `@motionscript/math` a `functionPlot` holds the marks that are of it: a `tangentLine`, and a `plotPoint` or `dropLines` put inside it follow its curve with no `on`. `curveArea` and `riemannSum` sit beside the plots they read and name them in `on`. Plots, arrows and marks go inside a coordinate system.
113
+
114
+ ### Patch Changes
115
+
116
+ - `@motionscript/math/kit` loads when it is the first part of the kit imported. The `Latex` node reached the kit barrel back for its helpers, so a host entering through `./kit` (a browser build loaded by import map, say) ran its decorators before `OUTLINE_TRIM` existed and the import failed with `OUTLINE_TRIM is not iterable`.
117
+ - 217ae88: A transformed `numberPlane` rules its grid at most four times as far as its own ranges reach, so a plane squeezed onto a line folds its grid into a narrowing band. Before, as the determinant neared zero, the grid's range grew as one over it, the box filled with lines (a solid wash, and slow frames), and then jumped back to the plain ranges once the plane was flat.
118
+ - ad28707: Component kit fixes.
119
+
120
+ - Charts: a bar chart maps its columns across the plot panel as laid out (and takes the line chart's top headroom), so a column ends on its marker's grid line. A pie chart's wedges, labels and legend follow `data` and the palette once they are set. A restated value-axis or y/x-axis `range` or `ticks` in `to()` rescales continuously from the axis as drawn, instead of cutting at the midpoint. Without a legend (or without series) the entrance keeps that beat's share, so the call-out and legend land where the slot lays them out. A constant line series gets a scale with width, a `NaN` or infinite cell reads as 0, and tick captions gain decimals when the step is finer than 0.1.
121
+ - Code: the compiled highlighter is cached per style object, so two styles sharing a name no longer colour alike. A `CodeRanges` chain serialises as its ranges, so a stored `highlight` target selects what it did before it was saved.
122
+ - LaTeX: seeking from inside a morph to a time before it restores the source formula instead of leaving the last morph frame.
123
+ - Geo: custom border rings are wound for d3, so a GeoJSON counter-clockwise ring draws as the small region it encloses; a great-circle path between antipodal points runs over the north pole instead of wherever rounding lands.
124
+ - Audio: bottom-aligned waveform bars stand on the floor of the box instead of hanging from the top.
125
+ - `Code` and `Latex` take an optional props bag, so `new Registry({ nodes: NODES })` and `createBrowserEngine({ nodes: NODES })` type-check without a cast.
126
+
127
+ - 1be0249: A formula MathJax cannot typeset now throws a `LatexError`, the same in a browser and in Node.
128
+
129
+ MathJax does not throw on malformed TeX; it typesets an error box. In a browser `buildLatexPath` then returned no tokens for `\fra`, `\frac{a`, `{` or `\badcommand{x}`, so nothing was drawn and nothing was reported, while the DOM-free adaptor returned one wide token that drew as a filled bar. Both now detect MathJax's error node and throw `LatexError`, which carries the `latex` source and MathJax's `reason`. `\require` is an error too, since only the listed TeX packages are loaded. A `Latex` node whose formula cannot be typeset keeps throwing on every read instead of reading as blank after the first.
130
+
131
+ - 55a1ed3: `to` and `morphTo` on a `Latex` node that is not in a tree run their duration and write nothing, as every other command does. They used to write `latex` on the loose node when driven directly; a document could not reach this, since the validator rejects a command that runs before its target is present.
132
+ - 217ae88: A point, tangent or guide inside a `functionPlot` is drawn over the curve. A mark's stroke is its ink, so it is now painted before the mark's children; before, it was painted last, as a shape's outline is, and the curve ran across every dot and line riding it. A `Mark` subclass that strokes its ink its own way overrides the new `renderInk` hook rather than `renderStroke`, and one that paints no fill until its ink has an inside answers `paintsFill`.
package/README.md CHANGED
@@ -18,8 +18,8 @@ export const nodes = NODES;
18
18
 
19
19
  | Entry | Holds |
20
20
  | --- | --- |
21
- | `@motionscript/math` | Every node class, `NODES`, and the kit below |
22
- | `@motionscript/math/kit` | What the nodes share and a copied node imports rather than copies: `CoordinateSystem`, `Mark`, the coordinate map, the equation language, the sampler, and the LaTeX helpers |
21
+ | `@motionscript/math` | Every component, `NODES`, and the kit below |
22
+ | `@motionscript/math/kit` | What the nodes share and a copied node imports rather than copies: the systems' and marks' helpers (`systemLayout`, `traced`, `drawMark`, the plane a system hands its marks), the coordinate map, the equation language, the sampler, and the LaTeX helpers |
23
23
  | `@motionscript/math/tex` | The typeset-math half alone: `Latex`, `TEX_NODES` and its helpers |
24
24
 
25
25
  ## Nodes
@@ -57,16 +57,15 @@ Every node also has the shape commands (`moveTo`, `fadeTo`, `fillTo`,
57
57
  | `networkGraph` | Vertices and edges, arranged in a circle, by springs, as a tree or in a grid | anywhere | `arrangeTo({ arrangement })`, `partFillTo({ part, fill })` |
58
58
  | `sampleSpace` | A probability's whole cut into parts whose areas are their probabilities | anywhere | `divideTo({ columnShares, rowShares })` |
59
59
 
60
- A system is a `numberLine`, an `axes2d`, a `numberPlane` or a `polarPlane`. Where a node goes is
61
- written on its class (`@node({ within, beside, closed })`), so a host can offer
62
- it only there; a `functionPlot` takes only the marks made for it. Nothing
63
- checks it when a document builds: a plot outside a system builds and draws
64
- nothing.
60
+ A system is a `numberLine`, an `axes2d`, a `numberPlane` or a `polarPlane`. The
61
+ Goes in column is where each node is made to go; offering it only there is the
62
+ host's to do, since the engine is told only a node's key, entries and commands.
63
+ Nothing checks it when a document builds: a plot outside a system builds and
64
+ draws nothing.
65
65
 
66
- Each node takes only the paints it draws. A shape's `fill`, `stroke` and outline
67
- trim (`start`, `end`, `progressTo`, `flash`) are inherited, and a node that has no
68
- use for one withdraws it (`withdraw` from the SDK), so it is not offered and
69
- writing it changes nothing: a plot, a tangent, an arrow or a brace is a line with
66
+ Each node takes only the paints it draws. A node spreads the shape paints
67
+ (`fill`, `stroke` and the outline trim `start`, `end`, `progressTo`, `flash`) it
68
+ has a use for and leaves the rest out, so they are not offered: a plot, a tangent, an arrow or a brace is a line with
70
69
  no fill; an area is a fill with no outline; a field is one stroke for every arrow
71
70
  or line; a formula and a traced path reveal themselves (`writeTo`, `traceTo`)
72
71
  rather than by trimming; a dot, a sample space and a Riemann sum have nothing a
@@ -99,16 +98,16 @@ const document = {
99
98
  size; `moveTo` moves it in graph units; a range tween carries it. On a
100
99
  `numberLine`, `x` is a value on the line and `y` is pixels above it.
101
100
  - **A mark is drawn through the system's map.** `functionPlot`, `pointsPlot`,
102
- `vectorArrow`, `curveArea`, `riemannSum`, `tangentLine` and `dropLines` extend
103
- `Mark`: their geometry is in graph coordinates and their box is the tight box of
101
+ `vectorArrow`, `curveArea`, `riemannSum`, `tangentLine` and `dropLines` are
102
+ marks (`traced`): their geometry is in graph coordinates and their box is the tight box of
104
103
  their ink. A plot's or an arrow's own `x`/`y` shift it in graph units; a
105
104
  `tangentLine`'s and a `dropLines`'s `x` is where along the graph they are.
106
105
  Outside a system a graph unit is a pixel and a plot draws nothing.
107
106
  - **Riding a plot.** A `plotPoint`, `tangentLine` or `dropLines` inside a
108
107
  `functionPlot` follows that plot, appears, moves and leaves with it, and is
109
108
  drawn over the curve: a mark's stroke is its ink, painted before its children
110
- rather than last as a shape's outline is (a `Mark` that strokes its ink its
111
- own way overrides `renderInk`, not `renderStroke`). In the system instead, a
109
+ rather than last as a shape's outline is (a mark drawn with `drawMark` that
110
+ strokes its ink its own way passes its own `ink`). In the system instead, a
112
111
  point or guide names a plot by id in `on`, or none and is free. `curveArea`
113
112
  and `riemannSum` sit in the system beside the plots they read and name one in
114
113
  `on` (an area a second in `under`). A point that rides a plot
@@ -160,8 +159,11 @@ commands: [
160
159
  drawn at its edge, and one with no value is drawn flat, so a pole does not tear
161
160
  the mesh. Left out, `uDomain` and `vDomain` are the axes' x and y ranges for a
162
161
  height and 0 to 1 for a parametric surface.
162
+ - **A point put inside a surface rides it**: its `x` and `y` say where, and its
163
+ height is the surface's, which `surfaceValueAt(surface, x, y)` reads.
163
164
  - **`colorScale` colours a surface by height** over the axes' z range, lowest
164
- first; without one it is painted in its `fill`. `meshLines` rules it each way.
165
+ first; without one it is painted in its `fill`, the plot blue unless given one
166
+ (a `curvePlot3d` too). `meshLines` rules it each way.
165
167
  - **A surface takes the mesh material props** (`opacity`, `roughness`, `wireframe`,
166
168
  …) and is lit by the axes' lights; it is drawn from both sides.
167
169
  - **Lines are tubes and labels are cards.** A `curvePlot3d`'s and an axis's
@@ -251,7 +253,7 @@ A `functionPlot`'s `expression` is read the way it is written:
251
253
  `tree` (levels down from `root`, a parent over its children), `grid`. A vertex
252
254
  in `positions` is placed by hand, from -1 to 1 each way. `arrangeTo` moves every
253
255
  vertex to where another arrangement puts it. (`layout` is every node's own box,
254
- hence the other word.)
256
+ hence the other word.) `vertexPoints(graph, size)` says where each vertex is drawn.
255
257
  - **`partFillTo({ part, fill })` paints a vertex by its name, or an edge written
256
258
  `a-b`**, arriving over the graph's own paint, as a formula's parts are painted;
257
259
  `partFills` holds them.
@@ -260,6 +262,7 @@ A `functionPlot`'s `expression` is read the way it is written:
260
262
  (its upper share, 0 to 1), so each part's area is its probability. Braces name
261
263
  the columns below (`columnLabels`) and the rows on the left (`rowLabels`);
262
264
  `values` writes each part's probability in it; `divideTo` moves the cuts.
265
+ `sampleParts(space, size)` gives each part's box and probability.
263
266
 
264
267
  ## Annotations
265
268
 
@@ -270,8 +273,8 @@ the two are in the tree; `retargetTo` slides it to another. A brace with no
270
273
  `on` spans `tail` to `head`. An angle mark sits at its own position and sweeps
271
274
  `fromAngle` to `toAngle` in degrees, so binding one to a variable opens it.
272
275
  A label written between dollar signs is typeset, on these and on a plot point
273
- or an axis. `FollowMark` and `quadOf` in `@motionscript/math/kit` are what a
274
- custom mark of this kind is built on.
276
+ or an axis. `FOLLOW_STATE`, `FOLLOW_COMMANDS` and `followedQuad` in
277
+ `@motionscript/math/kit` are what a custom mark of this kind is built on.
275
278
 
276
279
  ## Latex
277
280
 
@@ -295,10 +298,10 @@ export default {
295
298
  } satisfies CompositionDocument;
296
299
  ```
297
300
 
298
- - **`Latex`** node, a `ShapeNode` that draws a formula as fillable, strokable
301
+ - **`Latex`** node, a component that draws a formula as fillable, strokable
299
302
  glyph paths. Set `latex` to the TeX source and `fontSize` to scale it; `fill`,
300
303
  `stroke`, `shadow`, and `padding` work like any other shape.
301
- - **Formula morphing**: `morphTo` (or a `to` on `latex` or `fontSize`) interpolates each
304
+ - **Formula morphing**: `morphTo` (or any `to` that names `latex`) interpolates each
302
305
  glyph between the current and target formula, matching tokens that persist,
303
306
  fading out tokens that leave, and fading in tokens that arrive. A persisting
304
307
  glyph is carried by its geometry, so one that changes size on the way — the
@@ -307,7 +310,7 @@ export default {
307
310
  resizes smoothly along with it.
308
311
  - **Parts**: every piece of the source is a part, named by that source
309
312
  (`a^2`, `\frac{d}{dx}`, or neighbours that spell it together). `partFills`
310
- and `partFillTo` paint one with any paint, `partBounds(part)` says where it is,
313
+ and `partFillTo` paint one with any paint, `latexPartBounds(node, part)` says where it is,
311
314
  and a morph carries a term both formulas write as one, with its fill.
312
315
  - **`written`** writes the formula on glyph by glyph, each outlined and then
313
316
  filled; `writeTo` animates it. It is how a formula appears, so a formula has
@@ -324,8 +327,8 @@ packages enabled. Rendering is synchronous and browser-only.
324
327
 
325
328
  A formula MathJax cannot typeset (`\frac{a`, `\fra`, a stray `{`, or `\require`,
326
329
  since only the packages above are loaded) throws a `LatexError` from
327
- `buildLatexPath`, from a `Latex` node that holds it and from a `to` that targets
328
- it. The error carries the `latex` source and MathJax's `reason`. It is the same
330
+ `buildLatexPath`, and from a `Latex` node that holds it whenever it is laid out
331
+ (a document holding one fails to build). The error carries the `latex` source and MathJax's `reason`. It is the same
329
332
  in a browser and in Node; nothing is drawn in place of the formula.
330
333
 
331
334
  This package is written against [`@motionscript/sdk`](https://github.com/motionscript-dev/motionscript/tree/main/packages/sdk), which it
@@ -334,17 +337,20 @@ scene, such as [`@motionscript/browser`](https://github.com/motionscript-dev/mot
334
337
 
335
338
  ## Morphing, fills and what the host supplies
336
339
 
337
- - **`morphTo({ latex })` is the document command, and every `to` is a morph.**
338
- `Latex` overrides `to`, so a `to` that names only `fontSize` or `fill` goes
339
- through the same path as one that names `latex`. A morph reads its from-state on
340
- its **first evaluation**, not when the command is built, so two morphs in
341
- sequence start the second from the first's end.
340
+ - **`morphTo({ latex })` is the document command, and every `to` of `latex` is a morph.**
341
+ Mid-tween `latex` (a matrix's `entries` and `brackets`) holds both ends, a
342
+ `Morph`, and the glyphs are drawn that far between them, so a seek to any time
343
+ draws the morph there. A `to` of `fontSize` alone sets the formula again at
344
+ each size. A morph reads its from-state on its **first evaluation**, not when
345
+ the command is built, so two morphs in sequence start the second from the
346
+ first's end.
342
347
  - **Glyphs match by key.** A token's key is the character its MathJax glyph id
343
348
  decodes to (a mathematical italic `𝑥` is not `x`); a rule or fraction bar is
344
349
  `__rect_N` and a bare path `__path_N`, and those never match. `defaultLatexMorph`
345
350
  pairs keys greedily in order, fades deleted tokens over the first half and added
346
- ones over the second. A custom `morph` (`LatexStrategies`, a constructor option,
347
- not a prop, so a document cannot set it) replaces all of it, including paint order.
351
+ ones over the second. A custom `morph` (`LatexStrategies`) replaces it, for a
352
+ node built on the typeset helpers, which take it as an argument
353
+ (`formulaFrame(source, fontSize, partFills, morph)`); a document cannot set it.
348
354
  - **A `latex` row needs a `fill` or a `stroke` to draw anything**; `fill` defaults
349
355
  to none. The formula is typeset in display style, so double each backslash inside
350
356
  a JSON string.
@@ -362,8 +368,8 @@ scene, such as [`@motionscript/browser`](https://github.com/motionscript-dev/mot
362
368
  (typeset geometry by formula, 128 entries; paths by size and formula, 64).
363
369
  Importing the module registers MathJax's HTML handler, with the DOM-free adaptor
364
370
  when there is no `window` or `document`.
365
- - **`ms add latex` copies only `tex/node.ts`** (`registry.json`); typesetting and the
366
- morph stay in this package behind `src/engine.ts`.
371
+ - **`ms add latex` copies only `tex/node.ts`** (`registry.json`); typesetting, the
372
+ morph and the drawing (`tex/typeset.ts`) stay in this package behind `src/engine.ts`.
367
373
 
368
374
  ## Usage
369
375
 
@@ -1,4 +1,4 @@
1
- import { Graphics2D, PaintNode, type AssetScope, type BoxBounds, type Color, type Command, type CommandArgs, type NodeConfig, type PaintProps, type RenderContext2D, type Size2D, type Stroke } from "@motionscript/sdk";
1
+ import { type Color, type NodeOf, type NormalizedColor, type PaintProps, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
2
2
  export interface AngleMarkProps extends PaintProps {
3
3
  fromAngle?: number;
4
4
  toAngle?: number;
@@ -9,38 +9,63 @@ export interface AngleMarkProps extends PaintProps {
9
9
  labelColor?: Color;
10
10
  fontFamily?: string;
11
11
  }
12
+ interface AngleValues {
13
+ readonly fromAngle: number;
14
+ readonly toAngle: number;
15
+ readonly radius: number;
16
+ readonly corner: "arc" | "square" | "auto";
17
+ }
12
18
  /**
13
19
  * The mark of an angle at the node's own position: an arc from one direction
14
20
  * to another, or the small square of a right angle, with an optional label.
15
21
  * Directions are degrees counter-clockwise from the right, so binding one to a
16
22
  * variable opens and closes the angle. A label of `°` shows the angle's size.
17
23
  */
18
- export declare class AngleMark extends PaintNode<AngleMarkProps> {
19
- fromAngle: number;
20
- toAngle: number;
21
- radius: number;
24
+ export declare const AngleMark: import("@motionscript/sdk").Component<"angleMark", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
25
+ fromAngle: import("@motionscript/sdk").Type<number, number, false>;
26
+ toAngle: import("@motionscript/sdk").Type<number, number, false>;
27
+ radius: import("@motionscript/sdk").Type<number, number, false>;
22
28
  /** `auto` draws the square where the angle is a right one. */
23
- corner: "arc" | "square" | "auto";
29
+ corner: import("@motionscript/sdk").Type<"auto" | "square" | "arc", "auto" | "square" | "arc", false>;
24
30
  /** Text, a formula between dollar signs, or `°` for the angle's own size. */
25
- label: string;
26
- labelSize: number;
27
- labelColor: Color;
28
- fontFamily: string;
29
- stroke: Stroke;
30
- constructor(props?: NodeConfig<AngleMark, AngleMarkProps>);
31
- /** Grow or shrink the mark. */
32
- radiusTo(args: CommandArgs<{
33
- radius: number;
34
- }> & {
35
- duration: number;
36
- }): Command<AngleMarkProps>;
37
- /** The angle marked, in degrees: positive counter-clockwise. */
38
- get value(): number;
39
- declareAssets(assets: AssetScope): void;
40
- measure(): Partial<Size2D>;
41
- protected shapeGraphics(): Graphics2D | null;
42
- protected renderSelf(ctx: RenderContext2D): void;
43
- _localBounds(): BoxBounds;
44
- private _outline;
45
- }
31
+ label: import("@motionscript/sdk").Type<string, string, false>;
32
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
33
+ labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
34
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
35
+ /** The angle marked, in degrees: positive counter-clockwise. A formula reads it back as `[key.value]`. */
36
+ value: import("@motionscript/sdk").Type<number, number, true>;
37
+ start: import("@motionscript/sdk").Type<number, number, false>;
38
+ end: import("@motionscript/sdk").Type<number, number, false>;
39
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
40
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
41
+ }>, {
42
+ readonly radiusTo: readonly ["radius"];
43
+ readonly strokeTo: readonly ["stroke"];
44
+ readonly shadowTo: readonly ["shadow"];
45
+ readonly progressTo: readonly ["start", "end"];
46
+ readonly flash: {
47
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
48
+ };
49
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
50
+ fromAngle: import("@motionscript/sdk").Type<number, number, false>;
51
+ toAngle: import("@motionscript/sdk").Type<number, number, false>;
52
+ radius: import("@motionscript/sdk").Type<number, number, false>;
53
+ /** `auto` draws the square where the angle is a right one. */
54
+ corner: import("@motionscript/sdk").Type<"auto" | "square" | "arc", "auto" | "square" | "arc", false>;
55
+ /** Text, a formula between dollar signs, or `°` for the angle's own size. */
56
+ label: import("@motionscript/sdk").Type<string, string, false>;
57
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
58
+ labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
59
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
60
+ /** The angle marked, in degrees: positive counter-clockwise. A formula reads it back as `[key.value]`. */
61
+ value: import("@motionscript/sdk").Type<number, number, true>;
62
+ start: import("@motionscript/sdk").Type<number, number, false>;
63
+ end: import("@motionscript/sdk").Type<number, number, false>;
64
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
65
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
66
+ }>, null>>;
67
+ export type AngleMark = NodeOf<typeof AngleMark>;
68
+ /** The angle a mark marks, in degrees: positive counter-clockwise. */
69
+ export declare function angleOf(s: Pick<AngleValues, "fromAngle" | "toAngle">): number;
70
+ export {};
46
71
  //# sourceMappingURL=angle-mark.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"angle-mark.d.ts","sourceRoot":"","sources":["../../src/annotate/angle-mark.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,UAAU,EAEV,SAAS,EAKT,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,UAAU,EAEf,KAAK,UAAU,EAEf,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,MAAM,EACd,MAAM,mBAAmB,CAAC;AAK3B,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAaD;;;;;GAKG;AACH,qBAOa,SAAU,SAAQ,SAAS,CAAC,cAAc,CAAC;IACP,SAAS,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IACP,MAAM,EAAE,MAAM,CAAC;IACtE,8DAA8D;IACgC,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAEhI,6EAA6E;IACvB,KAAK,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,KAAK,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IAGjE,MAAM,EAAE,MAAM,CAAC;gBAEX,KAAK,CAAC,EAAE,UAAU,CAAC,SAAS,EAAE,cAAc,CAAC;IAIzD,+BAA+B;IAE/B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAI/F,gEAAgE;IAChE,IAAI,KAAK,IAAI,MAAM,CAElB;IAEQ,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAMvC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;cAIhB,aAAa,IAAI,UAAU,GAAG,IAAI;cAKlC,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAShD,YAAY,IAAI,SAAS;IAMlC,OAAO,CAAC,QAAQ;CAuBnB"}
1
+ {"version":3,"file":"angle-mark.d.ts","sourceRoot":"","sources":["../../src/annotate/angle-mark.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,KAAK,UAAU,EAGf,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAM3B,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AA6BD,UAAU,WAAW;IACjB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC9C;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS;;;;IAxBlB,8DAA8D;;IAE9D,6EAA6E;;;;;IAK7E,0GAA0G;;;;;;;;;;;;;;;;;;IAP1G,8DAA8D;;IAE9D,6EAA6E;;;;;IAK7E,0GAA0G;;;;;;UAkD5G,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AAEjD,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC,GAAG,MAAM,CAE7E"}