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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/CHANGELOG.md +132 -92
  2. package/README.md +39 -33
  3. package/dist/annotate/angle-mark.d.ts +52 -27
  4. package/dist/annotate/angle-mark.d.ts.map +1 -1
  5. package/dist/annotate/angle-mark.js +80 -115
  6. package/dist/annotate/angle-mark.js.map +1 -1
  7. package/dist/annotate/curly-brace.d.ts +59 -25
  8. package/dist/annotate/curly-brace.d.ts.map +1 -1
  9. package/dist/annotate/curly-brace.js +85 -100
  10. package/dist/annotate/curly-brace.js.map +1 -1
  11. package/dist/annotate/emphasis-mark.d.ts +43 -9
  12. package/dist/annotate/emphasis-mark.d.ts.map +1 -1
  13. package/dist/annotate/emphasis-mark.js +33 -34
  14. package/dist/annotate/emphasis-mark.js.map +1 -1
  15. package/dist/browser/chunks/chunk-ABYBW64J.js +2 -0
  16. package/dist/browser/chunks/chunk-ABYBW64J.js.map +7 -0
  17. package/dist/browser/chunks/chunk-K77KLQX4.js +2 -0
  18. package/dist/browser/chunks/chunk-K77KLQX4.js.map +7 -0
  19. package/dist/browser/index.js +1 -1
  20. package/dist/browser/index.js.map +3 -3
  21. package/dist/browser/kit.js +1 -1
  22. package/dist/browser/manifest.json +1 -1
  23. package/dist/browser/tex.js +1 -1
  24. package/dist/browser/tex.js.map +2 -2
  25. package/dist/engine.d.ts +26 -19
  26. package/dist/engine.d.ts.map +1 -1
  27. package/dist/engine.js +17 -14
  28. package/dist/engine.js.map +1 -1
  29. package/dist/kit/component.d.ts +51 -0
  30. package/dist/kit/component.d.ts.map +1 -0
  31. package/dist/kit/component.js +30 -0
  32. package/dist/kit/component.js.map +1 -0
  33. package/dist/kit/curve.d.ts +22 -11
  34. package/dist/kit/curve.d.ts.map +1 -1
  35. package/dist/kit/curve.js +25 -18
  36. package/dist/kit/curve.js.map +1 -1
  37. package/dist/kit/field-mark.d.ts +58 -35
  38. package/dist/kit/field-mark.d.ts.map +1 -1
  39. package/dist/kit/field-mark.js +100 -120
  40. package/dist/kit/field-mark.js.map +1 -1
  41. package/dist/kit/follow.d.ts +67 -29
  42. package/dist/kit/follow.d.ts.map +1 -1
  43. package/dist/kit/follow.js +114 -110
  44. package/dist/kit/follow.js.map +1 -1
  45. package/dist/kit/furniture.d.ts +3 -1
  46. package/dist/kit/furniture.d.ts.map +1 -1
  47. package/dist/kit/furniture.js +5 -0
  48. package/dist/kit/furniture.js.map +1 -1
  49. package/dist/kit/graph.d.ts +46 -0
  50. package/dist/kit/graph.d.ts.map +1 -0
  51. package/dist/kit/graph.js +90 -0
  52. package/dist/kit/graph.js.map +1 -0
  53. package/dist/kit/mark.d.ts +64 -39
  54. package/dist/kit/mark.d.ts.map +1 -1
  55. package/dist/kit/mark.js +80 -96
  56. package/dist/kit/mark.js.map +1 -1
  57. package/dist/kit/place.d.ts +10 -8
  58. package/dist/kit/place.d.ts.map +1 -1
  59. package/dist/kit/place.js +28 -30
  60. package/dist/kit/place.js.map +1 -1
  61. package/dist/kit/system.d.ts +27 -29
  62. package/dist/kit/system.d.ts.map +1 -1
  63. package/dist/kit/system.js +62 -58
  64. package/dist/kit/system.js.map +1 -1
  65. package/dist/kit/withdrawn.d.ts +3 -3
  66. package/dist/kit/withdrawn.js +3 -3
  67. package/dist/kit/withdrawn.js.map +1 -1
  68. package/dist/marks/curve-area.d.ts +24 -18
  69. package/dist/marks/curve-area.d.ts.map +1 -1
  70. package/dist/marks/curve-area.js +50 -73
  71. package/dist/marks/curve-area.js.map +1 -1
  72. package/dist/marks/drop-lines.d.ts +28 -10
  73. package/dist/marks/drop-lines.d.ts.map +1 -1
  74. package/dist/marks/drop-lines.js +37 -52
  75. package/dist/marks/drop-lines.js.map +1 -1
  76. package/dist/marks/plot-point.d.ts +37 -20
  77. package/dist/marks/plot-point.d.ts.map +1 -1
  78. package/dist/marks/plot-point.js +65 -91
  79. package/dist/marks/plot-point.js.map +1 -1
  80. package/dist/marks/riemann-sum.d.ts +30 -26
  81. package/dist/marks/riemann-sum.d.ts.map +1 -1
  82. package/dist/marks/riemann-sum.js +57 -85
  83. package/dist/marks/riemann-sum.js.map +1 -1
  84. package/dist/marks/tangent-line.d.ts +38 -14
  85. package/dist/marks/tangent-line.d.ts.map +1 -1
  86. package/dist/marks/tangent-line.js +73 -87
  87. package/dist/marks/tangent-line.js.map +1 -1
  88. package/dist/marks/vector-arrow.d.ts +30 -20
  89. package/dist/marks/vector-arrow.d.ts.map +1 -1
  90. package/dist/marks/vector-arrow.js +58 -78
  91. package/dist/marks/vector-arrow.js.map +1 -1
  92. package/dist/nodes.d.ts +13 -5
  93. package/dist/nodes.d.ts.map +1 -1
  94. package/dist/nodes.js +0 -6
  95. package/dist/nodes.js.map +1 -1
  96. package/dist/plots/function-plot.d.ts +107 -43
  97. package/dist/plots/function-plot.d.ts.map +1 -1
  98. package/dist/plots/function-plot.js +146 -177
  99. package/dist/plots/function-plot.js.map +1 -1
  100. package/dist/plots/points-plot.d.ts +34 -19
  101. package/dist/plots/points-plot.d.ts.map +1 -1
  102. package/dist/plots/points-plot.js +31 -58
  103. package/dist/plots/points-plot.js.map +1 -1
  104. package/dist/plots/stream-lines.d.ts +38 -19
  105. package/dist/plots/stream-lines.d.ts.map +1 -1
  106. package/dist/plots/stream-lines.js +60 -79
  107. package/dist/plots/stream-lines.js.map +1 -1
  108. package/dist/plots/traced-path.d.ts +34 -15
  109. package/dist/plots/traced-path.d.ts.map +1 -1
  110. package/dist/plots/traced-path.js +33 -48
  111. package/dist/plots/traced-path.js.map +1 -1
  112. package/dist/plots/vector-field.d.ts +31 -11
  113. package/dist/plots/vector-field.d.ts.map +1 -1
  114. package/dist/plots/vector-field.js +50 -64
  115. package/dist/plots/vector-field.js.map +1 -1
  116. package/dist/structures/network-graph.d.ts +99 -49
  117. package/dist/structures/network-graph.d.ts.map +1 -1
  118. package/dist/structures/network-graph.js +168 -217
  119. package/dist/structures/network-graph.js.map +1 -1
  120. package/dist/structures/sample-space.d.ts +69 -38
  121. package/dist/structures/sample-space.d.ts.map +1 -1
  122. package/dist/structures/sample-space.js +132 -170
  123. package/dist/structures/sample-space.js.map +1 -1
  124. package/dist/systems/axes2d.d.ts +126 -37
  125. package/dist/systems/axes2d.d.ts.map +1 -1
  126. package/dist/systems/axes2d.js +147 -183
  127. package/dist/systems/axes2d.js.map +1 -1
  128. package/dist/systems/number-line.d.ts +51 -28
  129. package/dist/systems/number-line.d.ts.map +1 -1
  130. package/dist/systems/number-line.js +82 -118
  131. package/dist/systems/number-line.js.map +1 -1
  132. package/dist/systems/number-plane.d.ts +92 -31
  133. package/dist/systems/number-plane.d.ts.map +1 -1
  134. package/dist/systems/number-plane.js +142 -149
  135. package/dist/systems/number-plane.js.map +1 -1
  136. package/dist/systems/polar-plane.d.ts +47 -26
  137. package/dist/systems/polar-plane.d.ts.map +1 -1
  138. package/dist/systems/polar-plane.js +107 -133
  139. package/dist/systems/polar-plane.js.map +1 -1
  140. package/dist/tex/index.d.ts.map +1 -1
  141. package/dist/tex/index.js +1 -0
  142. package/dist/tex/index.js.map +1 -1
  143. package/dist/tex/matrix.d.ts +56 -18
  144. package/dist/tex/matrix.d.ts.map +1 -1
  145. package/dist/tex/matrix.js +33 -50
  146. package/dist/tex/matrix.js.map +1 -1
  147. package/dist/tex/node.d.ts +55 -201
  148. package/dist/tex/node.d.ts.map +1 -1
  149. package/dist/tex/node.js +23 -593
  150. package/dist/tex/node.js.map +1 -1
  151. package/dist/tex/typeset.d.ts +133 -0
  152. package/dist/tex/typeset.d.ts.map +1 -0
  153. package/dist/tex/typeset.js +403 -0
  154. package/dist/tex/typeset.js.map +1 -0
  155. package/dist/three/axes3d.d.ts +140 -54
  156. package/dist/three/axes3d.d.ts.map +1 -1
  157. package/dist/three/axes3d.js +159 -204
  158. package/dist/three/axes3d.js.map +1 -1
  159. package/dist/three/curve-plot3d.d.ts +70 -42
  160. package/dist/three/curve-plot3d.d.ts.map +1 -1
  161. package/dist/three/curve-plot3d.js +97 -132
  162. package/dist/three/curve-plot3d.js.map +1 -1
  163. package/dist/three/entries.d.ts +17 -0
  164. package/dist/three/entries.d.ts.map +1 -0
  165. package/dist/three/entries.js +15 -0
  166. package/dist/three/entries.js.map +1 -0
  167. package/dist/three/plot-point3d.d.ts +57 -12
  168. package/dist/three/plot-point3d.d.ts.map +1 -1
  169. package/dist/three/plot-point3d.js +27 -53
  170. package/dist/three/plot-point3d.js.map +1 -1
  171. package/dist/three/space.d.ts +17 -2
  172. package/dist/three/space.d.ts.map +1 -1
  173. package/dist/three/space.js +19 -8
  174. package/dist/three/space.js.map +1 -1
  175. package/dist/three/surface-plot3d.d.ts +131 -49
  176. package/dist/three/surface-plot3d.d.ts.map +1 -1
  177. package/dist/three/surface-plot3d.js +227 -261
  178. package/dist/three/surface-plot3d.js.map +1 -1
  179. package/dist/three/vector-arrow3d.d.ts +58 -16
  180. package/dist/three/vector-arrow3d.d.ts.map +1 -1
  181. package/dist/three/vector-arrow3d.js +48 -67
  182. package/dist/three/vector-arrow3d.js.map +1 -1
  183. package/package.json +4 -4
  184. package/src/annotate/angle-mark.ts +95 -105
  185. package/src/annotate/curly-brace.ts +107 -85
  186. package/src/annotate/emphasis-mark.ts +55 -26
  187. package/src/engine.ts +35 -21
  188. package/src/kit/component.ts +57 -0
  189. package/src/kit/curve.ts +38 -20
  190. package/src/kit/field-mark.ts +124 -108
  191. package/src/kit/follow.ts +146 -120
  192. package/src/kit/furniture.ts +6 -1
  193. package/src/kit/graph.ts +116 -0
  194. package/src/kit/mark.ts +135 -114
  195. package/src/kit/place.ts +32 -56
  196. package/src/kit/system.ts +77 -71
  197. package/src/kit/withdrawn.ts +3 -3
  198. package/src/marks/curve-area.ts +65 -65
  199. package/src/marks/drop-lines.ts +50 -42
  200. package/src/marks/plot-point.ts +77 -82
  201. package/src/marks/riemann-sum.ts +73 -72
  202. package/src/marks/tangent-line.ts +87 -71
  203. package/src/marks/vector-arrow.ts +73 -73
  204. package/src/nodes.ts +41 -5
  205. package/src/plots/function-plot.ts +155 -171
  206. package/src/plots/points-plot.ts +46 -50
  207. package/src/plots/stream-lines.ts +75 -66
  208. package/src/plots/traced-path.ts +51 -33
  209. package/src/plots/vector-field.ts +68 -49
  210. package/src/structures/network-graph.ts +168 -185
  211. package/src/structures/sample-space.ts +149 -148
  212. package/src/systems/axes2d.ts +165 -156
  213. package/src/systems/number-line.ts +91 -92
  214. package/src/systems/number-plane.ts +149 -120
  215. package/src/systems/polar-plane.ts +117 -116
  216. package/src/tex/index.ts +2 -1
  217. package/src/tex/matrix.ts +62 -40
  218. package/src/tex/node.ts +54 -621
  219. package/src/tex/typeset.ts +461 -0
  220. package/src/three/axes3d.ts +182 -161
  221. package/src/three/curve-plot3d.ts +107 -110
  222. package/src/three/entries.ts +42 -0
  223. package/src/three/plot-point3d.ts +42 -45
  224. package/src/three/space.ts +34 -9
  225. package/src/three/surface-plot3d.ts +312 -323
  226. package/src/three/vector-arrow3d.ts +65 -54
  227. package/dist/browser/chunks/chunk-3GJB6AVO.js +0 -2
  228. package/dist/browser/chunks/chunk-3GJB6AVO.js.map +0 -7
  229. package/dist/browser/chunks/chunk-D5WHCVBC.js +0 -2
  230. package/dist/browser/chunks/chunk-D5WHCVBC.js.map +0 -7
  231. package/dist/browser/chunks/chunk-WL4KEX7Y.js +0 -2
  232. package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +0 -7
  233. package/src/kit/placement.ts +0 -8
