@motionscript/math 0.0.0-stage → 0.1.0-alpha.10

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 (335) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +49 -0
  4. package/README.md +389 -2
  5. package/dist/annotate/angle-mark.d.ts +96 -0
  6. package/dist/annotate/angle-mark.d.ts.map +1 -0
  7. package/dist/annotate/angle-mark.js +97 -0
  8. package/dist/annotate/angle-mark.js.map +1 -0
  9. package/dist/annotate/curly-brace.d.ts +115 -0
  10. package/dist/annotate/curly-brace.d.ts.map +1 -0
  11. package/dist/annotate/curly-brace.js +99 -0
  12. package/dist/annotate/curly-brace.js.map +1 -0
  13. package/dist/annotate/emphasis-mark.d.ts +80 -0
  14. package/dist/annotate/emphasis-mark.d.ts.map +1 -0
  15. package/dist/annotate/emphasis-mark.js +80 -0
  16. package/dist/annotate/emphasis-mark.js.map +1 -0
  17. package/dist/browser/THIRD_PARTY_LICENSES.txt +420 -0
  18. package/dist/browser/chunks/chunk-IRZCG6PM.js +2 -0
  19. package/dist/browser/chunks/chunk-IRZCG6PM.js.map +7 -0
  20. package/dist/browser/chunks/chunk-WMVW6ZIV.js +2 -0
  21. package/dist/browser/chunks/chunk-WMVW6ZIV.js.map +7 -0
  22. package/dist/browser/chunks/mathjax-WV55AC2P.js +61 -0
  23. package/dist/browser/chunks/mathjax-WV55AC2P.js.map +7 -0
  24. package/dist/browser/index.js +2 -0
  25. package/dist/browser/index.js.map +7 -0
  26. package/dist/browser/kit.js +2 -0
  27. package/dist/browser/kit.js.map +7 -0
  28. package/dist/browser/manifest.json +30 -0
  29. package/dist/browser/tex.js +2 -0
  30. package/dist/browser/tex.js.map +7 -0
  31. package/dist/engine.d.ts +71 -0
  32. package/dist/engine.d.ts.map +1 -0
  33. package/dist/engine.js +45 -0
  34. package/dist/engine.js.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +30 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/kit/brace.d.ts +8 -0
  40. package/dist/kit/brace.d.ts.map +1 -0
  41. package/dist/kit/brace.js +36 -0
  42. package/dist/kit/brace.js.map +1 -0
  43. package/dist/kit/cache.d.ts +30 -0
  44. package/dist/kit/cache.d.ts.map +1 -0
  45. package/dist/kit/cache.js +53 -0
  46. package/dist/kit/cache.js.map +1 -0
  47. package/dist/kit/component.d.ts +51 -0
  48. package/dist/kit/component.d.ts.map +1 -0
  49. package/dist/kit/component.js +30 -0
  50. package/dist/kit/component.js.map +1 -0
  51. package/dist/kit/contour.d.ts +8 -0
  52. package/dist/kit/contour.d.ts.map +1 -0
  53. package/dist/kit/contour.js +93 -0
  54. package/dist/kit/contour.js.map +1 -0
  55. package/dist/kit/coords.d.ts +69 -0
  56. package/dist/kit/coords.d.ts.map +1 -0
  57. package/dist/kit/coords.js +224 -0
  58. package/dist/kit/coords.js.map +1 -0
  59. package/dist/kit/curve.d.ts +28 -0
  60. package/dist/kit/curve.d.ts.map +1 -0
  61. package/dist/kit/curve.js +29 -0
  62. package/dist/kit/curve.js.map +1 -0
  63. package/dist/kit/equation.d.ts +61 -0
  64. package/dist/kit/equation.d.ts.map +1 -0
  65. package/dist/kit/equation.js +168 -0
  66. package/dist/kit/equation.js.map +1 -0
  67. package/dist/kit/equation3d.d.ts +50 -0
  68. package/dist/kit/equation3d.d.ts.map +1 -0
  69. package/dist/kit/equation3d.js +103 -0
  70. package/dist/kit/equation3d.js.map +1 -0
  71. package/dist/kit/expression.d.ts +35 -0
  72. package/dist/kit/expression.d.ts.map +1 -0
  73. package/dist/kit/expression.js +124 -0
  74. package/dist/kit/expression.js.map +1 -0
  75. package/dist/kit/field-mark.d.ts +79 -0
  76. package/dist/kit/field-mark.d.ts.map +1 -0
  77. package/dist/kit/field-mark.js +109 -0
  78. package/dist/kit/field-mark.js.map +1 -0
  79. package/dist/kit/field.d.ts +14 -0
  80. package/dist/kit/field.d.ts.map +1 -0
  81. package/dist/kit/field.js +46 -0
  82. package/dist/kit/field.js.map +1 -0
  83. package/dist/kit/follow.d.ts +109 -0
  84. package/dist/kit/follow.d.ts.map +1 -0
  85. package/dist/kit/follow.js +163 -0
  86. package/dist/kit/follow.js.map +1 -0
  87. package/dist/kit/furniture.d.ts +32 -0
  88. package/dist/kit/furniture.d.ts.map +1 -0
  89. package/dist/kit/furniture.js +92 -0
  90. package/dist/kit/furniture.js.map +1 -0
  91. package/dist/kit/geometry.d.ts +13 -0
  92. package/dist/kit/geometry.d.ts.map +1 -0
  93. package/dist/kit/geometry.js +54 -0
  94. package/dist/kit/geometry.js.map +1 -0
  95. package/dist/kit/graph.d.ts +46 -0
  96. package/dist/kit/graph.d.ts.map +1 -0
  97. package/dist/kit/graph.js +90 -0
  98. package/dist/kit/graph.js.map +1 -0
  99. package/dist/kit/mark.d.ts +72 -0
  100. package/dist/kit/mark.d.ts.map +1 -0
  101. package/dist/kit/mark.js +87 -0
  102. package/dist/kit/mark.js.map +1 -0
  103. package/dist/kit/part-fills.d.ts +23 -0
  104. package/dist/kit/part-fills.d.ts.map +1 -0
  105. package/dist/kit/part-fills.js +46 -0
  106. package/dist/kit/part-fills.js.map +1 -0
  107. package/dist/kit/place.d.ts +20 -0
  108. package/dist/kit/place.d.ts.map +1 -0
  109. package/dist/kit/place.js +66 -0
  110. package/dist/kit/place.js.map +1 -0
  111. package/dist/kit/sampler.d.ts +17 -0
  112. package/dist/kit/sampler.d.ts.map +1 -0
  113. package/dist/kit/sampler.js +250 -0
  114. package/dist/kit/sampler.js.map +1 -0
  115. package/dist/kit/scale.d.ts +12 -0
  116. package/dist/kit/scale.d.ts.map +1 -0
  117. package/dist/kit/scale.js +37 -0
  118. package/dist/kit/scale.js.map +1 -0
  119. package/dist/kit/source.d.ts +22 -0
  120. package/dist/kit/source.d.ts.map +1 -0
  121. package/dist/kit/source.js +45 -0
  122. package/dist/kit/source.js.map +1 -0
  123. package/dist/kit/system.d.ts +31 -0
  124. package/dist/kit/system.d.ts.map +1 -0
  125. package/dist/kit/system.js +71 -0
  126. package/dist/kit/system.js.map +1 -0
  127. package/dist/kit/ticks.d.ts +19 -0
  128. package/dist/kit/ticks.d.ts.map +1 -0
  129. package/dist/kit/ticks.js +78 -0
  130. package/dist/kit/ticks.js.map +1 -0
  131. package/dist/kit/withdrawn.d.ts +9 -0
  132. package/dist/kit/withdrawn.d.ts.map +1 -0
  133. package/dist/kit/withdrawn.js +9 -0
  134. package/dist/kit/withdrawn.js.map +1 -0
  135. package/dist/marks/curve-area.d.ts +51 -0
  136. package/dist/marks/curve-area.d.ts.map +1 -0
  137. package/dist/marks/curve-area.js +59 -0
  138. package/dist/marks/curve-area.js.map +1 -0
  139. package/dist/marks/drop-lines.d.ts +57 -0
  140. package/dist/marks/drop-lines.d.ts.map +1 -0
  141. package/dist/marks/drop-lines.js +43 -0
  142. package/dist/marks/drop-lines.js.map +1 -0
  143. package/dist/marks/plot-point.d.ts +71 -0
  144. package/dist/marks/plot-point.d.ts.map +1 -0
  145. package/dist/marks/plot-point.js +71 -0
  146. package/dist/marks/plot-point.js.map +1 -0
  147. package/dist/marks/riemann-sum.d.ts +58 -0
  148. package/dist/marks/riemann-sum.d.ts.map +1 -0
  149. package/dist/marks/riemann-sum.js +63 -0
  150. package/dist/marks/riemann-sum.js.map +1 -0
  151. package/dist/marks/tangent-line.d.ts +71 -0
  152. package/dist/marks/tangent-line.d.ts.map +1 -0
  153. package/dist/marks/tangent-line.js +89 -0
  154. package/dist/marks/tangent-line.js.map +1 -0
  155. package/dist/marks/vector-arrow.d.ts +60 -0
  156. package/dist/marks/vector-arrow.d.ts.map +1 -0
  157. package/dist/marks/vector-arrow.js +67 -0
  158. package/dist/marks/vector-arrow.js.map +1 -0
  159. package/dist/nodes.d.ts +43 -0
  160. package/dist/nodes.d.ts.map +1 -0
  161. package/dist/nodes.js +57 -0
  162. package/dist/nodes.js.map +1 -0
  163. package/dist/plots/function-plot.d.ts +159 -0
  164. package/dist/plots/function-plot.d.ts.map +1 -0
  165. package/dist/plots/function-plot.js +184 -0
  166. package/dist/plots/function-plot.js.map +1 -0
  167. package/dist/plots/points-plot.d.ts +64 -0
  168. package/dist/plots/points-plot.d.ts.map +1 -0
  169. package/dist/plots/points-plot.js +72 -0
  170. package/dist/plots/points-plot.js.map +1 -0
  171. package/dist/plots/stream-lines.d.ts +76 -0
  172. package/dist/plots/stream-lines.d.ts.map +1 -0
  173. package/dist/plots/stream-lines.js +122 -0
  174. package/dist/plots/stream-lines.js.map +1 -0
  175. package/dist/plots/traced-path.d.ts +70 -0
  176. package/dist/plots/traced-path.d.ts.map +1 -0
  177. package/dist/plots/traced-path.js +41 -0
  178. package/dist/plots/traced-path.js.map +1 -0
  179. package/dist/plots/vector-field.d.ts +60 -0
  180. package/dist/plots/vector-field.d.ts.map +1 -0
  181. package/dist/plots/vector-field.js +77 -0
  182. package/dist/plots/vector-field.js.map +1 -0
  183. package/dist/structures/graph-layout.d.ts +11 -0
  184. package/dist/structures/graph-layout.d.ts.map +1 -0
  185. package/dist/structures/graph-layout.js +135 -0
  186. package/dist/structures/graph-layout.js.map +1 -0
  187. package/dist/structures/network-graph.d.ts +174 -0
  188. package/dist/structures/network-graph.d.ts.map +1 -0
  189. package/dist/structures/network-graph.js +240 -0
  190. package/dist/structures/network-graph.js.map +1 -0
  191. package/dist/structures/sample-space.d.ts +114 -0
  192. package/dist/structures/sample-space.d.ts.map +1 -0
  193. package/dist/structures/sample-space.js +161 -0
  194. package/dist/structures/sample-space.js.map +1 -0
  195. package/dist/systems/axes2d.d.ts +197 -0
  196. package/dist/systems/axes2d.d.ts.map +1 -0
  197. package/dist/systems/axes2d.js +157 -0
  198. package/dist/systems/axes2d.js.map +1 -0
  199. package/dist/systems/number-line.d.ts +101 -0
  200. package/dist/systems/number-line.d.ts.map +1 -0
  201. package/dist/systems/number-line.js +91 -0
  202. package/dist/systems/number-line.js.map +1 -0
  203. package/dist/systems/number-plane.d.ts +168 -0
  204. package/dist/systems/number-plane.d.ts.map +1 -0
  205. package/dist/systems/number-plane.js +186 -0
  206. package/dist/systems/number-plane.js.map +1 -0
  207. package/dist/systems/polar-plane.d.ts +98 -0
  208. package/dist/systems/polar-plane.d.ts.map +1 -0
  209. package/dist/systems/polar-plane.js +139 -0
  210. package/dist/systems/polar-plane.js.map +1 -0
  211. package/dist/tex/geometry.d.ts +85 -0
  212. package/dist/tex/geometry.d.ts.map +1 -0
  213. package/dist/tex/geometry.js +632 -0
  214. package/dist/tex/geometry.js.map +1 -0
  215. package/dist/tex/index.d.ts +11 -0
  216. package/dist/tex/index.d.ts.map +1 -0
  217. package/dist/tex/index.js +10 -0
  218. package/dist/tex/index.js.map +1 -0
  219. package/dist/tex/mathjax.d.ts +33 -0
  220. package/dist/tex/mathjax.d.ts.map +1 -0
  221. package/dist/tex/mathjax.js +74 -0
  222. package/dist/tex/mathjax.js.map +1 -0
  223. package/dist/tex/matrix.d.ts +101 -0
  224. package/dist/tex/matrix.d.ts.map +1 -0
  225. package/dist/tex/matrix.js +56 -0
  226. package/dist/tex/matrix.js.map +1 -0
  227. package/dist/tex/node.d.ts +98 -0
  228. package/dist/tex/node.d.ts.map +1 -0
  229. package/dist/tex/node.js +25 -0
  230. package/dist/tex/node.js.map +1 -0
  231. package/dist/tex/tween.d.ts +50 -0
  232. package/dist/tex/tween.d.ts.map +1 -0
  233. package/dist/tex/tween.js +253 -0
  234. package/dist/tex/tween.js.map +1 -0
  235. package/dist/tex/typeset.d.ts +133 -0
  236. package/dist/tex/typeset.d.ts.map +1 -0
  237. package/dist/tex/typeset.js +403 -0
  238. package/dist/tex/typeset.js.map +1 -0
  239. package/dist/three/axes3d.d.ts +247 -0
  240. package/dist/three/axes3d.d.ts.map +1 -0
  241. package/dist/three/axes3d.js +187 -0
  242. package/dist/three/axes3d.js.map +1 -0
  243. package/dist/three/curve-plot3d.d.ts +126 -0
  244. package/dist/three/curve-plot3d.d.ts.map +1 -0
  245. package/dist/three/curve-plot3d.js +109 -0
  246. package/dist/three/curve-plot3d.js.map +1 -0
  247. package/dist/three/entries.d.ts +17 -0
  248. package/dist/three/entries.d.ts.map +1 -0
  249. package/dist/three/entries.js +15 -0
  250. package/dist/three/entries.js.map +1 -0
  251. package/dist/three/label3d.d.ts +11 -0
  252. package/dist/three/label3d.d.ts.map +1 -0
  253. package/dist/three/label3d.js +42 -0
  254. package/dist/three/label3d.js.map +1 -0
  255. package/dist/three/plot-point3d.d.ts +99 -0
  256. package/dist/three/plot-point3d.d.ts.map +1 -0
  257. package/dist/three/plot-point3d.js +34 -0
  258. package/dist/three/plot-point3d.js.map +1 -0
  259. package/dist/three/space.d.ts +43 -0
  260. package/dist/three/space.d.ts.map +1 -0
  261. package/dist/three/space.js +58 -0
  262. package/dist/three/space.js.map +1 -0
  263. package/dist/three/surface-plot3d.d.ts +207 -0
  264. package/dist/three/surface-plot3d.d.ts.map +1 -0
  265. package/dist/three/surface-plot3d.js +261 -0
  266. package/dist/three/surface-plot3d.js.map +1 -0
  267. package/dist/three/vector-arrow3d.d.ts +96 -0
  268. package/dist/three/vector-arrow3d.d.ts.map +1 -0
  269. package/dist/three/vector-arrow3d.js +53 -0
  270. package/dist/three/vector-arrow3d.js.map +1 -0
  271. package/package.json +80 -3
  272. package/registry.json +251 -0
  273. package/src/annotate/angle-mark.ts +137 -0
  274. package/src/annotate/curly-brace.ts +148 -0
  275. package/src/annotate/emphasis-mark.ts +118 -0
  276. package/src/engine.ts +86 -0
  277. package/src/index.ts +29 -0
  278. package/src/kit/brace.ts +37 -0
  279. package/src/kit/cache.ts +61 -0
  280. package/src/kit/component.ts +57 -0
  281. package/src/kit/contour.ts +94 -0
  282. package/src/kit/coords.ts +278 -0
  283. package/src/kit/curve.ts +47 -0
  284. package/src/kit/equation.ts +181 -0
  285. package/src/kit/equation3d.ts +137 -0
  286. package/src/kit/expression.ts +159 -0
  287. package/src/kit/field-mark.ts +171 -0
  288. package/src/kit/field.ts +50 -0
  289. package/src/kit/follow.ts +229 -0
  290. package/src/kit/furniture.ts +113 -0
  291. package/src/kit/geometry.ts +49 -0
  292. package/src/kit/graph.ts +116 -0
  293. package/src/kit/mark.ts +152 -0
  294. package/src/kit/part-fills.ts +61 -0
  295. package/src/kit/place.ts +77 -0
  296. package/src/kit/sampler.ts +281 -0
  297. package/src/kit/scale.ts +39 -0
  298. package/src/kit/source.ts +57 -0
  299. package/src/kit/system.ts +105 -0
  300. package/src/kit/ticks.ts +85 -0
  301. package/src/kit/withdrawn.ts +8 -0
  302. package/src/marks/curve-area.ts +89 -0
  303. package/src/marks/drop-lines.ts +71 -0
  304. package/src/marks/plot-point.ts +102 -0
  305. package/src/marks/riemann-sum.ts +99 -0
  306. package/src/marks/tangent-line.ts +119 -0
  307. package/src/marks/vector-arrow.ts +98 -0
  308. package/src/nodes.ts +99 -0
  309. package/src/plots/function-plot.ts +220 -0
  310. package/src/plots/points-plot.ts +103 -0
  311. package/src/plots/stream-lines.ts +160 -0
  312. package/src/plots/traced-path.ts +70 -0
  313. package/src/plots/vector-field.ts +107 -0
  314. package/src/structures/graph-layout.ts +145 -0
  315. package/src/structures/network-graph.ts +291 -0
  316. package/src/structures/sample-space.ts +210 -0
  317. package/src/systems/axes2d.ts +226 -0
  318. package/src/systems/number-line.ts +130 -0
  319. package/src/systems/number-plane.ts +232 -0
  320. package/src/systems/polar-plane.ts +177 -0
  321. package/src/tex/geometry.ts +703 -0
  322. package/src/tex/index.ts +15 -0
  323. package/src/tex/mathjax.ts +82 -0
  324. package/src/tex/matrix.ts +97 -0
  325. package/src/tex/node.ts +74 -0
  326. package/src/tex/tween.ts +308 -0
  327. package/src/tex/typeset.ts +461 -0
  328. package/src/three/axes3d.ts +267 -0
  329. package/src/three/curve-plot3d.ts +146 -0
  330. package/src/three/entries.ts +42 -0
  331. package/src/three/label3d.ts +52 -0
  332. package/src/three/plot-point3d.ts +63 -0
  333. package/src/three/space.ts +92 -0
  334. package/src/three/surface-plot3d.ts +318 -0
  335. package/src/three/vector-arrow3d.ts +88 -0
