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

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 (322) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +48 -0
  4. package/README.md +385 -3
  5. package/dist/annotate/angle-mark.d.ts +46 -0
  6. package/dist/annotate/angle-mark.d.ts.map +1 -0
  7. package/dist/annotate/angle-mark.js +132 -0
  8. package/dist/annotate/angle-mark.js.map +1 -0
  9. package/dist/annotate/curly-brace.d.ts +46 -0
  10. package/dist/annotate/curly-brace.d.ts.map +1 -0
  11. package/dist/annotate/curly-brace.js +114 -0
  12. package/dist/annotate/curly-brace.js.map +1 -0
  13. package/dist/annotate/emphasis-mark.d.ts +20 -0
  14. package/dist/annotate/emphasis-mark.d.ts.map +1 -0
  15. package/dist/annotate/emphasis-mark.js +81 -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-3GJB6AVO.js +2 -0
  19. package/dist/browser/chunks/chunk-3GJB6AVO.js.map +7 -0
  20. package/dist/browser/chunks/chunk-D5WHCVBC.js +2 -0
  21. package/dist/browser/chunks/chunk-D5WHCVBC.js.map +7 -0
  22. package/dist/browser/chunks/chunk-WL4KEX7Y.js +2 -0
  23. package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +7 -0
  24. package/dist/browser/chunks/mathjax-DNP3YRES.js +61 -0
  25. package/dist/browser/chunks/mathjax-DNP3YRES.js.map +7 -0
  26. package/dist/browser/index.js +2 -0
  27. package/dist/browser/index.js.map +7 -0
  28. package/dist/browser/kit.js +2 -0
  29. package/dist/browser/kit.js.map +7 -0
  30. package/dist/browser/manifest.json +30 -0
  31. package/dist/browser/tex.js +2 -0
  32. package/dist/browser/tex.js.map +7 -0
  33. package/dist/engine.d.ts +64 -0
  34. package/dist/engine.d.ts.map +1 -0
  35. package/dist/engine.js +42 -0
  36. package/dist/engine.js.map +1 -0
  37. package/dist/index.d.ts +30 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +30 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/kit/brace.d.ts +8 -0
  42. package/dist/kit/brace.d.ts.map +1 -0
  43. package/dist/kit/brace.js +36 -0
  44. package/dist/kit/brace.js.map +1 -0
  45. package/dist/kit/cache.d.ts +30 -0
  46. package/dist/kit/cache.d.ts.map +1 -0
  47. package/dist/kit/cache.js +53 -0
  48. package/dist/kit/cache.js.map +1 -0
  49. package/dist/kit/contour.d.ts +8 -0
  50. package/dist/kit/contour.d.ts.map +1 -0
  51. package/dist/kit/contour.js +93 -0
  52. package/dist/kit/contour.js.map +1 -0
  53. package/dist/kit/coords.d.ts +69 -0
  54. package/dist/kit/coords.d.ts.map +1 -0
  55. package/dist/kit/coords.js +224 -0
  56. package/dist/kit/coords.js.map +1 -0
  57. package/dist/kit/curve.d.ts +17 -0
  58. package/dist/kit/curve.d.ts.map +1 -0
  59. package/dist/kit/curve.js +22 -0
  60. package/dist/kit/curve.js.map +1 -0
  61. package/dist/kit/equation.d.ts +61 -0
  62. package/dist/kit/equation.d.ts.map +1 -0
  63. package/dist/kit/equation.js +168 -0
  64. package/dist/kit/equation.js.map +1 -0
  65. package/dist/kit/equation3d.d.ts +50 -0
  66. package/dist/kit/equation3d.d.ts.map +1 -0
  67. package/dist/kit/equation3d.js +103 -0
  68. package/dist/kit/equation3d.js.map +1 -0
  69. package/dist/kit/expression.d.ts +35 -0
  70. package/dist/kit/expression.d.ts.map +1 -0
  71. package/dist/kit/expression.js +124 -0
  72. package/dist/kit/expression.js.map +1 -0
  73. package/dist/kit/field-mark.d.ts +58 -0
  74. package/dist/kit/field-mark.d.ts.map +1 -0
  75. package/dist/kit/field-mark.js +129 -0
  76. package/dist/kit/field-mark.js.map +1 -0
  77. package/dist/kit/field.d.ts +14 -0
  78. package/dist/kit/field.d.ts.map +1 -0
  79. package/dist/kit/field.js +46 -0
  80. package/dist/kit/field.js.map +1 -0
  81. package/dist/kit/follow.d.ts +71 -0
  82. package/dist/kit/follow.d.ts.map +1 -0
  83. package/dist/kit/follow.js +159 -0
  84. package/dist/kit/follow.js.map +1 -0
  85. package/dist/kit/furniture.d.ts +30 -0
  86. package/dist/kit/furniture.d.ts.map +1 -0
  87. package/dist/kit/furniture.js +87 -0
  88. package/dist/kit/furniture.js.map +1 -0
  89. package/dist/kit/geometry.d.ts +13 -0
  90. package/dist/kit/geometry.d.ts.map +1 -0
  91. package/dist/kit/geometry.js +54 -0
  92. package/dist/kit/geometry.js.map +1 -0
  93. package/dist/kit/mark.d.ts +47 -0
  94. package/dist/kit/mark.d.ts.map +1 -0
  95. package/dist/kit/mark.js +103 -0
  96. package/dist/kit/mark.js.map +1 -0
  97. package/dist/kit/part-fills.d.ts +23 -0
  98. package/dist/kit/part-fills.d.ts.map +1 -0
  99. package/dist/kit/part-fills.js +46 -0
  100. package/dist/kit/part-fills.js.map +1 -0
  101. package/dist/kit/place.d.ts +18 -0
  102. package/dist/kit/place.d.ts.map +1 -0
  103. package/dist/kit/place.js +68 -0
  104. package/dist/kit/place.js.map +1 -0
  105. package/dist/kit/placement.d.ts +8 -0
  106. package/dist/kit/placement.d.ts.map +1 -0
  107. package/dist/kit/placement.js +8 -0
  108. package/dist/kit/placement.js.map +1 -0
  109. package/dist/kit/sampler.d.ts +17 -0
  110. package/dist/kit/sampler.d.ts.map +1 -0
  111. package/dist/kit/sampler.js +250 -0
  112. package/dist/kit/sampler.js.map +1 -0
  113. package/dist/kit/scale.d.ts +12 -0
  114. package/dist/kit/scale.d.ts.map +1 -0
  115. package/dist/kit/scale.js +37 -0
  116. package/dist/kit/scale.js.map +1 -0
  117. package/dist/kit/source.d.ts +22 -0
  118. package/dist/kit/source.d.ts.map +1 -0
  119. package/dist/kit/source.js +45 -0
  120. package/dist/kit/source.js.map +1 -0
  121. package/dist/kit/system.d.ts +33 -0
  122. package/dist/kit/system.d.ts.map +1 -0
  123. package/dist/kit/system.js +67 -0
  124. package/dist/kit/system.js.map +1 -0
  125. package/dist/kit/ticks.d.ts +19 -0
  126. package/dist/kit/ticks.d.ts.map +1 -0
  127. package/dist/kit/ticks.js +78 -0
  128. package/dist/kit/ticks.js.map +1 -0
  129. package/dist/kit/withdrawn.d.ts +9 -0
  130. package/dist/kit/withdrawn.d.ts.map +1 -0
  131. package/dist/kit/withdrawn.js +9 -0
  132. package/dist/kit/withdrawn.js.map +1 -0
  133. package/dist/marks/curve-area.d.ts +32 -0
  134. package/dist/marks/curve-area.d.ts.map +1 -0
  135. package/dist/marks/curve-area.js +82 -0
  136. package/dist/marks/curve-area.js.map +1 -0
  137. package/dist/marks/drop-lines.d.ts +22 -0
  138. package/dist/marks/drop-lines.d.ts.map +1 -0
  139. package/dist/marks/drop-lines.js +58 -0
  140. package/dist/marks/drop-lines.js.map +1 -0
  141. package/dist/marks/plot-point.d.ts +35 -0
  142. package/dist/marks/plot-point.d.ts.map +1 -0
  143. package/dist/marks/plot-point.js +97 -0
  144. package/dist/marks/plot-point.js.map +1 -0
  145. package/dist/marks/riemann-sum.d.ts +37 -0
  146. package/dist/marks/riemann-sum.d.ts.map +1 -0
  147. package/dist/marks/riemann-sum.js +91 -0
  148. package/dist/marks/riemann-sum.js.map +1 -0
  149. package/dist/marks/tangent-line.d.ts +27 -0
  150. package/dist/marks/tangent-line.d.ts.map +1 -0
  151. package/dist/marks/tangent-line.js +103 -0
  152. package/dist/marks/tangent-line.js.map +1 -0
  153. package/dist/marks/vector-arrow.d.ts +32 -0
  154. package/dist/marks/vector-arrow.d.ts.map +1 -0
  155. package/dist/marks/vector-arrow.js +87 -0
  156. package/dist/marks/vector-arrow.js.map +1 -0
  157. package/dist/nodes.d.ts +35 -0
  158. package/dist/nodes.d.ts.map +1 -0
  159. package/dist/nodes.js +63 -0
  160. package/dist/nodes.js.map +1 -0
  161. package/dist/plots/function-plot.d.ts +67 -0
  162. package/dist/plots/function-plot.d.ts.map +1 -0
  163. package/dist/plots/function-plot.js +215 -0
  164. package/dist/plots/function-plot.js.map +1 -0
  165. package/dist/plots/points-plot.d.ts +28 -0
  166. package/dist/plots/points-plot.d.ts.map +1 -0
  167. package/dist/plots/points-plot.js +99 -0
  168. package/dist/plots/points-plot.js.map +1 -0
  169. package/dist/plots/stream-lines.d.ts +35 -0
  170. package/dist/plots/stream-lines.d.ts.map +1 -0
  171. package/dist/plots/stream-lines.js +141 -0
  172. package/dist/plots/stream-lines.js.map +1 -0
  173. package/dist/plots/traced-path.d.ts +31 -0
  174. package/dist/plots/traced-path.d.ts.map +1 -0
  175. package/dist/plots/traced-path.js +56 -0
  176. package/dist/plots/traced-path.js.map +1 -0
  177. package/dist/plots/vector-field.d.ts +23 -0
  178. package/dist/plots/vector-field.d.ts.map +1 -0
  179. package/dist/plots/vector-field.js +91 -0
  180. package/dist/plots/vector-field.js.map +1 -0
  181. package/dist/structures/graph-layout.d.ts +11 -0
  182. package/dist/structures/graph-layout.d.ts.map +1 -0
  183. package/dist/structures/graph-layout.js +135 -0
  184. package/dist/structures/graph-layout.js.map +1 -0
  185. package/dist/structures/network-graph.d.ts +83 -0
  186. package/dist/structures/network-graph.d.ts.map +1 -0
  187. package/dist/structures/network-graph.js +289 -0
  188. package/dist/structures/network-graph.js.map +1 -0
  189. package/dist/structures/sample-space.d.ts +62 -0
  190. package/dist/structures/sample-space.d.ts.map +1 -0
  191. package/dist/structures/sample-space.js +199 -0
  192. package/dist/structures/sample-space.js.map +1 -0
  193. package/dist/systems/axes2d.d.ts +75 -0
  194. package/dist/systems/axes2d.d.ts.map +1 -0
  195. package/dist/systems/axes2d.js +193 -0
  196. package/dist/systems/axes2d.js.map +1 -0
  197. package/dist/systems/number-line.d.ts +49 -0
  198. package/dist/systems/number-line.d.ts.map +1 -0
  199. package/dist/systems/number-line.js +127 -0
  200. package/dist/systems/number-line.js.map +1 -0
  201. package/dist/systems/number-plane.d.ts +59 -0
  202. package/dist/systems/number-plane.d.ts.map +1 -0
  203. package/dist/systems/number-plane.js +193 -0
  204. package/dist/systems/number-plane.js.map +1 -0
  205. package/dist/systems/polar-plane.d.ts +48 -0
  206. package/dist/systems/polar-plane.d.ts.map +1 -0
  207. package/dist/systems/polar-plane.js +165 -0
  208. package/dist/systems/polar-plane.js.map +1 -0
  209. package/dist/tex/geometry.d.ts +85 -0
  210. package/dist/tex/geometry.d.ts.map +1 -0
  211. package/dist/tex/geometry.js +632 -0
  212. package/dist/tex/geometry.js.map +1 -0
  213. package/dist/tex/index.d.ts +11 -0
  214. package/dist/tex/index.d.ts.map +1 -0
  215. package/dist/tex/index.js +9 -0
  216. package/dist/tex/index.js.map +1 -0
  217. package/dist/tex/mathjax.d.ts +33 -0
  218. package/dist/tex/mathjax.d.ts.map +1 -0
  219. package/dist/tex/mathjax.js +74 -0
  220. package/dist/tex/mathjax.js.map +1 -0
  221. package/dist/tex/matrix.d.ts +31 -0
  222. package/dist/tex/matrix.d.ts.map +1 -0
  223. package/dist/tex/matrix.js +73 -0
  224. package/dist/tex/matrix.js.map +1 -0
  225. package/dist/tex/node.d.ts +215 -0
  226. package/dist/tex/node.d.ts.map +1 -0
  227. package/dist/tex/node.js +595 -0
  228. package/dist/tex/node.js.map +1 -0
  229. package/dist/tex/tween.d.ts +50 -0
  230. package/dist/tex/tween.d.ts.map +1 -0
  231. package/dist/tex/tween.js +253 -0
  232. package/dist/tex/tween.js.map +1 -0
  233. package/dist/three/axes3d.d.ts +87 -0
  234. package/dist/three/axes3d.d.ts.map +1 -0
  235. package/dist/three/axes3d.js +228 -0
  236. package/dist/three/axes3d.js.map +1 -0
  237. package/dist/three/curve-plot3d.d.ts +60 -0
  238. package/dist/three/curve-plot3d.d.ts.map +1 -0
  239. package/dist/three/curve-plot3d.js +143 -0
  240. package/dist/three/curve-plot3d.js.map +1 -0
  241. package/dist/three/label3d.d.ts +11 -0
  242. package/dist/three/label3d.d.ts.map +1 -0
  243. package/dist/three/label3d.js +40 -0
  244. package/dist/three/label3d.js.map +1 -0
  245. package/dist/three/plot-point3d.d.ts +26 -0
  246. package/dist/three/plot-point3d.d.ts.map +1 -0
  247. package/dist/three/plot-point3d.js +60 -0
  248. package/dist/three/plot-point3d.js.map +1 -0
  249. package/dist/three/space.d.ts +28 -0
  250. package/dist/three/space.d.ts.map +1 -0
  251. package/dist/three/space.js +47 -0
  252. package/dist/three/space.js.map +1 -0
  253. package/dist/three/surface-plot3d.d.ts +80 -0
  254. package/dist/three/surface-plot3d.d.ts.map +1 -0
  255. package/dist/three/surface-plot3d.js +290 -0
  256. package/dist/three/surface-plot3d.js.map +1 -0
  257. package/dist/three/vector-arrow3d.d.ts +25 -0
  258. package/dist/three/vector-arrow3d.d.ts.map +1 -0
  259. package/dist/three/vector-arrow3d.js +72 -0
  260. package/dist/three/vector-arrow3d.js.map +1 -0
  261. package/package.json +79 -3
  262. package/registry.json +251 -0
  263. package/src/annotate/angle-mark.ts +147 -0
  264. package/src/annotate/curly-brace.ts +126 -0
  265. package/src/annotate/emphasis-mark.ts +89 -0
  266. package/src/engine.ts +72 -0
  267. package/src/index.ts +29 -0
  268. package/src/kit/brace.ts +37 -0
  269. package/src/kit/cache.ts +61 -0
  270. package/src/kit/contour.ts +94 -0
  271. package/src/kit/coords.ts +278 -0
  272. package/src/kit/curve.ts +29 -0
  273. package/src/kit/equation.ts +181 -0
  274. package/src/kit/equation3d.ts +137 -0
  275. package/src/kit/expression.ts +159 -0
  276. package/src/kit/field-mark.ts +155 -0
  277. package/src/kit/field.ts +50 -0
  278. package/src/kit/follow.ts +203 -0
  279. package/src/kit/furniture.ts +108 -0
  280. package/src/kit/geometry.ts +49 -0
  281. package/src/kit/mark.ts +131 -0
  282. package/src/kit/part-fills.ts +61 -0
  283. package/src/kit/place.ts +101 -0
  284. package/src/kit/placement.ts +8 -0
  285. package/src/kit/sampler.ts +281 -0
  286. package/src/kit/scale.ts +39 -0
  287. package/src/kit/source.ts +57 -0
  288. package/src/kit/system.ts +99 -0
  289. package/src/kit/ticks.ts +85 -0
  290. package/src/kit/withdrawn.ts +8 -0
  291. package/src/marks/curve-area.ts +89 -0
  292. package/src/marks/drop-lines.ts +63 -0
  293. package/src/marks/plot-point.ts +107 -0
  294. package/src/marks/riemann-sum.ts +98 -0
  295. package/src/marks/tangent-line.ts +103 -0
  296. package/src/marks/vector-arrow.ts +98 -0
  297. package/src/nodes.ts +63 -0
  298. package/src/plots/function-plot.ts +236 -0
  299. package/src/plots/points-plot.ts +107 -0
  300. package/src/plots/stream-lines.ts +151 -0
  301. package/src/plots/traced-path.ts +52 -0
  302. package/src/plots/vector-field.ts +88 -0
  303. package/src/structures/graph-layout.ts +145 -0
  304. package/src/structures/network-graph.ts +308 -0
  305. package/src/structures/sample-space.ts +209 -0
  306. package/src/systems/axes2d.ts +217 -0
  307. package/src/systems/number-line.ts +131 -0
  308. package/src/systems/number-plane.ts +203 -0
  309. package/src/systems/polar-plane.ts +176 -0
  310. package/src/tex/geometry.ts +703 -0
  311. package/src/tex/index.ts +14 -0
  312. package/src/tex/mathjax.ts +82 -0
  313. package/src/tex/matrix.ts +75 -0
  314. package/src/tex/node.ts +641 -0
  315. package/src/tex/tween.ts +308 -0
  316. package/src/three/axes3d.ts +240 -0
  317. package/src/three/curve-plot3d.ts +147 -0
  318. package/src/three/label3d.ts +50 -0
  319. package/src/three/plot-point3d.ts +66 -0
  320. package/src/three/space.ts +67 -0
  321. package/src/three/surface-plot3d.ts +323 -0
  322. package/src/three/vector-arrow3d.ts +77 -0