@@ -1,87 +1,67 @@
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";
1
+ import { component2d, Types, } from "@motionscript/sdk";
2
+ import { omit, PAINT, PAINT_COMMANDS } from "../kit/component.js";
3
+ import { PLANE_ENTRY } from "../kit/graph.js";
4
+ import { drawMark, graphPoint, inkSize, ownPoint, reading, traced } from "../kit/mark.js";
12
5
  /** Degrees of arc per drawn segment of a bent arrow. */
13
6
  const BEND_STEP = 4;
7
+ const state = {
8
+ ...omit(PAINT, "fill"),
9
+ tail: Types.vector2(),
10
+ head: Types.vector2({ x: 1, y: 1 }),
11
+ /** The arc the arrow sweeps, in degrees: zero is straight, positive bows to its left. */
12
+ bend: Types.number(0, { min: -180, max: 180, unit: "°" }),
13
+ graph: PLANE_ENTRY,
14
+ };
15
+ /** A handle on one end of the arrow: where the end is in its own frame, and the graph point a drop there gives. */
16
+ const end = (which) => ({
17
+ at: (s) => {
18
+ const read = reading(s);
19
+ return ownPoint(read, traceArrow(s, read), s[which]);
20
+ },
21
+ value: (at, s) => {
22
+ const read = reading(s);
23
+ return graphPoint(read, traceArrow(s, read), at);
24
+ },
25
+ });
14
26
  /**
15
27
  * An arrow from `tail` to `head`, two graph points. Its arrowhead is the stroke's
16
28
  * `endCap`, so a plain segment, a double arrow or a dashed one is a change of
17
29
  * stroke. (`from` and `to` are not its names because every node has a `to`.)
18
30
  */
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];
31
+ export const VectorArrow = traced(component2d({
32
+ key: "vectorArrow",
33
+ state,
34
+ defaults: { stroke: { weight: 4, fill: "#e5e7eb", align: "center", endCap: "triangle" }, width: "hug", height: "hug" },
35
+ commands: {
36
+ ...omit(PAINT_COMMANDS, "fillTo"),
37
+ /** Move either end, in graph coordinates. */
38
+ endpointsTo: { args: ["tail", "head"] },
39
+ },
40
+ handles: { tail: end("tail"), head: end("head") },
41
+ measure: (_measurer, s) => inkSize(traceArrow(s, reading(s))),
42
+ render: (ctx, s) => drawMark(ctx, s, traceArrow(s, reading(s))),
43
+ }), traceArrow);
44
+ function traceArrow(s, { map, shift }) {
45
+ const a = map.toPoint(s.tail.x + shift.x, s.tail.y + shift.y);
46
+ const b = map.toPoint(s.head.x + shift.x, s.head.y + shift.y);
47
+ const sweep = (s.bend * Math.PI) / 180;
48
+ const chord = Math.hypot(b.x - a.x, b.y - a.y);
49
+ if (Math.abs(sweep) < 1e-3 || chord === 0)
50
+ return [[a, b]];
51
+ // The circle through both ends that subtends `sweep` at its centre.
52
+ const radius = chord / (2 * Math.sin(Math.abs(sweep) / 2));
53
+ const side = Math.sign(sweep);
54
+ const reach = radius * Math.cos(sweep / 2);
55
+ // The centre sits to the arrow's right for a positive sweep, so the arc bows to its left.
56
+ const cx = (a.x + b.x) / 2 + (side * (b.y - a.y) * reach) / chord;
57
+ const cy = (a.y + b.y) / 2 - (side * (b.x - a.x) * reach) / chord;
58
+ const from = Math.atan2(a.y - cy, a.x - cx);
59
+ const steps = Math.max(8, Math.ceil(Math.abs(s.bend) / BEND_STEP));
60
+ const run = [];
61
+ for (let i = 0; i <= steps; i++) {
62
+ const angle = from - (sweep * i) / steps;
63
+ run.push({ x: cx + radius * Math.cos(angle), y: cy + radius * Math.sin(angle) });
50
64
  }
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 };
65
+ return [run];
66
+ }
87
67
  //# sourceMappingURL=vector-arrow.js.map