@@ -0,0 +1,96 @@
1
+ import { type Mesh3DProps, type NodeOf, type Vector3, type Vector3Input, type Blend3D as _Blend3D, type Color as _Color, type Faces3D as _Faces3D, type Fill3D as _Fill3D, type Geometry3D as _Geometry3D, type Material3D as _Material3D, type Node3D as _Node3D, type Node3DProps as _Node3DProps, type NormalizedColor as _NormalizedColor, type Shading3D as _Shading3D, type Texture3D as _Texture3D } from "@motionscript/sdk";
2
+ export interface VectorArrow3dProps extends Mesh3DProps {
3
+ tail?: Vector3Input;
4
+ head?: Vector3Input;
5
+ thickness?: number;
6
+ tip?: boolean;
7
+ }
8
+ /** An arrow between two points of a 3D graph: a vector from the origin by default. */
9
+ export declare const VectorArrow3d: import("@motionscript/sdk").Component<"vectorArrow3d", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
10
+ tail: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
11
+ head: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
12
+ /** The radius of the shaft, in scene units; the tip is sized from it. */
13
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
14
+ tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
15
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
16
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
17
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
18
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
19
+ geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
20
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
21
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
22
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
23
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
24
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
25
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
26
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
27
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
28
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
29
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
30
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
31
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
32
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
33
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
34
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
35
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
36
+ }>, {
37
+ readonly endpointsTo: readonly ["tail", "head"];
38
+ }, null, _Node3D<_Node3DProps>, import("@motionscript/sdk").CallProps3D<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
39
+ tail: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
40
+ head: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
41
+ /** The radius of the shaft, in scene units; the tip is sized from it. */
42
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
43
+ tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
44
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
45
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
46
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
47
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
48
+ geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
49
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
50
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
51
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
52
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
53
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
54
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
55
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
56
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
57
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
58
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
59
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
60
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
61
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
62
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
63
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
64
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
65
+ }>, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Transform3DState, {
66
+ tail: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
67
+ head: import("@motionscript/sdk").Type<Vector3Input, Vector3, false>;
68
+ /** The radius of the shaft, in scene units; the tip is sized from it. */
69
+ thickness: import("@motionscript/sdk").Type<number, number, false>;
70
+ tip: import("@motionscript/sdk").Type<boolean, boolean, false>;
71
+ graph: import("@motionscript/sdk").Type<import("./space.js").Graph3D | null, import("./space.js").Graph3D | null, true>;
72
+ fill: import("@motionscript/sdk").Type<_Fill3D, _Fill3D, false>;
73
+ blend: import("@motionscript/sdk").Type<_Blend3D | undefined, _Blend3D | undefined, false>;
74
+ opacity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
75
+ geometry: import("@motionscript/sdk").Type<_Geometry3D | undefined, _Geometry3D | undefined, false>;
76
+ material: import("@motionscript/sdk").Type<_Material3D | readonly _Material3D[] | undefined, _Material3D | readonly _Material3D[] | undefined, false>;
77
+ roughness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
78
+ metalness: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
79
+ emission: import("@motionscript/sdk").Type<_Color | undefined, _NormalizedColor | undefined, false>;
80
+ emissionStrength: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
81
+ normalMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
82
+ roughnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
83
+ metalnessMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
84
+ aoMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
85
+ alphaMap: import("@motionscript/sdk").Type<_Texture3D | undefined, _Texture3D | undefined, false>;
86
+ envMapIntensity: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
87
+ wireframe: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
88
+ shading: import("@motionscript/sdk").Type<_Shading3D | undefined, _Shading3D | undefined, false>;
89
+ faces: import("@motionscript/sdk").Type<_Faces3D | undefined, _Faces3D | undefined, false>;
90
+ vertexColors: import("@motionscript/sdk").Type<boolean | undefined, boolean | undefined, false>;
91
+ unlit: import("@motionscript/sdk").Type<boolean, boolean, false>;
92
+ }>, {
93
+ readonly endpointsTo: readonly ["tail", "head"];
94
+ }, _Node3D<_Node3DProps>>>>;
95
+ export type VectorArrow3d = NodeOf<typeof VectorArrow3d>;
96
+ //# sourceMappingURL=vector-arrow3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector-arrow3d.d.ts","sourceRoot":"","sources":["../../src/three/vector-arrow3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,KAAK,WAAW,EAChB,KAAK,MAAM,EAEX,KAAK,OAAO,EACZ,KAAK,YAAY,EAEjB,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,KAAK,IAAI,MAAM,EACpB,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,UAAU,IAAI,WAAW,EAC9B,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,SAAS,IAAI,UAAU,EAC5B,KAAK,SAAS,IAAI,UAAU,EAC/B,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;CACjB;AAgBD,sFAAsF;AACtF,eAAO,MAAM,aAAa;;;IAPtB,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAzE,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAzE,yEAAyE;;;;;;;;;;;;;;;;;;;;;;;;;;2BAe3E,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { component3d, Graphics3D, lerpVector3, Material, resolveVector3, Types, } from "@motionscript/sdk";
2
+ import { meshEntries } from "./entries.js";
3
+ import { aim, graphEntry, graphOf } from "./space.js";
4
+ function point(initial) {
5
+ return Types.custom(initial, { resolve: resolveVector3, lerp: lerpVector3, kind: "vector3" });
6
+ }
7
+ const state = {
8
+ ...meshEntries,
9
+ tail: point({ x: 0, y: 0, z: 0 }),
10
+ head: point({ x: 1, y: 1, z: 1 }),
11
+ /** The radius of the shaft, in scene units; the tip is sized from it. */
12
+ thickness: Types.number(0.035, { min: 0.001, step: 0.005 }),
13
+ tip: Types.boolean(true, { animatable: false }),
14
+ graph: graphEntry(),
15
+ };
16
+ /** An arrow between two points of a 3D graph: a vector from the origin by default. */
17
+ export const VectorArrow3d = component3d({
18
+ key: "vectorArrow3d",
19
+ state,
20
+ commands: {
21
+ /** Animate either end, or both. */
22
+ endpointsTo: { args: ["tail", "head"] },
23
+ },
24
+ render: (ctx, s) => ctx.draw(drawArrow(s)),
25
+ });
26
+ function drawArrow(s) {
27
+ const g3 = new Graphics3D();
28
+ const space = graphOf(s);
29
+ const { tail, head, thickness } = s;
30
+ // Outside a graph an arrow is drawn in the scene's own units.
31
+ const from = space ? space.offset(tail.x, tail.y, tail.z) : tail;
32
+ const to = space ? space.offset(head.x, head.y, head.z) : head;
33
+ const along = { x: to.x - from.x, y: to.y - from.y, z: to.z - from.z };
34
+ const length = Math.hypot(along.x, along.y, along.z);
35
+ if (!(length > 0))
36
+ return g3;
37
+ const paint = Material.shorthand(s);
38
+ const quaternion = aim(along);
39
+ const tipLength = s.tip ? Math.min(thickness * 8, length) : 0;
40
+ const shaft = length - tipLength;
41
+ const at = (distance) => ({
42
+ x: from.x + (along.x * distance) / length,
43
+ y: from.y + (along.y * distance) / length,
44
+ z: from.z + (along.z * distance) / length,
45
+ });
46
+ if (shaft > 0)
47
+ g3.cylinder({ ...paint, radius: thickness, height: shaft, segments: [12, 1], position: at(shaft / 2), quaternion });
48
+ if (tipLength > 0) {
49
+ g3.cone({ ...paint, radius: thickness * 2.8, height: tipLength, segments: [20, 1], position: at(shaft + tipLength / 2), quaternion });
50
+ }
51
+ return g3;
52
+ }
53
+ //# sourceMappingURL=vector-arrow3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector-arrow3d.js","sourceRoot":"","sources":["../../src/three/vector-arrow3d.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n component3d,\n Graphics3D,\n lerpVector3,\n Material,\n resolveVector3,\n Types,\n type Mesh3DProps,\n type NodeOf,\n type Values,\n type Vector3,\n type Vector3Input,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Blend3D as _Blend3D,\n type Color as _Color,\n type Faces3D as _Faces3D,\n type Fill3D as _Fill3D,\n type Geometry3D as _Geometry3D,\n type Material3D as _Material3D,\n type Node3D as _Node3D,\n type Node3DProps as _Node3DProps,\n type NormalizedColor as _NormalizedColor,\n type Shading3D as _Shading3D,\n type Texture3D as _Texture3D,\n} from \"@motionscript/sdk\";\nimport { meshEntries } from \"./entries\";\nimport { aim, graphEntry, graphOf } from \"./space\";\n\nexport interface VectorArrow3dProps extends Mesh3DProps {\n tail?: Vector3Input;\n head?: Vector3Input;\n thickness?: number;\n tip?: boolean;\n}\n\nfunction point(initial: Vector3) {\n return Types.custom<Vector3Input, Vector3>(initial, { resolve: resolveVector3, lerp: lerpVector3, kind: \"vector3\" });\n}\n\nconst state = {\n ...meshEntries,\n tail: point({ x: 0, y: 0, z: 0 }),\n head: point({ x: 1, y: 1, z: 1 }),\n /** The radius of the shaft, in scene units; the tip is sized from it. */\n thickness: Types.number(0.035, { min: 0.001, step: 0.005 }),\n tip: Types.boolean(true, { animatable: false }),\n graph: graphEntry(),\n};\n\n/** An arrow between two points of a 3D graph: a vector from the origin by default. */\nexport const VectorArrow3d = component3d({\n key: \"vectorArrow3d\",\n state,\n commands: {\n /** Animate either end, or both. */\n endpointsTo: { args: [\"tail\", \"head\"] },\n },\n render: (ctx, s) => ctx.draw(drawArrow(s)),\n});\n\nexport type VectorArrow3d = NodeOf<typeof VectorArrow3d>;\n\nfunction drawArrow(s: Values<typeof state>): Graphics3D {\n const g3 = new Graphics3D();\n const space = graphOf(s);\n const { tail, head, thickness } = s;\n // Outside a graph an arrow is drawn in the scene's own units.\n const from = space ? space.offset(tail.x, tail.y, tail.z) : tail;\n const to = space ? space.offset(head.x, head.y, head.z) : head;\n const along: Vector3 = { x: to.x - from.x, y: to.y - from.y, z: to.z - from.z };\n const length = Math.hypot(along.x, along.y, along.z);\n if (!(length > 0)) return g3;\n\n const paint = Material.shorthand(s);\n const quaternion = aim(along);\n const tipLength = s.tip ? Math.min(thickness * 8, length) : 0;\n const shaft = length - tipLength;\n const at = (distance: number): Vector3 => ({\n x: from.x + (along.x * distance) / length,\n y: from.y + (along.y * distance) / length,\n z: from.z + (along.z * distance) / length,\n });\n if (shaft > 0) g3.cylinder({ ...paint, radius: thickness, height: shaft, segments: [12, 1], position: at(shaft / 2), quaternion });\n if (tipLength > 0) {\n g3.cone({ ...paint, radius: thickness * 2.8, height: tipLength, segments: [20, 1], position: at(shaft + tipLength / 2), quaternion });\n }\n return g3;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,83 @@
1
1
  {
2
2
  "name": "@motionscript/math",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.10",
4
+ "type": "module",
5
+ "description": "Math for Motion Script: coordinate systems, function and vector-field plots, 3D graphs and surfaces, network graphs, and LaTeX formulas typeset to glyph paths that morph token by token.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/motionscript-dev/motionscript.git",
9
+ "directory": "packages/components/math"
10
+ },
11
+ "homepage": "https://motionscript.dev",
12
+ "bugs": {
13
+ "url": "https://github.com/motionscript-dev/motionscript/issues"
14
+ },
15
+ "main": "dist/index.js",
16
+ "types": "dist/index.d.ts",
17
+ "sideEffects": false,
18
+ "files": [
19
+ "NOTICE",
20
+ "dist",
21
+ "src",
22
+ "registry.json",
23
+ "CHANGELOG.md",
24
+ "!dist/**/*.tsbuildinfo",
25
+ "!src/**/tests/**",
26
+ "!src/**/*.test.ts",
27
+ "!src/**/*.test.tsx",
28
+ "!src/**/*.fixtures.ts"
29
+ ],
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./kit": {
36
+ "types": "./dist/engine.d.ts",
37
+ "default": "./dist/engine.js"
38
+ },
39
+ "./tex": {
40
+ "types": "./dist/tex/index.d.ts",
41
+ "default": "./dist/tex/index.js"
42
+ }
43
+ },
44
+ "keywords": [
45
+ "motion-script",
46
+ "motion script",
47
+ "math",
48
+ "latex",
49
+ "animation"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "license": "Apache-2.0",
55
+ "author": "Motionscript",
56
+ "peerDependencies": {
57
+ "@motionscript/sdk": "^0.1.0-alpha.10"
58
+ },
59
+ "dependencies": {
60
+ "@mathjax/mathjax-newcm-font": "^4.1.1",
61
+ "@mathjax/src": "^4.1.1"
62
+ },
63
+ "devDependencies": {
64
+ "@types/node": "^25.6.2",
65
+ "eslint": "^9.39.4",
66
+ "eslint-import-resolver-typescript": "^4.4.4",
67
+ "eslint-plugin-import-x": "^4.16.1",
68
+ "tsc-alias": "^1.8.16",
69
+ "typescript": "^6.0.3",
70
+ "typescript-eslint": "^8.48.0",
71
+ "vitest": "^4.1.5",
72
+ "@motionscript/core": "0.1.0-alpha.10",
73
+ "@motionscript/sdk": "0.1.0-alpha.10"
74
+ },
75
+ "scripts": {
76
+ "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && node ../../../scripts/build-browser.mjs",
77
+ "dev": "tsc -p tsconfig.build.json --watch & tsc-alias -p tsconfig.build.json --resolve-full-paths -w",
78
+ "clean": "rimraf --glob dist .turbo *.tsbuildinfo",
79
+ "test": "vitest",
80
+ "lint": "eslint .",
81
+ "typecheck": "tsc -p tsconfig.json --noEmit"
82
+ }
6
83
  }