@@ -0,0 +1,91 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { command, fillProperty, node, property, strokeProperty, withdraw, } from "@motionscript/sdk";
8
+ import { clamp, stated } from "../kit/geometry.js";
9
+ import { Mark } from "../kit/mark.js";
10
+ import { curveOf } from "../kit/curve.js";
11
+ import { lerpInterval, PLOT_COLOR, readInterval } from "../kit/furniture.js";
12
+ import { SYSTEMS } from "../kit/placement.js";
13
+ import { OUTLINE_TRIM } from "../kit/withdrawn.js";
14
+ /** More rectangles than this is a filled area with extra steps. */
15
+ const MAX_RECTANGLES = 2000;
16
+ /** Rectangles under a plot, each `dx` wide and as tall as the curve where it is sampled. */
17
+ let RiemannSum = class RiemannSum extends Mark {
18
+ constructor(props) {
19
+ super(props ?? {});
20
+ }
21
+ /** Animate the rectangles' width: narrower is the sum closing in on the area. */
22
+ refineTo(args) {
23
+ return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
24
+ }
25
+ /** Animate the span of x the rectangles cover. */
26
+ domainTo(args) {
27
+ return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
28
+ }
29
+ isClosed() {
30
+ return true;
31
+ }
32
+ trace(map) {
33
+ const plot = curveOf(this, this.on);
34
+ const [a, b] = this.domain;
35
+ const dx = this.dx;
36
+ if (!plot || !(b > a) || !(dx > 0))
37
+ return [];
38
+ const [yMin, yMax] = map.yRange;
39
+ const base = clamp(0, yMin, yMax);
40
+ const at = this.sample === "left" ? 0 : this.sample === "right" ? 1 : 0.5;
41
+ const count = Math.min(MAX_RECTANGLES, Math.ceil((b - a) / dx - 1e-9));
42
+ const runs = [];
43
+ for (let i = 0; i < count; i++) {
44
+ const left = a + i * dx;
45
+ const right = Math.min(b, left + dx);
46
+ const value = plot.valueAt(left + (right - left) * at);
47
+ if (!Number.isFinite(value))
48
+ continue;
49
+ const height = clamp(value, yMin, yMax);
50
+ runs.push([map.toPoint(left, base), map.toPoint(left, height), map.toPoint(right, height), map.toPoint(right, base)]);
51
+ }
52
+ return runs;
53
+ }
54
+ };
55
+ __decorate([
56
+ property({ default: "", kind: "nodeRef", nodeTypes: ["functionPlot"], animatable: false })
57
+ ], RiemannSum.prototype, "on", void 0);
58
+ __decorate([
59
+ property({ default: [0, 1], mapper: readInterval, tween: lerpInterval })
60
+ ], RiemannSum.prototype, "domain", void 0);
61
+ __decorate([
62
+ property({ default: 0.25, min: 0.001 })
63
+ ], RiemannSum.prototype, "dx", void 0);
64
+ __decorate([
65
+ property({ default: "left", options: ["left", "right", "center"], animatable: false })
66
+ ], RiemannSum.prototype, "sample", void 0);
67
+ __decorate([
68
+ fillProperty({ default: { type: "solid", color: PLOT_COLOR, opacity: 0.35 } })
69
+ ], RiemannSum.prototype, "fill", void 0);
70
+ __decorate([
71
+ strokeProperty({ default: { weight: 1.5, fill: PLOT_COLOR, align: "center", join: "round" } })
72
+ ], RiemannSum.prototype, "stroke", void 0);
73
+ __decorate([
74
+ command({ args: ["dx"] })
75
+ ], RiemannSum.prototype, "refineTo", null);
76
+ __decorate([
77
+ command({ args: ["domain"] })
78
+ ], RiemannSum.prototype, "domainTo", null);
79
+ RiemannSum = __decorate([
80
+ node({
81
+ key: "riemannSum",
82
+ within: SYSTEMS,
83
+ beside: ["functionPlot"],
84
+ parentKey: "shape",
85
+ forkable: true,
86
+ layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: false },
87
+ }),
88
+ withdraw(...OUTLINE_TRIM)
89
+ ], RiemannSum);
90
+ export { RiemannSum };
91
+ //# sourceMappingURL=riemann-sum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"riemann-sum.js","sourceRoot":"","sources":["../../src/marks/riemann-sum.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,QAAQ,GAQX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM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E,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;0CAG7B;AA1BQ,UAAU;IATtB,IAAI,CAAC;QACF,GAAG,EAAE,YAAY;QACjB,MAAM,EAAE,OAAO;QACf,MAAM,EAAE,CAAC,cAAc,CAAC;QACxB,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE;KAC9G,CAAC;IACD,QAAQ,CAAC,GAAG,YAAY,CAAC;GACb,UAAU,CAoDtB","sourcesContent":["import {\r\n command,\r\n fillProperty,\r\n node,\r\n property,\r\n strokeProperty,\r\n withdraw,\r\n type Command,\r\n type CommandArgs,\r\n type Fill,\r\n type NodeConfig,\r\n type PaintProps,\r\n type Stroke,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport type { CoordinateMap, Interval } from \"../kit/coords\";\r\nimport { clamp, stated } from \"../kit/geometry\";\r\nimport { Mark } from \"../kit/mark\";\r\nimport { curveOf } from \"../kit/curve\";\r\nimport { lerpInterval, PLOT_COLOR, readInterval } from \"../kit/furniture\";\r\nimport { SYSTEMS } from \"../kit/placement\";\r\nimport { OUTLINE_TRIM } from \"../kit/withdrawn\";\r\n\r\nexport type RiemannSample = \"left\" | \"right\" | \"center\";\r\n\r\nexport interface RiemannSumProps extends PaintProps {\r\n on?: string;\r\n domain?: Interval;\r\n dx?: number;\r\n sample?: RiemannSample;\r\n}\r\n\r\n/** More rectangles than this is a filled area with extra steps. */\r\nconst MAX_RECTANGLES = 2000;\r\n\r\n/** Rectangles under a plot, each `dx` wide and as tall as the curve where it is sampled. */\r\n@node({\r\n key: \"riemannSum\",\r\n within: SYSTEMS,\r\n beside: [\"functionPlot\"],\r\n parentKey: \"shape\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"hug\", defaultHeightMode: \"hug\", acceptsChildren: false },\r\n})\r\n@withdraw(...OUTLINE_TRIM)\r\nexport class RiemannSum extends Mark<RiemannSumProps> {\r\n @property({ default: \"\", kind: \"nodeRef\", nodeTypes: [\"functionPlot\"], animatable: false }) declare on: string;\r\n @property({ default: [0, 1], mapper: readInterval, tween: lerpInterval })\r\n declare domain: Interval;\r\n /** Each rectangle's width, in graph units. */\r\n @property({ default: 0.25, min: 0.001 }) declare dx: number;\r\n /** Where in its width a rectangle reads the curve's height. */\r\n @property({ default: \"left\", options: [\"left\", \"right\", \"center\"], animatable: false }) declare sample: RiemannSample;\r\n\r\n @fillProperty({ default: { type: \"solid\", color: PLOT_COLOR, opacity: 0.35 } }) declare fill: Fill;\r\n @strokeProperty({ default: { weight: 1.5, fill: PLOT_COLOR, align: \"center\", join: \"round\" } }) declare stroke: Stroke;\r\n\r\n constructor(props?: NodeConfig<RiemannSum, RiemannSumProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n /** Animate the rectangles' width: narrower is the sum closing in on the area. */\r\n @command({ args: [\"dx\"] })\r\n refineTo(args: CommandArgs<{ dx: number }> & { duration: number }): Command<RiemannSumProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n /** Animate the span of x the rectangles cover. */\r\n @command({ args: [\"domain\"] })\r\n domainTo(args: CommandArgs<{ domain: Interval }> & { duration: number }): Command<RiemannSumProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n protected override isClosed(): boolean {\r\n return true;\r\n }\r\n\r\n protected trace(map: CoordinateMap): Vector2[][] {\r\n const plot = curveOf(this, this.on);\r\n const [a, b] = this.domain;\r\n const dx = this.dx;\r\n if (!plot || !(b > a) || !(dx > 0)) return [];\r\n const [yMin, yMax] = map.yRange;\r\n const base = clamp(0, yMin, yMax);\r\n const at = this.sample === \"left\" ? 0 : this.sample === \"right\" ? 1 : 0.5;\r\n const count = Math.min(MAX_RECTANGLES, Math.ceil((b - a) / dx - 1e-9));\r\n const runs: Vector2[][] = [];\r\n for (let i = 0; i < count; i++) {\r\n const left = a + i * dx;\r\n const right = Math.min(b, left + dx);\r\n const value = plot.valueAt(left + (right - left) * at);\r\n if (!Number.isFinite(value)) continue;\r\n const height = clamp(value, yMin, yMax);\r\n runs.push([map.toPoint(left, base), map.toPoint(left, height), map.toPoint(right, height), map.toPoint(right, base)]);\r\n }\r\n return runs;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,27 @@
1
+ import { type NodeConfig, type PaintProps, type Stroke, type Vector2 } from "@motionscript/sdk";
2
+ import type { CoordinateMap } from "../kit/coords.js";
3
+ import { Mark } from "../kit/mark.js";
4
+ export interface TangentLineProps extends PaintProps {
5
+ on?: string;
6
+ length?: number;
7
+ dx?: number;
8
+ legs?: boolean;
9
+ }
10
+ /**
11
+ * The tangent to a plot at this node's `x`, a fixed length on screen. With a
12
+ * `dx` it is the secant through `x` and `x + dx` instead, and `legs` draws that
13
+ * secant's run and rise.
14
+ */
15
+ export declare class TangentLine extends Mark<TangentLineProps> {
16
+ on: string;
17
+ length: number;
18
+ /** The second point's distance along x; zero is the tangent itself. */
19
+ dx: number;
20
+ legs: boolean;
21
+ stroke: Stroke;
22
+ constructor(props?: NodeConfig<TangentLine, TangentLineProps>);
23
+ /** The slope drawn, in graph units: the curve's at `x`, or the secant's when there is a `dx`. */
24
+ get slope(): number;
25
+ protected trace(map: CoordinateMap): Vector2[][];
26
+ }
27
+ //# sourceMappingURL=tangent-line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tangent-line.d.ts","sourceRoot":"","sources":["../../src/marks/tangent-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,OAAO,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAInC,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAChD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAKD;;;;GAIG;AACH,qBAQa,WAAY,SAAQ,IAAI,CAAC,gBAAgB,CAAC;IACiD,EAAE,EAAE,MAAM,CAAC;IACvD,MAAM,EAAE,MAAM,CAAC;IACvE,uEAAuE;IAC7B,EAAE,EAAE,MAAM,CAAC;IACI,IAAI,EAAE,OAAO,CAAC;IAG/D,MAAM,EAAE,MAAM,CAAC;gBAEX,KAAK,CAAC,EAAE,UAAU,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAI7D,iGAAiG;IACjG,IAAI,KAAK,IAAI,MAAM,CAKlB;IAED,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,EAAE,EAAE;CAsCnD"}
@@ -0,0 +1,103 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { node, property, strokeProperty, withdraw, } from "@motionscript/sdk";
8
+ import { Mark } from "../kit/mark.js";
9
+ import { curveOf } from "../kit/curve.js";
10
+ import { FILL_PAINT } from "../kit/withdrawn.js";
11
+ /** The step a slope is measured over, as a share of the system's width. */
12
+ const SLOPE_STEP = 1e-4;
13
+ /**
14
+ * The tangent to a plot at this node's `x`, a fixed length on screen. With a
15
+ * `dx` it is the secant through `x` and `x + dx` instead, and `legs` draws that
16
+ * secant's run and rise.
17
+ */
18
+ let TangentLine = class TangentLine extends Mark {
19
+ constructor(props) {
20
+ super(props ?? {});
21
+ }
22
+ /** The slope drawn, in graph units: the curve's at `x`, or the secant's when there is a `dx`. */
23
+ get slope() {
24
+ const plot = curveOf(this, this.on);
25
+ if (!plot)
26
+ return NaN;
27
+ if (this.dx > 0)
28
+ return (plot.valueAt(this.x + this.dx) - plot.valueAt(this.x)) / this.dx;
29
+ return slopeAt(plot, this.x, 1e-6 * Math.max(1, Math.abs(this.x)));
30
+ }
31
+ trace(map) {
32
+ const plot = curveOf(this, this.on);
33
+ if (!plot)
34
+ return [];
35
+ const x = this.x;
36
+ const y = plot.valueAt(x);
37
+ if (!Number.isFinite(y))
38
+ return [];
39
+ const half = this.length / 2;
40
+ if (this.dx > 0) {
41
+ const y2 = plot.valueAt(x + this.dx);
42
+ if (!Number.isFinite(y2))
43
+ return [];
44
+ const a = map.toPoint(x, y);
45
+ const b = map.toPoint(x + this.dx, y2);
46
+ const span = Math.hypot(b.x - a.x, b.y - a.y);
47
+ if (span === 0)
48
+ return [];
49
+ const reach = Math.max(half, span / 2 + 16);
50
+ const ux = (b.x - a.x) / span;
51
+ const uy = (b.y - a.y) / span;
52
+ const mx = (a.x + b.x) / 2;
53
+ const my = (a.y + b.y) / 2;
54
+ const secant = [{ x: mx - ux * reach, y: my - uy * reach }, { x: mx + ux * reach, y: my + uy * reach }];
55
+ return this.legs ? [secant, [a, map.toPoint(x + this.dx, y), b]] : [secant];
56
+ }
57
+ const [xMin, xMax] = map.xRange;
58
+ const h = Number.isFinite(xMax - xMin) ? (xMax - xMin) * SLOPE_STEP : 1e-4;
59
+ const before = plot.valueAt(x - h);
60
+ const after = plot.valueAt(x + h);
61
+ if (!Number.isFinite(before) || !Number.isFinite(after))
62
+ return [];
63
+ const p = map.toPoint(x, y);
64
+ const a = map.toPoint(x - h, before);
65
+ const b = map.toPoint(x + h, after);
66
+ const span = Math.hypot(b.x - a.x, b.y - a.y);
67
+ if (span === 0)
68
+ return [];
69
+ const ux = (b.x - a.x) / span;
70
+ const uy = (b.y - a.y) / span;
71
+ return [[{ x: p.x - ux * half, y: p.y - uy * half }, { x: p.x + ux * half, y: p.y + uy * half }]];
72
+ }
73
+ };
74
+ __decorate([
75
+ property({ default: "", kind: "nodeRef", nodeTypes: ["functionPlot"], animatable: false })
76
+ ], TangentLine.prototype, "on", void 0);
77
+ __decorate([
78
+ property({ default: 260, min: 0, unit: "px" })
79
+ ], TangentLine.prototype, "length", void 0);
80
+ __decorate([
81
+ property({ default: 0, min: 0 })
82
+ ], TangentLine.prototype, "dx", void 0);
83
+ __decorate([
84
+ property({ default: false, animatable: false })
85
+ ], TangentLine.prototype, "legs", void 0);
86
+ __decorate([
87
+ strokeProperty({ default: { weight: 3, fill: "#f59e0b", align: "center", cap: "round", join: "round" } })
88
+ ], TangentLine.prototype, "stroke", void 0);
89
+ TangentLine = __decorate([
90
+ node({
91
+ key: "tangentLine",
92
+ within: ["functionPlot"],
93
+ parentKey: "shape",
94
+ forkable: true,
95
+ layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: false },
96
+ }),
97
+ withdraw(...FILL_PAINT)
98
+ ], TangentLine);
99
+ export { TangentLine };
100
+ function slopeAt(plot, x, h) {
101
+ return (plot.valueAt(x + h) - plot.valueAt(x - h)) / (2 * h);
102
+ }
103
+ //# sourceMappingURL=tangent-line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tangent-line.js","sourceRoot":"","sources":["../../src/marks/tangent-line.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,QAAQ,GAKX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,OAAO,EAAc,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,k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AE,CAAC;2CACnF;AARd,WAAW;IARvB,IAAI,CAAC;QACF,GAAG,EAAE,aAAa;QAClB,MAAM,EAAE,CAAC,cAAc,CAAC;QACxB,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE;KAC9G,CAAC;IACD,QAAQ,CAAC,GAAG,UAAU,CAAC;GACX,WAAW,CA4DvB;;AAED,SAAS,OAAO,CAAC,IAAW,EAAE,CAAS,EAAE,CAAS;IAC9C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import {\r\n node,\r\n property,\r\n strokeProperty,\r\n withdraw,\r\n type NodeConfig,\r\n type PaintProps,\r\n type Stroke,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport type { CoordinateMap } from \"../kit/coords\";\r\nimport { Mark } from \"../kit/mark\";\r\nimport { curveOf, type Curve } from \"../kit/curve\";\r\nimport { FILL_PAINT } from \"../kit/withdrawn\";\r\n\r\nexport interface TangentLineProps extends PaintProps {\r\n on?: string;\r\n length?: number;\r\n dx?: number;\r\n legs?: boolean;\r\n}\r\n\r\n/** The step a slope is measured over, as a share of the system's width. */\r\nconst SLOPE_STEP = 1e-4;\r\n\r\n/**\r\n * The tangent to a plot at this node's `x`, a fixed length on screen. With a\r\n * `dx` it is the secant through `x` and `x + dx` instead, and `legs` draws that\r\n * secant's run and rise.\r\n */\r\n@node({\r\n key: \"tangentLine\",\r\n within: [\"functionPlot\"],\r\n parentKey: \"shape\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"hug\", defaultHeightMode: \"hug\", acceptsChildren: false },\r\n})\r\n@withdraw(...FILL_PAINT)\r\nexport class TangentLine extends Mark<TangentLineProps> {\r\n @property({ default: \"\", kind: \"nodeRef\", nodeTypes: [\"functionPlot\"], animatable: false }) declare on: string;\r\n @property({ default: 260, min: 0, unit: \"px\" }) declare length: number;\r\n /** The second point's distance along x; zero is the tangent itself. */\r\n @property({ default: 0, min: 0 }) declare dx: number;\r\n @property({ default: false, animatable: false }) declare legs: boolean;\r\n\r\n @strokeProperty({ default: { weight: 3, fill: \"#f59e0b\", align: \"center\", cap: \"round\", join: \"round\" } })\r\n declare stroke: Stroke;\r\n\r\n constructor(props?: NodeConfig<TangentLine, TangentLineProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n /** The slope drawn, in graph units: the curve's at `x`, or the secant's when there is a `dx`. */\r\n get slope(): number {\r\n const plot = curveOf(this, this.on);\r\n if (!plot) return NaN;\r\n if (this.dx > 0) return (plot.valueAt(this.x + this.dx) - plot.valueAt(this.x)) / this.dx;\r\n return slopeAt(plot, this.x, 1e-6 * Math.max(1, Math.abs(this.x)));\r\n }\r\n\r\n protected trace(map: CoordinateMap): Vector2[][] {\r\n const plot = curveOf(this, this.on);\r\n if (!plot) return [];\r\n const x = this.x;\r\n const y = plot.valueAt(x);\r\n if (!Number.isFinite(y)) return [];\r\n const half = this.length / 2;\r\n\r\n if (this.dx > 0) {\r\n const y2 = plot.valueAt(x + this.dx);\r\n if (!Number.isFinite(y2)) return [];\r\n const a = map.toPoint(x, y);\r\n const b = map.toPoint(x + this.dx, y2);\r\n const span = Math.hypot(b.x - a.x, b.y - a.y);\r\n if (span === 0) return [];\r\n const reach = Math.max(half, span / 2 + 16);\r\n const ux = (b.x - a.x) / span;\r\n const uy = (b.y - a.y) / span;\r\n const mx = (a.x + b.x) / 2;\r\n const my = (a.y + b.y) / 2;\r\n const secant = [{ x: mx - ux * reach, y: my - uy * reach }, { x: mx + ux * reach, y: my + uy * reach }];\r\n return this.legs ? [secant, [a, map.toPoint(x + this.dx, y), b]] : [secant];\r\n }\r\n\r\n const [xMin, xMax] = map.xRange;\r\n const h = Number.isFinite(xMax - xMin) ? (xMax - xMin) * SLOPE_STEP : 1e-4;\r\n const before = plot.valueAt(x - h);\r\n const after = plot.valueAt(x + h);\r\n if (!Number.isFinite(before) || !Number.isFinite(after)) return [];\r\n const p = map.toPoint(x, y);\r\n const a = map.toPoint(x - h, before);\r\n const b = map.toPoint(x + h, after);\r\n const span = Math.hypot(b.x - a.x, b.y - a.y);\r\n if (span === 0) return [];\r\n const ux = (b.x - a.x) / span;\r\n const uy = (b.y - a.y) / span;\r\n return [[{ x: p.x - ux * half, y: p.y - uy * half }, { x: p.x + ux * half, y: p.y + uy * half }]];\r\n }\r\n}\r\n\r\nfunction slopeAt(plot: Curve, x: number, h: number): number {\r\n return (plot.valueAt(x + h) - plot.valueAt(x - h)) / (2 * h);\r\n}\r\n"]}
@@ -0,0 +1,32 @@
1
+ import { type Command, type CommandArgs, type NodeConfig, type NodeHandle, type PaintProps, type Stroke, type Vector2 } from "@motionscript/sdk";
2
+ import type { CoordinateMap } from "../kit/coords.js";
3
+ import { Mark } from "../kit/mark.js";
4
+ export interface VectorArrowProps extends PaintProps {
5
+ tail?: Vector2;
6
+ head?: Vector2;
7
+ bend?: number;
8
+ }
9
+ /**
10
+ * An arrow from `tail` to `head`, two graph points. Its arrowhead is the stroke's
11
+ * `endCap`, so a plain segment, a double arrow or a dashed one is a change of
12
+ * stroke. (`from` and `to` are not its names because every node has a `to`.)
13
+ */
14
+ export declare class VectorArrow extends Mark<VectorArrowProps> {
15
+ tail: Vector2;
16
+ head: Vector2;
17
+ /** The arc the arrow sweeps, in degrees: zero is straight, positive bows to its left. */
18
+ bend: number;
19
+ stroke: Stroke;
20
+ constructor(props?: NodeConfig<VectorArrow, VectorArrowProps>);
21
+ /** Move either end, in graph coordinates. */
22
+ endpointsTo(args: CommandArgs<{
23
+ tail?: Vector2;
24
+ head?: Vector2;
25
+ }> & {
26
+ duration: number;
27
+ }): Command<VectorArrowProps>;
28
+ protected trace(map: CoordinateMap): Vector2[][];
29
+ _handles(): readonly NodeHandle[];
30
+ _handleValue(prop: string, at: Vector2): Vector2 | null;
31
+ }
32
+ //# sourceMappingURL=vector-arrow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector-arrow.d.ts","sourceRoot":"","sources":["../../src/marks/vector-arrow.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,OAAO,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAInC,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAChD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD;;;;GAIG;AACH,qBAQa,WAAY,SAAQ,IAAI,CAAC,gBAAgB,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC;IACa,IAAI,EAAE,OAAO,CAAC;IACpE,yFAAyF;IACvB,IAAI,EAAE,MAAM,CAAC;IAGvE,MAAM,EAAE,MAAM,CAAC;gBAEX,KAAK,CAAC,EAAE,UAAU,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAI7D,6CAA6C;IAE7C,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIpH,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,EAAE,EAAE;IAyBvC,QAAQ,IAAI,SAAS,UAAU,EAAE;IAOjC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI;CAGnE"}
@@ -0,0 +1,87 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { command, node, property, strokeProperty, vector2Property, withdraw, } from "@motionscript/sdk";
8
+ import { stated } from "../kit/geometry.js";
9
+ import { Mark } from "../kit/mark.js";
10
+ import { SYSTEMS } from "../kit/placement.js";
11
+ import { FILL_PAINT } from "../kit/withdrawn.js";
12
+ /** Degrees of arc per drawn segment of a bent arrow. */
13
+ const BEND_STEP = 4;
14
+ /**
15
+ * An arrow from `tail` to `head`, two graph points. Its arrowhead is the stroke's
16
+ * `endCap`, so a plain segment, a double arrow or a dashed one is a change of
17
+ * stroke. (`from` and `to` are not its names because every node has a `to`.)
18
+ */
19
+ let VectorArrow = class VectorArrow extends Mark {
20
+ constructor(props) {
21
+ super(props ?? {});
22
+ }
23
+ /** Move either end, in graph coordinates. */
24
+ endpointsTo(args) {
25
+ return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
26
+ }
27
+ trace(map) {
28
+ const shift = this.shift();
29
+ const a = map.toPoint(this.tail.x + shift.x, this.tail.y + shift.y);
30
+ const b = map.toPoint(this.head.x + shift.x, this.head.y + shift.y);
31
+ const sweep = (this.bend * Math.PI) / 180;
32
+ const chord = Math.hypot(b.x - a.x, b.y - a.y);
33
+ if (Math.abs(sweep) < 1e-3 || chord === 0)
34
+ return [[a, b]];
35
+ // The circle through both ends that subtends `sweep` at its centre.
36
+ const radius = chord / (2 * Math.sin(Math.abs(sweep) / 2));
37
+ const side = Math.sign(sweep);
38
+ const reach = radius * Math.cos(sweep / 2);
39
+ // The centre sits to the arrow's right for a positive sweep, so the arc bows to its left.
40
+ const cx = (a.x + b.x) / 2 + (side * (b.y - a.y) * reach) / chord;
41
+ const cy = (a.y + b.y) / 2 - (side * (b.x - a.x) * reach) / chord;
42
+ const from = Math.atan2(a.y - cy, a.x - cx);
43
+ const steps = Math.max(8, Math.ceil(Math.abs(this.bend) / BEND_STEP));
44
+ const run = [];
45
+ for (let i = 0; i <= steps; i++) {
46
+ const angle = from - (sweep * i) / steps;
47
+ run.push({ x: cx + radius * Math.cos(angle), y: cy + radius * Math.sin(angle) });
48
+ }
49
+ return [run];
50
+ }
51
+ _handles() {
52
+ return [
53
+ { prop: "tail", at: this.ownPoint(this.tail) },
54
+ { prop: "head", at: this.ownPoint(this.head) },
55
+ ];
56
+ }
57
+ _handleValue(prop, at) {
58
+ return prop === "tail" || prop === "head" ? this.graphPoint(at) : null;
59
+ }
60
+ };
61
+ __decorate([
62
+ vector2Property()
63
+ ], VectorArrow.prototype, "tail", void 0);
64
+ __decorate([
65
+ vector2Property({ default: { x: 1, y: 1 } })
66
+ ], VectorArrow.prototype, "head", void 0);
67
+ __decorate([
68
+ property({ default: 0, min: -180, max: 180, unit: "°" })
69
+ ], VectorArrow.prototype, "bend", void 0);
70
+ __decorate([
71
+ strokeProperty({ default: { weight: 4, fill: "#e5e7eb", align: "center", endCap: "triangle" } })
72
+ ], VectorArrow.prototype, "stroke", void 0);
73
+ __decorate([
74
+ command({ args: ["tail", "head"] })
75
+ ], VectorArrow.prototype, "endpointsTo", null);
76
+ VectorArrow = __decorate([
77
+ node({
78
+ key: "vectorArrow",
79
+ within: SYSTEMS,
80
+ parentKey: "shape",
81
+ forkable: true,
82
+ layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: false },
83
+ }),
84
+ withdraw(...FILL_PAINT)
85
+ ], VectorArrow);
86
+ export { VectorArrow };
87
+ //# sourceMappingURL=vector-arrow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vector-arrow.js","sourceRoot":"","sources":["../../src/marks/vector-arrow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,eAAe,EACf,QAAQ,GAQX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQ9C,wDAAwD;AACxD,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB;;;;GAIG;AASI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAsB;IASnD,YAAY,KAAiD;QACzD,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACvB,CAAC;IAED,6CAA6C;IAE7C,WAAW,CAAC,IAA4E;QACpF,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9F,CAAC;IAES,KAAK,CAAC,GAAkB;QAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACpE,MA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E,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,CAAC;CACJ,CAAA;AArD8B;IAA1B,eAAe,EAAE;yCAAuB;AACa;IAArD,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;yCAAuB;AAEF;IAAjE,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;yCAAsB;AAGvE;IADP,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC;2CAC1E;AAQvB;IADC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;8CAGnC;AAjBQ,WAAW;IARvB,IAAI,CAAC;QACF,GAAG,EAAE,aAAa;QAClB,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE;KAC9G,CAAC;IACD,QAAQ,CAAC,GAAG,UAAU,CAAC;GACX,WAAW,CAsDvB","sourcesContent":["import {\r\n command,\r\n node,\r\n property,\r\n strokeProperty,\r\n vector2Property,\r\n withdraw,\r\n type Command,\r\n type CommandArgs,\r\n type NodeConfig,\r\n type NodeHandle,\r\n type PaintProps,\r\n type Stroke,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport type { CoordinateMap } from \"../kit/coords\";\r\nimport { stated } from \"../kit/geometry\";\r\nimport { Mark } from \"../kit/mark\";\r\nimport { SYSTEMS } from \"../kit/placement\";\r\nimport { FILL_PAINT } from \"../kit/withdrawn\";\r\n\r\nexport interface VectorArrowProps extends PaintProps {\r\n tail?: Vector2;\r\n head?: Vector2;\r\n bend?: number;\r\n}\r\n\r\n/** Degrees of arc per drawn segment of a bent arrow. */\r\nconst BEND_STEP = 4;\r\n\r\n/**\r\n * An arrow from `tail` to `head`, two graph points. Its arrowhead is the stroke's\r\n * `endCap`, so a plain segment, a double arrow or a dashed one is a change of\r\n * stroke. (`from` and `to` are not its names because every node has a `to`.)\r\n */\r\n@node({\r\n key: \"vectorArrow\",\r\n within: SYSTEMS,\r\n parentKey: \"shape\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"hug\", defaultHeightMode: \"hug\", acceptsChildren: false },\r\n})\r\n@withdraw(...FILL_PAINT)\r\nexport class VectorArrow extends Mark<VectorArrowProps> {\r\n @vector2Property() declare tail: Vector2;\r\n @vector2Property({ default: { x: 1, y: 1 } }) declare head: Vector2;\r\n /** The arc the arrow sweeps, in degrees: zero is straight, positive bows to its left. */\r\n @property({ default: 0, min: -180, max: 180, unit: \"°\" }) declare bend: number;\r\n\r\n @strokeProperty({ default: { weight: 4, fill: \"#e5e7eb\", align: \"center\", endCap: \"triangle\" } })\r\n declare stroke: Stroke;\r\n\r\n constructor(props?: NodeConfig<VectorArrow, VectorArrowProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n /** Move either end, in graph coordinates. */\r\n @command({ args: [\"tail\", \"head\"] })\r\n endpointsTo(args: CommandArgs<{ tail?: Vector2; head?: Vector2 }> & { duration: number }): Command<VectorArrowProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n protected trace(map: CoordinateMap): Vector2[][] {\r\n const shift = this.shift();\r\n const a = map.toPoint(this.tail.x + shift.x, this.tail.y + shift.y);\r\n const b = map.toPoint(this.head.x + shift.x, this.head.y + shift.y);\r\n const sweep = (this.bend * Math.PI) / 180;\r\n const chord = Math.hypot(b.x - a.x, b.y - a.y);\r\n if (Math.abs(sweep) < 1e-3 || chord === 0) return [[a, b]];\r\n\r\n // The circle through both ends that subtends `sweep` at its centre.\r\n const radius = chord / (2 * Math.sin(Math.abs(sweep) / 2));\r\n const side = Math.sign(sweep);\r\n const reach = radius * Math.cos(sweep / 2);\r\n // The centre sits to the arrow's right for a positive sweep, so the arc bows to its left.\r\n const cx = (a.x + b.x) / 2 + (side * (b.y - a.y) * reach) / chord;\r\n const cy = (a.y + b.y) / 2 - (side * (b.x - a.x) * reach) / chord;\r\n const from = Math.atan2(a.y - cy, a.x - cx);\r\n const steps = Math.max(8, Math.ceil(Math.abs(this.bend) / BEND_STEP));\r\n const run: Vector2[] = [];\r\n for (let i = 0; i <= steps; i++) {\r\n const angle = from - (sweep * i) / steps;\r\n run.push({ x: cx + radius * Math.cos(angle), y: cy + radius * Math.sin(angle) });\r\n }\r\n return [run];\r\n }\r\n\r\n override _handles(): readonly NodeHandle[] {\r\n return [\r\n { prop: \"tail\", at: this.ownPoint(this.tail) },\r\n { prop: \"head\", at: this.ownPoint(this.head) },\r\n ];\r\n }\r\n\r\n override _handleValue(prop: string, at: Vector2): Vector2 | null {\r\n return prop === \"tail\" || prop === \"head\" ? this.graphPoint(at) : null;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,35 @@
1
+ import { AngleMark } from "./annotate/angle-mark.js";
2
+ import { CurlyBrace } from "./annotate/curly-brace.js";
3
+ import { EmphasisMark } from "./annotate/emphasis-mark.js";
4
+ import { CurveArea } from "./marks/curve-area.js";
5
+ import { DropLines } from "./marks/drop-lines.js";
6
+ import { PlotPoint } from "./marks/plot-point.js";
7
+ import { RiemannSum } from "./marks/riemann-sum.js";
8
+ import { TangentLine } from "./marks/tangent-line.js";
9
+ import { VectorArrow } from "./marks/vector-arrow.js";
10
+ import { FunctionPlot } from "./plots/function-plot.js";
11
+ import { PointsPlot } from "./plots/points-plot.js";
12
+ import { StreamLines } from "./plots/stream-lines.js";
13
+ import { TracedPath } from "./plots/traced-path.js";
14
+ import { VectorField } from "./plots/vector-field.js";
15
+ import { Axes2d } from "./systems/axes2d.js";
16
+ import { NumberLine } from "./systems/number-line.js";
17
+ import { NumberPlane } from "./systems/number-plane.js";
18
+ import { PolarPlane } from "./systems/polar-plane.js";
19
+ import { NetworkGraph } from "./structures/network-graph.js";
20
+ import { SampleSpace } from "./structures/sample-space.js";
21
+ import { LatexMatrix } from "./tex/matrix.js";
22
+ import { Latex } from "./tex/node.js";
23
+ import { Axes3d } from "./three/axes3d.js";
24
+ import { CurvePlot3d } from "./three/curve-plot3d.js";
25
+ import { PlotPoint3d } from "./three/plot-point3d.js";
26
+ import { SurfacePlot3d } from "./three/surface-plot3d.js";
27
+ import { VectorArrow3d } from "./three/vector-arrow3d.js";
28
+ /**
29
+ * Every node type this package publishes. A host registers them by handing the
30
+ * array to an engine (`nodes: NODES`); `@node()` only declares each key. Class
31
+ * values rather than side-effect imports, because the package is
32
+ * `sideEffects: false` and a document names a type by string.
33
+ */
34
+ export declare const NODES: (typeof Latex | typeof Axes2d | typeof FunctionPlot | typeof LatexMatrix | typeof NumberLine | typeof NumberPlane | typeof PointsPlot | typeof PlotPoint | typeof VectorArrow | typeof CurveArea | typeof RiemannSum | typeof TangentLine | typeof DropLines | typeof CurlyBrace | typeof AngleMark | typeof EmphasisMark | typeof Axes3d | typeof SurfacePlot3d | typeof CurvePlot3d | typeof PlotPoint3d | typeof VectorArrow3d | typeof PolarPlane | typeof VectorField | typeof StreamLines | typeof TracedPath | typeof NetworkGraph | typeof SampleSpace)[];
35
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;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;AACH,eAAO,MAAM,KAAK,miBA4BjB,CAAC"}
package/dist/nodes.js ADDED
@@ -0,0 +1,63 @@
1
+ import { AngleMark } from "./annotate/angle-mark.js";
2
+ import { CurlyBrace } from "./annotate/curly-brace.js";
3
+ import { EmphasisMark } from "./annotate/emphasis-mark.js";
4
+ import { CurveArea } from "./marks/curve-area.js";
5
+ import { DropLines } from "./marks/drop-lines.js";
6
+ import { PlotPoint } from "./marks/plot-point.js";
7
+ import { RiemannSum } from "./marks/riemann-sum.js";
8
+ import { TangentLine } from "./marks/tangent-line.js";
9
+ import { VectorArrow } from "./marks/vector-arrow.js";
10
+ import { FunctionPlot } from "./plots/function-plot.js";
11
+ import { PointsPlot } from "./plots/points-plot.js";
12
+ import { StreamLines } from "./plots/stream-lines.js";
13
+ import { TracedPath } from "./plots/traced-path.js";
14
+ import { VectorField } from "./plots/vector-field.js";
15
+ import { Axes2d } from "./systems/axes2d.js";
16
+ import { NumberLine } from "./systems/number-line.js";
17
+ import { NumberPlane } from "./systems/number-plane.js";
18
+ import { PolarPlane } from "./systems/polar-plane.js";
19
+ import { NetworkGraph } from "./structures/network-graph.js";
20
+ import { SampleSpace } from "./structures/sample-space.js";
21
+ import { LatexMatrix } from "./tex/matrix.js";
22
+ import { Latex } from "./tex/node.js";
23
+ import { Axes3d } from "./three/axes3d.js";
24
+ import { CurvePlot3d } from "./three/curve-plot3d.js";
25
+ import { PlotPoint3d } from "./three/plot-point3d.js";
26
+ import { SurfacePlot3d } from "./three/surface-plot3d.js";
27
+ import { VectorArrow3d } from "./three/vector-arrow3d.js";
28
+ /**
29
+ * Every node type this package publishes. A host registers them by handing the
30
+ * array to an engine (`nodes: NODES`); `@node()` only declares each key. Class
31
+ * values rather than side-effect imports, because the package is
32
+ * `sideEffects: false` and a document names a type by string.
33
+ */
34
+ export const NODES = [
35
+ Latex,
36
+ LatexMatrix,
37
+ NumberLine,
38
+ Axes2d,
39
+ NumberPlane,
40
+ FunctionPlot,
41
+ PointsPlot,
42
+ PlotPoint,
43
+ VectorArrow,
44
+ CurveArea,
45
+ RiemannSum,
46
+ TangentLine,
47
+ DropLines,
48
+ CurlyBrace,
49
+ AngleMark,
50
+ EmphasisMark,
51
+ Axes3d,
52
+ SurfacePlot3d,
53
+ CurvePlot3d,
54
+ PlotPoint3d,
55
+ VectorArrow3d,
56
+ PolarPlane,
57
+ VectorField,
58
+ StreamLines,
59
+ TracedPath,
60
+ NetworkGraph,
61
+ SampleSpace,
62
+ ];
63
+ //# sourceMappingURL=nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,KAAK;IACL,WAAW;IACX,UAAU;IACV,MAAM;IACN,WAAW;IACX,YAAY;IACZ,UAAU;IACV,SAAS;IACT,WAAW;IACX,SAAS;IACT,UAAU;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,SAAS;IACT,YAAY;IACZ,MAAM;IACN,aAAa;IACb,WAAW;IACX,WAAW;IACX,aAAa;IACb,UAAU;IACV,WAAW;IACX,WAAW;IACX,UAAU;IACV,YAAY;IACZ,WAAW;CACd,CAAC","sourcesContent":["import { AngleMark } from \"./annotate/angle-mark\";\r\nimport { CurlyBrace } from \"./annotate/curly-brace\";\r\nimport { EmphasisMark } from \"./annotate/emphasis-mark\";\r\nimport { CurveArea } from \"./marks/curve-area\";\r\nimport { DropLines } from \"./marks/drop-lines\";\r\nimport { PlotPoint } from \"./marks/plot-point\";\r\nimport { RiemannSum } from \"./marks/riemann-sum\";\r\nimport { TangentLine } from \"./marks/tangent-line\";\r\nimport { VectorArrow } from \"./marks/vector-arrow\";\r\nimport { FunctionPlot } from \"./plots/function-plot\";\r\nimport { PointsPlot } from \"./plots/points-plot\";\r\nimport { StreamLines } from \"./plots/stream-lines\";\r\nimport { TracedPath } from \"./plots/traced-path\";\r\nimport { VectorField } from \"./plots/vector-field\";\r\nimport { Axes2d } from \"./systems/axes2d\";\r\nimport { NumberLine } from \"./systems/number-line\";\r\nimport { NumberPlane } from \"./systems/number-plane\";\r\nimport { PolarPlane } from \"./systems/polar-plane\";\r\nimport { NetworkGraph } from \"./structures/network-graph\";\r\nimport { SampleSpace } from \"./structures/sample-space\";\r\nimport { LatexMatrix } from \"./tex/matrix\";\r\nimport { Latex } from \"./tex/node\";\r\nimport { Axes3d } from \"./three/axes3d\";\r\nimport { CurvePlot3d } from \"./three/curve-plot3d\";\r\nimport { PlotPoint3d } from \"./three/plot-point3d\";\r\nimport { SurfacePlot3d } from \"./three/surface-plot3d\";\r\nimport { VectorArrow3d } from \"./three/vector-arrow3d\";\r\n\r\n/**\r\n * Every node type this package publishes. A host registers them by handing the\r\n * array to an engine (`nodes: NODES`); `@node()` only declares each key. Class\r\n * values rather than side-effect imports, because the package is\r\n * `sideEffects: false` and a document names a type by string.\r\n */\r\nexport const NODES = [\r\n Latex,\r\n LatexMatrix,\r\n NumberLine,\r\n Axes2d,\r\n NumberPlane,\r\n FunctionPlot,\r\n PointsPlot,\r\n PlotPoint,\r\n VectorArrow,\r\n CurveArea,\r\n RiemannSum,\r\n TangentLine,\r\n DropLines,\r\n CurlyBrace,\r\n AngleMark,\r\n EmphasisMark,\r\n Axes3d,\r\n SurfacePlot3d,\r\n CurvePlot3d,\r\n PlotPoint3d,\r\n VectorArrow3d,\r\n PolarPlane,\r\n VectorField,\r\n StreamLines,\r\n TracedPath,\r\n NetworkGraph,\r\n SampleSpace,\r\n];\r\n"]}
@@ -0,0 +1,67 @@
1
+ import { type Command, type CommandArgs, type NodeConfig, type PaintProps, type Stroke, type Vector2 } from "@motionscript/sdk";
2
+ import type { CoordinateMap, Interval } from "../kit/coords.js";
3
+ import type { Curve } from "../kit/curve.js";
4
+ import type { ExpressionScope } from "../kit/expression.js";
5
+ import { Mark } from "../kit/mark.js";
6
+ import { type PlotSource } from "../kit/source.js";
7
+ export interface FunctionPlotProps extends PaintProps {
8
+ expression?: string | PlotSource;
9
+ domain?: Interval | null;
10
+ params?: ExpressionScope;
11
+ }
12
+ /**
13
+ * The curve of an equation, drawn in the coordinate system it is a child of.
14
+ * How the equation is written says what it is: see `Equation`. A mark put
15
+ * inside it reads it: the area under it, a tangent, a point that rides it.
16
+ */
17
+ export declare class FunctionPlot<P extends FunctionPlotProps = FunctionPlotProps> extends Mark<P> implements Curve {
18
+ expression: PlotSource;
19
+ /**
20
+ * The span of the free variable that is drawn. Left out, a function runs the
21
+ * width of its system, a polar curve one turn and a parametric one from 0 to 1.
22
+ */
23
+ domain: Interval | null;
24
+ /**
25
+ * The equation's named values: any name in it that is not a variable, a
26
+ * function or a constant. One left unset is 1, and a formula can bind each
27
+ * to a variable.
28
+ */
29
+ params: ExpressionScope;
30
+ stroke: Stroke;
31
+ constructor(props?: NodeConfig<FunctionPlot<P>, P>);
32
+ /** Change the equation, the curve bending from the one into the other. */
33
+ morphTo(args: CommandArgs<{
34
+ expression: string;
35
+ }> & {
36
+ duration: number;
37
+ }): Command<P>;
38
+ /** Animate the equation's named values. */
39
+ paramsTo(args: CommandArgs<{
40
+ params: ExpressionScope;
41
+ }> & {
42
+ duration: number;
43
+ }): Command<P>;
44
+ /** Animate the span that is drawn. */
45
+ domainTo(args: CommandArgs<{
46
+ domain: Interval | null;
47
+ }> & {
48
+ duration: number;
49
+ }): Command<P>;
50
+ /**
51
+ * The curve's height at graph `x`, or `NaN` where it has none or is not a
52
+ * function of `x`. What a point, a tangent or an area riding this plot reads.
53
+ */
54
+ valueAt(x: number): number;
55
+ /** The span of the free variable that is drawn: `domain`, unless a node built on this one says otherwise. */
56
+ protected span(): Interval | null;
57
+ protected trace(map: CoordinateMap): Vector2[][];
58
+ private _key;
59
+ private _runs;
60
+ private _equation;
61
+ private _heightOf;
62
+ /** Where an implicit `source` holds, over what the system shows, as pixel runs. */
63
+ private _contour;
64
+ /** `source` as a pixel curve over a parameter running 0 to 1. */
65
+ private _curve;
66
+ }
67
+ //# sourceMappingURL=function-plot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-plot.d.ts","sourceRoot":"","sources":["../../src/plots/function-plot.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,OAAO,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAA4D,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAI1G,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACjD,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACjC,MAAM,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC5B;AAID;;;;GAIG;AACH,qBAUa,YAAY,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,CAAE,SAAQ,IAAI,CAAC,CAAC,CAAE,YAAW,KAAK;IAE/F,UAAU,EAAE,UAAU,CAAC;IAE/B;;;OAGG;IACmG,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAE9H;;;;OAIG;IACmD,MAAM,EAAE,eAAe,CAAC;IAGtE,MAAM,EAAE,MAAM,CAAC;gBAEX,KAAK,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC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