@@ -1 +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,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,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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"]}
1
+ {"version":3,"file":"vector-arrow.js","sourceRoot":"","sources":["../../src/marks/vector-arrow.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAWR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAoC,MAAM,aAAa,CAAC;AAQzH,wDAAwD;AACxD,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,MAAM,KAAK,GAAG;IACV,GAAG,IAAI,CAAC,KAAK,EAAE,MA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,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACzC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC","sourcesContent":["import {\r\n component2d,\r\n Types,\r\n type NodeOf,\r\n type PaintProps,\r\n type Vector2,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n type Stroke as _Stroke,\r\n type StrokeResolved as _StrokeResolved,\r\n} from \"@motionscript/sdk\";\r\nimport { omit, PAINT, PAINT_COMMANDS } from \"../kit/component\";\r\nimport { PLANE_ENTRY } from \"../kit/graph\";\r\nimport { drawMark, graphPoint, inkSize, ownPoint, reading, traced, type MarkReading, type MarkState } from \"../kit/mark\";\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\nconst state = {\r\n ...omit(PAINT, \"fill\"),\r\n tail: Types.vector2(),\r\n head: Types.vector2({ x: 1, y: 1 }),\r\n /** The arc the arrow sweeps, in degrees: zero is straight, positive bows to its left. */\r\n bend: Types.number(0, { min: -180, max: 180, unit: \"°\" }),\r\n graph: PLANE_ENTRY,\r\n};\r\n\r\ninterface ArrowValues {\r\n readonly tail: Vector2;\r\n readonly head: Vector2;\r\n readonly bend: number;\r\n}\r\n\r\n/** A handle on one end of the arrow: where the end is in its own frame, and the graph point a drop there gives. */\r\nconst end = (which: \"tail\" | \"head\") => ({\r\n at: (s: ArrowValues & MarkState) => {\r\n const read = reading(s);\r\n return ownPoint(read, traceArrow(s, read), s[which]);\r\n },\r\n value: (at: Vector2, s: ArrowValues & MarkState) => {\r\n const read = reading(s);\r\n return graphPoint(read, traceArrow(s, read), at);\r\n },\r\n});\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\nexport const VectorArrow = traced(component2d({\r\n key: \"vectorArrow\",\r\n state,\r\n defaults: { stroke: { weight: 4, fill: \"#e5e7eb\", align: \"center\", endCap: \"triangle\" }, width: \"hug\", height: \"hug\" },\r\n commands: {\r\n ...omit(PAINT_COMMANDS, \"fillTo\"),\r\n /** Move either end, in graph coordinates. */\r\n endpointsTo: { args: [\"tail\", \"head\"] },\r\n },\r\n handles: { tail: end(\"tail\"), head: end(\"head\") },\r\n measure: (_measurer, s) => inkSize(traceArrow(s, reading(s))),\r\n render: (ctx, s) => drawMark(ctx, s, traceArrow(s, reading(s))),\r\n}), traceArrow);\r\n\r\nexport type VectorArrow = NodeOf<typeof VectorArrow>;\r\n\r\nfunction traceArrow(s: ArrowValues, { map, shift }: MarkReading): Vector2[][] {\r\n const a = map.toPoint(s.tail.x + shift.x, s.tail.y + shift.y);\r\n const b = map.toPoint(s.head.x + shift.x, s.head.y + shift.y);\r\n const sweep = (s.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(s.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"]}
package/dist/nodes.d.ts CHANGED
@@ -26,10 +26,18 @@ import { PlotPoint3d } from "./three/plot-point3d.js";
26
26
  import { SurfacePlot3d } from "./three/surface-plot3d.js";
27
27
  import { VectorArrow3d } from "./three/vector-arrow3d.js";
28
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.
29
+ * Every node type this package publishes.
30
+ *
31
+ * A host registers these by handing the array to an engine —
32
+ * `new Engine(platform, { nodes: NODES })` — which reads each component's key.
33
+ * Defining a component only *declares* that key: nothing is registered by
34
+ * importing a module, so a registry holds exactly what its owner asked for.
35
+ *
36
+ * Listing the component **values** is also what survives bundling: this package
37
+ * declares `sideEffects: false`, and a document names a node type by string, so
38
+ * an import kept only for its side effect is exactly what gets shaken out.
33
39
  */
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)[];
40
+ type KitNode = typeof Latex | typeof LatexMatrix | typeof NumberLine | typeof Axes2d | typeof NumberPlane | typeof FunctionPlot | 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;
41
+ export declare const NODES: KitNode[];
42
+ export {};
35
43
  //# sourceMappingURL=nodes.d.ts.map