package/registry.json ADDED
@@ -0,0 +1,251 @@
1
+ {
2
+ "kit": {
3
+ "barrel": "src/engine.ts",
4
+ "specifier": "@motionscript/math"
5
+ },
6
+ "items": [
7
+ {
8
+ "name": "latex",
9
+ "description": "A LaTeX formula drawn as glyph paths, morphing token by token between formulas.",
10
+ "root": "src/tex",
11
+ "files": [
12
+ "node.ts"
13
+ ],
14
+ "flatten": true
15
+ },
16
+ {
17
+ "name": "latex-matrix",
18
+ "description": "A matrix typeset from its entries, each one addressable as a part.",
19
+ "root": "src/tex",
20
+ "files": [
21
+ "matrix.ts"
22
+ ],
23
+ "flatten": true
24
+ },
25
+ {
26
+ "name": "number-line",
27
+ "description": "One axis with ticks and numbers; children sit at a value along it.",
28
+ "root": "src/systems",
29
+ "files": [
30
+ "number-line.ts"
31
+ ],
32
+ "flatten": true
33
+ },
34
+ {
35
+ "name": "axes2d",
36
+ "description": "An x and a y axis whose children sit in graph coordinates.",
37
+ "root": "src/systems",
38
+ "files": [
39
+ "axes2d.ts"
40
+ ],
41
+ "flatten": true
42
+ },
43
+ {
44
+ "name": "number-plane",
45
+ "description": "Axes over a full grid with square units.",
46
+ "root": "src/systems",
47
+ "files": [
48
+ "number-plane.ts"
49
+ ],
50
+ "flatten": true
51
+ },
52
+ {
53
+ "name": "function-plot",
54
+ "description": "The curve of an equation: a function, a polar or a parametric one.",
55
+ "root": "src/plots",
56
+ "files": [
57
+ "function-plot.ts"
58
+ ],
59
+ "flatten": true
60
+ },
61
+ {
62
+ "name": "points-plot",
63
+ "description": "A line or closed shape through listed graph points.",
64
+ "root": "src/plots",
65
+ "files": [
66
+ "points-plot.ts"
67
+ ],
68
+ "flatten": true
69
+ },
70
+ {
71
+ "name": "plot-point",
72
+ "description": "A labelled dot at graph coordinates, or riding a plot.",
73
+ "root": "src/marks",
74
+ "files": [
75
+ "plot-point.ts"
76
+ ],
77
+ "flatten": true
78
+ },
79
+ {
80
+ "name": "vector-arrow",
81
+ "description": "An arrow between two graph points.",
82
+ "root": "src/marks",
83
+ "files": [
84
+ "vector-arrow.ts"
85
+ ],
86
+ "flatten": true
87
+ },
88
+ {
89
+ "name": "curve-area",
90
+ "description": "The region under a plot or between two.",
91
+ "root": "src/marks",
92
+ "files": [
93
+ "curve-area.ts"
94
+ ],
95
+ "flatten": true
96
+ },
97
+ {
98
+ "name": "riemann-sum",
99
+ "description": "Rectangles approximating the area under a plot.",
100
+ "root": "src/marks",
101
+ "files": [
102
+ "riemann-sum.ts"
103
+ ],
104
+ "flatten": true
105
+ },
106
+ {
107
+ "name": "tangent-line",
108
+ "description": "The tangent or a secant to a plot.",
109
+ "root": "src/marks",
110
+ "files": [
111
+ "tangent-line.ts"
112
+ ],
113
+ "flatten": true
114
+ },
115
+ {
116
+ "name": "drop-lines",
117
+ "description": "Guide lines from a graph point to the axes.",
118
+ "root": "src/marks",
119
+ "files": [
120
+ "drop-lines.ts"
121
+ ],
122
+ "flatten": true
123
+ },
124
+ {
125
+ "name": "curly-brace",
126
+ "description": "A curly brace along a node, a part of a formula, or two points.",
127
+ "root": "src/annotate",
128
+ "files": [
129
+ "curly-brace.ts"
130
+ ],
131
+ "flatten": true
132
+ },
133
+ {
134
+ "name": "angle-mark",
135
+ "description": "The arc or square of an angle, with its label.",
136
+ "root": "src/annotate",
137
+ "files": [
138
+ "angle-mark.ts"
139
+ ],
140
+ "flatten": true
141
+ },
142
+ {
143
+ "name": "emphasis-mark",
144
+ "description": "A box, circle, underline or cross drawn on a node or a part of a formula.",
145
+ "root": "src/annotate",
146
+ "files": [
147
+ "emphasis-mark.ts"
148
+ ],
149
+ "flatten": true
150
+ },
151
+ {
152
+ "name": "axes3d",
153
+ "description": "A 3D graph with its own camera: three axes through a box of graph coordinates, z up, whose children sit in graph units.",
154
+ "root": "src/three",
155
+ "files": [
156
+ "axes3d.ts"
157
+ ],
158
+ "flatten": true
159
+ },
160
+ {
161
+ "name": "surface-plot3d",
162
+ "description": "A surface in a 3D graph: a height over x and y, or three parts in u and v.",
163
+ "root": "src/three",
164
+ "files": [
165
+ "surface-plot3d.ts"
166
+ ],
167
+ "flatten": true
168
+ },
169
+ {
170
+ "name": "curve-plot3d",
171
+ "description": "A curve through a 3D graph, three parts in t, drawn as a tube.",
172
+ "root": "src/three",
173
+ "files": [
174
+ "curve-plot3d.ts"
175
+ ],
176
+ "flatten": true
177
+ },
178
+ {
179
+ "name": "plot-point3d",
180
+ "description": "A labelled dot at 3D graph coordinates, riding a surface it is put inside.",
181
+ "root": "src/three",
182
+ "files": [
183
+ "plot-point3d.ts"
184
+ ],
185
+ "flatten": true
186
+ },
187
+ {
188
+ "name": "vector-arrow3d",
189
+ "description": "An arrow between two points of a 3D graph.",
190
+ "root": "src/three",
191
+ "files": [
192
+ "vector-arrow3d.ts"
193
+ ],
194
+ "flatten": true
195
+ },
196
+ {
197
+ "name": "polar-plane",
198
+ "description": "Rings and spokes about an origin, whose children sit in graph coordinates.",
199
+ "root": "src/systems",
200
+ "files": [
201
+ "polar-plane.ts"
202
+ ],
203
+ "flatten": true
204
+ },
205
+ {
206
+ "name": "vector-field",
207
+ "description": "A grid of arrows showing a vector field, coloured by its strength.",
208
+ "root": "src/plots",
209
+ "files": [
210
+ "vector-field.ts"
211
+ ],
212
+ "flatten": true
213
+ },
214
+ {
215
+ "name": "stream-lines",
216
+ "description": "The lines a vector field carries a point along, which can be sent flowing.",
217
+ "root": "src/plots",
218
+ "files": [
219
+ "stream-lines.ts"
220
+ ],
221
+ "flatten": true
222
+ },
223
+ {
224
+ "name": "traced-path",
225
+ "description": "The trail a point leaves as a value changes.",
226
+ "root": "src/plots",
227
+ "files": [
228
+ "traced-path.ts"
229
+ ],
230
+ "flatten": true
231
+ },
232
+ {
233
+ "name": "network-graph",
234
+ "description": "Vertices and edges arranged in a circle, by springs, as a tree or in a grid.",
235
+ "root": "src/structures",
236
+ "files": [
237
+ "network-graph.ts"
238
+ ],
239
+ "flatten": true
240
+ },
241
+ {
242
+ "name": "sample-space",
243
+ "description": "A probability's whole cut into parts whose areas are their probabilities.",
244
+ "root": "src/structures",
245
+ "files": [
246
+ "sample-space.ts"
247
+ ],
248
+ "flatten": true
249
+ }
250
+ ]
251
+ }
@@ -0,0 +1,137 @@
1
+ import {
2
+ component2d,
3
+ Graphics2D,
4
+ Types,
5
+ type Color,
6
+ type NodeOf,
7
+ type NormalizedColor,
8
+ type PaintProps,
9
+ type PathCommand,
10
+ // Named so the emitted declaration reaches these through the sdk, not core.
11
+ type Node2D as _Node2D,
12
+ type Node2DProps as _Node2DProps,
13
+ type Shadow as _Shadow,
14
+ type ShadowResolved as _ShadowResolved,
15
+ type Stroke as _Stroke,
16
+ type StrokeResolved as _StrokeResolved,
17
+ } from "@motionscript/sdk";
18
+ import { listed, omit, PAINT, PAINT_COMMANDS, painted } from "../kit/component";
19
+ import { outlineBounds, OWN_FRAME } from "../kit/follow";
20
+ import { drawLabels, loadFormulas } from "../kit/furniture";
21
+ import { strokeShape } from "../kit/mark";
22
+
23
+ export interface AngleMarkProps extends PaintProps {
24
+ fromAngle?: number;
25
+ toAngle?: number;
26
+ radius?: number;
27
+ corner?: "arc" | "square" | "auto";
28
+ label?: string;
29
+ labelSize?: number;
30
+ labelColor?: Color;
31
+ fontFamily?: string;
32
+ }
33
+
34
+ /** Degrees of arc per drawn segment. */
35
+ const ARC_STEP = 4;
36
+ /** How close to a right angle `auto` draws the square. */
37
+ const RIGHT_SLOP = 0.5;
38
+
39
+ const point = (radius: number, degrees: number) => {
40
+ const turn = (degrees * Math.PI) / 180;
41
+ return { x: radius * Math.cos(turn), y: radius * Math.sin(turn) };
42
+ };
43
+
44
+ const state = {
45
+ // It is only an outline.
46
+ ...omit(PAINT, "fill"),
47
+ fromAngle: Types.number(0, { unit: "°" }),
48
+ toAngle: Types.number(60, { unit: "°" }),
49
+ radius: Types.number(48, { min: 0, unit: "px" }),
50
+ /** `auto` draws the square where the angle is a right one. */
51
+ corner: listed(["auto", "arc", "square"], "auto", { animatable: false }),
52
+ /** Text, a formula between dollar signs, or `°` for the angle's own size. */
53
+ label: Types.text("", { animatable: false }),
54
+ labelSize: Types.number(24, { min: 1, unit: "px" }),
55
+ labelColor: Types.color("#e5e7eb"),
56
+ fontFamily: Types.text("", { animatable: false }),
57
+ /** The angle marked, in degrees: positive counter-clockwise. A formula reads it back as `[key.value]`. */
58
+ value: Types.number(0, { private: true }),
59
+ };
60
+
61
+ interface AngleValues {
62
+ readonly fromAngle: number;
63
+ readonly toAngle: number;
64
+ readonly radius: number;
65
+ readonly corner: "arc" | "square" | "auto";
66
+ }
67
+
68
+ /**
69
+ * The mark of an angle at the node's own position: an arc from one direction
70
+ * to another, or the small square of a right angle, with an optional label.
71
+ * Directions are degrees counter-clockwise from the right, so binding one to a
72
+ * variable opens and closes the angle. A label of `°` shows the angle's size.
73
+ */
74
+ export const AngleMark = component2d({
75
+ key: "angleMark",
76
+ state,
77
+ defaults: { stroke: { weight: 3, fill: "#e5e7eb", align: "center", cap: "round", join: "round" }, width: "hug", height: "hug", value: (s) => angleOf(s) },
78
+ load: (loader, s) => {
79
+ if (s.label !== "" && s.fontFamily !== "") loader.font(s.fontFamily);
80
+ loadFormulas(loader, [s.label]);
81
+ },
82
+ commands: {
83
+ ...omit(PAINT_COMMANDS, "fillTo"),
84
+ /** Grow or shrink the mark. */
85
+ radiusTo: { args: ["radius"] },
86
+ },
87
+ measure: () => ({ width: 0, height: 0 }),
88
+ bounds: (_size, s) => outlineBounds(outline(s)),
89
+ render: (ctx, s) => {
90
+ const data = outline(s);
91
+ const shape = data.length > 0 ? () => new Graphics2D().path({ data, centerBounds: OWN_FRAME, start: s.start, end: s.end }) : null;
92
+ painted(
93
+ ctx,
94
+ () => {
95
+ if (shape) ctx.draw(shape().shadow(s.shadow).fill([]));
96
+ if (s.label === "" || s.radius <= 0) return;
97
+ const text = s.label === "°" ? `${Math.round(Math.abs(s.value) * 10) / 10}°` : s.label;
98
+ const at = point(s.radius + s.labelSize * 0.9, (s.fromAngle + s.toAngle) / 2);
99
+ const style = { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor };
100
+ ctx.draw(drawLabels([{ text, at, align: "center" }], style));
101
+ },
102
+ () => {
103
+ if (shape) strokeShape(ctx, shape, s);
104
+ },
105
+ );
106
+ },
107
+ });
108
+
109
+ export type AngleMark = NodeOf<typeof AngleMark>;
110
+
111
+ /** The angle a mark marks, in degrees: positive counter-clockwise. */
112
+ export function angleOf(s: Pick<AngleValues, "fromAngle" | "toAngle">): number {
113
+ return s.toAngle - s.fromAngle;
114
+ }
115
+
116
+ function outline({ fromAngle, toAngle, radius, corner }: AngleValues): PathCommand[] {
117
+ const sweep = toAngle - fromAngle;
118
+ if (radius <= 0 || sweep === 0) return [];
119
+ const square = corner === "square" || (corner === "auto" && Math.abs(Math.abs(sweep) - 90) < RIGHT_SLOP);
120
+ if (square) {
121
+ const side = radius * 0.6;
122
+ const a = point(side, fromAngle);
123
+ const b = point(side, toAngle);
124
+ return [
125
+ { type: "M", x: a.x, y: a.y },
126
+ { type: "L", x: a.x + b.x, y: a.y + b.y },
127
+ { type: "L", x: b.x, y: b.y },
128
+ ];
129
+ }
130
+ const steps = Math.max(2, Math.ceil(Math.abs(sweep) / ARC_STEP));
131
+ const out: PathCommand[] = [];
132
+ for (let i = 0; i <= steps; i++) {
133
+ const p = point(radius, fromAngle + (sweep * i) / steps);
134
+ out.push({ type: i === 0 ? "M" : "L", x: p.x, y: p.y });
135
+ }
136
+ return out;
137
+ }