@@ -1 +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;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,sB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AAO,SAAS,GAChB,OAAO,YAAY,GACnB,OAAO,MAAM,GACb,OAAO,aAAa,GACpB,OAAO,WAAW,GAClB,OAAO,WAAW,GAClB,OAAO,aAAa,GACpB,OAAO,UAAU,GACjB,OAAO,WAAW,GAClB,OAAO,WAAW,GAClB,OAAO,UAAU,GACjB,OAAO,YAAY,GACnB,OAAO,WAAW,CAAC;AAEzB,eAAO,MAAM,KAAK,EAAE,OAAO,EA4B1B,CAAC"}
package/dist/nodes.js CHANGED
@@ -25,12 +25,6 @@ import { CurvePlot3d } from "./three/curve-plot3d.js";
25
25
  import { PlotPoint3d } from "./three/plot-point3d.js";
26
26
  import { SurfacePlot3d } from "./three/surface-plot3d.js";
27
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
28
  export const NODES = [
35
29
  Latex,
36
30
  LatexMatrix,
package/dist/nodes.js.map CHANGED
@@ -1 +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,Y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,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"]}
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;AA4CvD,MAAM,CAAC,MAAM,KAAK,GAAc;IAC5B,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.\r\n *\r\n * A host registers these by handing the array to an engine —\r\n * `new Engine(platform, { nodes: NODES })` — which reads each component's key.\r\n * Defining a component only *declares* that key: nothing is registered by\r\n * importing a module, so a registry holds exactly what its owner asked for.\r\n *\r\n * Listing the component **values** is also what survives bundling: this package\r\n * declares `sideEffects: false`, and a document names a node type by string, so\r\n * an import kept only for its side effect is exactly what gets shaken out.\r\n */\r\n// Typed by name, so the declaration names each component rather than spelling out its type through core.\r\ntype KitNode =\r\n | typeof Latex\r\n | typeof LatexMatrix\r\n | typeof NumberLine\r\n | typeof Axes2d\r\n | typeof NumberPlane\r\n | typeof FunctionPlot\r\n | typeof PointsPlot\r\n | typeof PlotPoint\r\n | typeof VectorArrow\r\n | typeof CurveArea\r\n | typeof RiemannSum\r\n | typeof TangentLine\r\n | typeof DropLines\r\n | typeof CurlyBrace\r\n | typeof AngleMark\r\n | typeof EmphasisMark\r\n | typeof Axes3d\r\n | typeof SurfacePlot3d\r\n | typeof CurvePlot3d\r\n | typeof PlotPoint3d\r\n | typeof VectorArrow3d\r\n | typeof PolarPlane\r\n | typeof VectorField\r\n | typeof StreamLines\r\n | typeof TracedPath\r\n | typeof NetworkGraph\r\n | typeof SampleSpace;\r\n\r\nexport const NODES: KitNode[] = [\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"]}
@@ -1,67 +1,131 @@
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";
1
+ import { type NodeOf, type PaintProps, type Vector2, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
2
+ import type { Interval } from "../kit/coords.js";
4
3
  import type { ExpressionScope } from "../kit/expression.js";
5
- import { Mark } from "../kit/mark.js";
4
+ import { type MarkReading } from "../kit/mark.js";
6
5
  import { type PlotSource } from "../kit/source.js";
7
6
  export interface FunctionPlotProps extends PaintProps {
8
7
  expression?: string | PlotSource;
9
8
  domain?: Interval | null;
10
9
  params?: ExpressionScope;
11
10
  }
11
+ /** A plot's entries: what a traced path is built on too. It is only a line, so it has no fill. */
12
+ export declare const PLOT_STATE: {
13
+ expression: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
14
+ /**
15
+ * The span of the free variable that is drawn. Left out, a function runs the
16
+ * width of its system, a polar curve one turn and a parametric one from 0 to 1.
17
+ */
18
+ domain: import("@motionscript/sdk").Type<Interval | null, Interval | null, false>;
19
+ /**
20
+ * The equation's named values: any name in it that is not a variable, a
21
+ * function or a constant. One left unset is 1, and a formula can bind each
22
+ * to a variable.
23
+ */
24
+ params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
25
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
26
+ start: import("@motionscript/sdk").Type<number, number, false>;
27
+ end: import("@motionscript/sdk").Type<number, number, false>;
28
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
29
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
30
+ };
31
+ /** A plot's own commands, beside a line's paints. */
32
+ export declare const PLOT_COMMANDS: {
33
+ /** Change the equation, the curve bending from the one into the other. */
34
+ morphTo: {
35
+ args: readonly ["expression"];
36
+ };
37
+ /** Animate the equation's named values. */
38
+ paramsTo: {
39
+ args: readonly ["params"];
40
+ };
41
+ /** Animate the span that is drawn. */
42
+ domainTo: {
43
+ args: readonly ["domain"];
44
+ };
45
+ strokeTo: {
46
+ readonly args: readonly ["stroke"];
47
+ readonly run?: undefined;
48
+ };
49
+ shadowTo: {
50
+ readonly args: readonly ["shadow"];
51
+ readonly run?: undefined;
52
+ };
53
+ progressTo: {
54
+ readonly args: readonly ["start", "end"];
55
+ readonly run?: undefined;
56
+ };
57
+ flash: {
58
+ readonly args: {
59
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
60
+ };
61
+ run(timeline: any, state: any, children: any): import("@motionscript/sdk").Piece;
62
+ };
63
+ };
64
+ export declare const PLOT_STROKE: {
65
+ readonly weight: 3;
66
+ readonly fill: "#58a6ff";
67
+ readonly align: "center";
68
+ readonly cap: "round";
69
+ readonly join: "round";
70
+ };
71
+ /** What a plot's curve is drawn from. */
72
+ export interface PlotValues {
73
+ readonly expression: PlotSource;
74
+ readonly params: ExpressionScope;
75
+ }
12
76
  /**
13
77
  * The curve of an equation, drawn in the coordinate system it is a child of.
14
78
  * How the equation is written says what it is: see `Equation`. A mark put
15
79
  * inside it reads it: the area under it, a tangent, a point that rides it.
16
80
  */
17
- export declare class FunctionPlot<P extends FunctionPlotProps = FunctionPlotProps> extends Mark<P> implements Curve {
18
- expression: PlotSource;
81
+ export declare const FunctionPlot: import("@motionscript/sdk").Component<"functionPlot", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
82
+ expression: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
19
83
  /**
20
84
  * The span of the free variable that is drawn. Left out, a function runs the
21
85
  * width of its system, a polar curve one turn and a parametric one from 0 to 1.
22
86
  */
23
- domain: Interval | null;
87
+ domain: import("@motionscript/sdk").Type<Interval | null, Interval | null, false>;
24
88
  /**
25
89
  * The equation's named values: any name in it that is not a variable, a
26
90
  * function or a constant. One left unset is 1, and a formula can bind each
27
91
  * to a variable.
28
92
  */
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>;
93
+ params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
94
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
95
+ start: import("@motionscript/sdk").Type<number, number, false>;
96
+ end: import("@motionscript/sdk").Type<number, number, false>;
97
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
98
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
99
+ }>, {
100
+ morphTo: readonly ["expression"];
101
+ paramsTo: readonly ["params"];
102
+ domainTo: readonly ["domain"];
103
+ strokeTo: readonly ["stroke"];
104
+ shadowTo: readonly ["shadow"];
105
+ progressTo: readonly ["start", "end"];
106
+ flash: {
107
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
108
+ };
109
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
110
+ expression: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
111
+ /**
112
+ * The span of the free variable that is drawn. Left out, a function runs the
113
+ * width of its system, a polar curve one turn and a parametric one from 0 to 1.
114
+ */
115
+ domain: import("@motionscript/sdk").Type<Interval | null, Interval | null, false>;
50
116
  /**
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.
117
+ * The equation's named values: any name in it that is not a variable, a
118
+ * function or a constant. One left unset is 1, and a formula can bind each
119
+ * to a variable.
53
120
  */
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
- }
121
+ params: import("@motionscript/sdk").Type<Readonly<Record<string, number>>, Readonly<Record<string, number>>, false>;
122
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
123
+ start: import("@motionscript/sdk").Type<number, number, false>;
124
+ end: import("@motionscript/sdk").Type<number, number, false>;
125
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
126
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
127
+ }>, null>>;
128
+ export type FunctionPlot = NodeOf<typeof FunctionPlot>;
129
+ /** The runs a plot of `s` draws through `read`, over `span` of its free variable (all of it for `null`). */
130
+ export declare function tracePlot(s: PlotValues, read: MarkReading, span: Interval | null): Vector2[][];
67
131
  //# sourceMappingURL=function-plot.d.ts.map
@@ -1 +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,CAAC;IAIlD,0EAA0E;IAE1E,OAAO,C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