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

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 +28 -0
  2. package/README.md +39 -33
  3. package/dist/annotate/angle-mark.d.ts +77 -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 +94 -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 +69 -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 +56 -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 +37 -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 +45 -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 +56 -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 +47 -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 +58 -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 +48 -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 +135 -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 +55 -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 +60 -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 +54 -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 +48 -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 +140 -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 +90 -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 +159 -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 +80 -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 +140 -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 +76 -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 +88 -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 +84 -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 +214 -54
  156. package/dist/three/axes3d.d.ts.map +1 -1
  157. package/dist/three/axes3d.js +163 -204
  158. package/dist/three/axes3d.js.map +1 -1
  159. package/dist/three/curve-plot3d.d.ts +108 -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 +85 -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 +176 -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 +87 -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 +187 -160
  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,67 +1,71 @@
1
- import { Clip, flowOps, Graphics2D, insetsOps, PaintNode, } from "@motionscript/sdk";
1
+ import { Graphics2D, insetsOps, Paint, provides, } from "@motionscript/sdk";
2
+ import { settle, SYSTEM, systemPlane } from "./graph.js";
2
3
  import { openPlane, placeOnMap } from "./place.js";
3
- const NO_CONTENT = { width: 0, height: 0 };
4
- const CENTRE = { x: 0, y: 0 };
5
4
  /**
6
- * A node whose children sit in its graph coordinates. A child's `x`/`y` are in
7
- * the system's units and the child keeps its own size, so anything can be put
8
- * on a graph: a dot, a label, an image. A mark is drawn through the
9
- * system's map instead and laid out on its ink.
5
+ * What a coordinate system shares: a node whose children sit in its graph
6
+ * coordinates. A child's `x`/`y` are in the system's units and the child keeps
7
+ * its own size, so anything can be put on a graph: a dot, a label, an image. A
8
+ * mark is drawn through the system's map instead and laid out on its ink.
10
9
  *
11
10
  * The system's `stroke` is its axis line (so `endCap` is the tip) and its `fill`
12
11
  * the backdrop. Ticks, grid and labels are drawing ops, never child nodes: a
13
12
  * document's children would otherwise share their indices with them.
14
13
  */
15
- export class CoordinateSystem extends PaintNode {
16
- /** This system's coordinates, as last laid out. */
17
- get coordinates() {
18
- return this._map ?? (this._map = this.mapFor(this._area(this.layoutBounds)));
19
- }
20
- // A system is the size it is given: its children are placed in it, not measured into it.
21
- measure(constraints) {
22
- return flowOps.size(this, constraints, this.effectivePadding(), NO_CONTENT);
23
- }
24
- layoutChildren(rect, scope) {
25
- const map = this.mapFor(this._area(rect));
26
- this._map = map;
27
- const inner = insetsOps.insetBounds(rect.width, rect.height, this.effectivePadding());
28
- this._planes = placeOnMap(this.flowChildren(), map, CENTRE, inner, scope);
29
- }
30
- _planeOf(child) {
31
- return child ? (this._planes.get(child) ?? null) : openPlane(this.coordinates, CENTRE);
32
- }
33
- shapeGraphics() {
34
- const r = this.layoutBounds;
35
- return new Graphics2D().rect({ x: 0, y: 0, width: r.width, height: r.height });
36
- }
37
- renderSelf(ctx) {
38
- super.renderSelf(ctx);
39
- const map = this.coordinates;
40
- const clip = map.spills ? this.clipSelf() : null;
41
- if (clip)
42
- ctx.beginClip(clip);
43
- for (const part of this.furniture(map))
44
- ctx.draw(part);
45
- if (clip)
46
- ctx.endClip();
47
- }
48
- // The stroke is the axis line, drawn with the furniture: painted here it would land over the children.
49
- renderStroke() { }
50
- clipSelf() {
51
- const { minX, minY, maxX, maxY } = this.coordinates.area;
52
- return new Clip().rect({ x: (minX + maxX) / 2, y: (minY + maxY) / 2, width: maxX - minX, height: maxY - minY });
53
- }
54
- _map = null;
55
- _planes = new WeakMap();
56
- /** The plot area: the box less its padding, y-up from the box's centre. */
57
- _area(rect) {
58
- const inner = insetsOps.insetBounds(rect.width, rect.height, this.effectivePadding());
59
- return {
60
- minX: inner.x - inner.width / 2,
61
- maxX: inner.x + inner.width / 2,
62
- minY: -inner.y - inner.height / 2,
63
- maxY: -inner.y + inner.height / 2,
64
- };
65
- }
14
+ const CENTRE = { x: 0, y: 0 };
15
+ /** The plot area: the box less its padding, y-up from the box's centre. */
16
+ export function plotArea(size, padding) {
17
+ const inner = insetsOps.insetBounds(size.width, size.height, padding);
18
+ return {
19
+ minX: inner.x - inner.width / 2,
20
+ maxX: inner.x + inner.width / 2,
21
+ minY: -inner.y - inner.height / 2,
22
+ maxY: -inner.y + inner.height / 2,
23
+ };
24
+ }
25
+ /** A system's map at a laid-out `size`. */
26
+ export function systemMap(size, state, mapFor) {
27
+ return mapFor(plotArea(size, state.padding), state);
28
+ }
29
+ /** A system is the size it is given: its children are placed in it, not measured into it. */
30
+ export function systemSize(state) {
31
+ const { left, right, top, bottom } = state.padding;
32
+ return { width: left + right, height: top + bottom };
33
+ }
34
+ /** What a system hands its subtree: its plane, which its layout keeps current. */
35
+ export function systemProvides(state) {
36
+ return [provides(SYSTEM, systemPlane(state))];
37
+ }
38
+ /** Lay a system's children out on its map. */
39
+ export function systemLayout(size, state, children, mapFor) {
40
+ const map = systemMap(size, state, mapFor);
41
+ const plane = systemPlane(state);
42
+ settle(plane, map, children);
43
+ const inner = insetsOps.insetBounds(size.width, size.height, state.padding);
44
+ return placeOnMap(children, map, CENTRE, inner, plane);
45
+ }
46
+ /** Where a child dropped on a system would sit. */
47
+ export function systemOpenPlane(size, state, mapFor) {
48
+ return openPlane(systemMap(size, state, mapFor), CENTRE);
49
+ }
50
+ /**
51
+ * A system's paint: the backdrop, then the furniture under its children, kept
52
+ * in the plot area where the map spills from it, then the children, confined
53
+ * to the plot area when `clip` is set. The stroke is the axis line, drawn with
54
+ * the furniture: painted after the children it would land over them.
55
+ */
56
+ export function drawSystem(ctx, state, map, furniture) {
57
+ const { width, height } = ctx.size;
58
+ const { minX, minY, maxX, maxY } = map.area;
59
+ const area = new Graphics2D().rect({ x: (minX + maxX) / 2, y: (minY + maxY) / 2, width: maxX - minX, height: maxY - minY });
60
+ ctx.inFront(() => {
61
+ ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).shadow(state.shadow).fill(state.fill));
62
+ const parts = furniture(map);
63
+ if (map.spills)
64
+ ctx.clip(area, () => ctx.draw(parts));
65
+ else
66
+ ctx.draw(parts);
67
+ });
68
+ // No shape of its own to paint here; the plot area is what clips the children and what picking tests.
69
+ Paint.draw(ctx, state, null, { clipShape: area });
66
70
  }
67
71
  //# sourceMappingURL=system.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/kit/system.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,EACJ,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,GAWZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIhD,MAAM,UAAU,GAAW,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AACnD,MAAM,MAAM,GAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAEvC;;;;;;;;;GASG;AACH,MAAM,OAAgB,gBAAoD,SAAQ,SAAY;IAO1F,mDAAmD;IACnD,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,yFAAyF;IAChF,OAAO,CAAC,WAA4B;QACzC,OAAO,O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AAE,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC;SACpC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import {\r\n Clip,\r\n flowOps,\r\n Graphics2D,\r\n insetsOps,\r\n PaintNode,\r\n type BoxBounds,\r\n type ChildPlane,\r\n type Extents,\r\n type MeasureContext2D,\r\n type Node2D,\r\n type PaintProps,\r\n type RenderContext2D,\r\n type Size2D,\r\n type SizeConstraints,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport type { CoordinateMap } from \"./coords\";\r\nimport { openPlane, placeOnMap } from \"./place\";\r\n\r\nexport type { Anchored } from \"./place\";\r\n\r\nconst NO_CONTENT: Size2D = { width: 0, height: 0 };\r\nconst CENTRE: Vector2 = { x: 0, y: 0 };\r\n\r\n/**\r\n * A node whose children sit in its graph coordinates. A child's `x`/`y` are in\r\n * the system's units and the child keeps its own size, so anything can be put\r\n * on a graph: a dot, a label, an image. A mark is drawn through the\r\n * system's map instead and laid out on its ink.\r\n *\r\n * The system's `stroke` is its axis line (so `endCap` is the tip) and its `fill`\r\n * the backdrop. Ticks, grid and labels are drawing ops, never child nodes: a\r\n * document's children would otherwise share their indices with them.\r\n */\r\nexport abstract class CoordinateSystem<P extends PaintProps = PaintProps> extends PaintNode<P> {\r\n /** How graph values land on a plot area of this size. */\r\n protected abstract mapFor(area: Extents): CoordinateMap;\r\n\r\n /** What the system draws of itself, under its children. */\r\n protected abstract furniture(map: CoordinateMap): Graphics2D[];\r\n\r\n /** This system's coordinates, as last laid out. */\r\n get coordinates(): CoordinateMap {\r\n return this._map ?? (this._map = this.mapFor(this._area(this.layoutBounds)));\r\n }\r\n\r\n // A system is the size it is given: its children are placed in it, not measured into it.\r\n override measure(constraints: SizeConstraints): Partial<Size2D> {\r\n return flowOps.size(this, constraints, this.effectivePadding(), NO_CONTENT);\r\n }\r\n\r\n protected override layoutChildren(rect: BoxBounds, scope: MeasureContext2D): void {\r\n const map = this.mapFor(this._area(rect));\r\n this._map = map;\r\n const inner = insetsOps.insetBounds(rect.width, rect.height, this.effectivePadding());\r\n this._planes = placeOnMap(this.flowChildren(), map, CENTRE, inner, scope);\r\n }\r\n\r\n override _planeOf(child: Node2D | null): ChildPlane | null {\r\n return child ? (this._planes.get(child) ?? null) : openPlane(this.coordinates, CENTRE);\r\n }\r\n\r\n protected override shapeGraphics(): Graphics2D | null {\r\n const r = this.layoutBounds;\r\n return new Graphics2D().rect({ x: 0, y: 0, width: r.width, height: r.height });\r\n }\r\n\r\n protected override renderSelf(ctx: RenderContext2D): void {\r\n super.renderSelf(ctx);\r\n const map = this.coordinates;\r\n const clip = map.spills ? this.clipSelf() : null;\r\n if (clip) ctx.beginClip(clip);\r\n for (const part of this.furniture(map)) ctx.draw(part);\r\n if (clip) ctx.endClip();\r\n }\r\n\r\n // The stroke is the axis line, drawn with the furniture: painted here it would land over the children.\r\n protected override renderStroke(): void {}\r\n\r\n protected override clipSelf(): Clip | null {\r\n const { minX, minY, maxX, maxY } = this.coordinates.area;\r\n return new Clip().rect({ x: (minX + maxX) / 2, y: (minY + maxY) / 2, width: maxX - minX, height: maxY - minY });\r\n }\r\n\r\n private _map: CoordinateMap | null = null;\r\n private _planes = new WeakMap<Node2D, ChildPlane>();\r\n\r\n /** The plot area: the box less its padding, y-up from the box's centre. */\r\n private _area(rect: BoxBounds): Extents {\r\n const inner = insetsOps.insetBounds(rect.width, rect.height, this.effectivePadding());\r\n return {\r\n minX: inner.x - inner.width / 2,\r\n maxX: inner.x + inner.width / 2,\r\n minY: -inner.y - inner.height / 2,\r\n maxY: -inner.y + inner.height / 2,\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/kit/system.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,SAAS,EACT,KAAK,EACL,QAAQ,GAYX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAA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AAI,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;IAC5H,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACrG,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,GAAG,CAAC,MAAM;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;YACjD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,sGAAsG;IACtG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAoC,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACrF,CAAC","sourcesContent":["import {\r\n Graphics2D,\r\n insetsOps,\r\n Paint,\r\n provides,\r\n type ChildPlane,\r\n type ChildView,\r\n type Extents,\r\n type InsetsResolved,\r\n type Placement2D,\r\n type Provided,\r\n type RenderContext,\r\n type Shadow,\r\n type Fill,\r\n type Size2D,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport type { CoordinateMap } from \"./coords\";\r\nimport { settle, SYSTEM, systemPlane } from \"./graph\";\r\nimport { openPlane, placeOnMap } from \"./place\";\r\n\r\n/**\r\n * What a coordinate system shares: a node whose children sit in its graph\r\n * coordinates. A child's `x`/`y` are in the system's units and the child keeps\r\n * its own size, so anything can be put on a graph: a dot, a label, an image. A\r\n * mark is drawn through the system's map instead and laid out on its ink.\r\n *\r\n * The system's `stroke` is its axis line (so `endCap` is the tip) and its `fill`\r\n * the backdrop. Ticks, grid and labels are drawing ops, never child nodes: a\r\n * document's children would otherwise share their indices with them.\r\n */\r\n\r\nconst CENTRE: Vector2 = { x: 0, y: 0 };\r\n\r\n/** What a system's helpers read of its state. */\r\nexport interface SystemState {\r\n readonly padding: InsetsResolved;\r\n readonly fill: Fill;\r\n readonly shadow: Shadow;\r\n readonly clip: boolean;\r\n}\r\n\r\n/** How a system's graph values land on its plot area. */\r\nexport type MapFor<S> = (area: Extents, state: S) => CoordinateMap;\r\n\r\n/** The plot area: the box less its padding, y-up from the box's centre. */\r\nexport function plotArea(size: Size2D, padding: InsetsResolved): Extents {\r\n const inner = insetsOps.insetBounds(size.width, size.height, padding);\r\n return {\r\n minX: inner.x - inner.width / 2,\r\n maxX: inner.x + inner.width / 2,\r\n minY: -inner.y - inner.height / 2,\r\n maxY: -inner.y + inner.height / 2,\r\n };\r\n}\r\n\r\n/** A system's map at a laid-out `size`. */\r\nexport function systemMap<S extends SystemState>(size: Size2D, state: S, mapFor: MapFor<S>): CoordinateMap {\r\n return mapFor(plotArea(size, state.padding), state);\r\n}\r\n\r\n/** A system is the size it is given: its children are placed in it, not measured into it. */\r\nexport function systemSize(state: SystemState): Size2D {\r\n const { left, right, top, bottom } = state.padding;\r\n return { width: left + right, height: top + bottom };\r\n}\r\n\r\n/** What a system hands its subtree: its plane, which its layout keeps current. */\r\nexport function systemProvides(state: object): readonly Provided[] {\r\n return [provides(SYSTEM, systemPlane(state))];\r\n}\r\n\r\n/** Lay a system's children out on its map. */\r\nexport function systemLayout<S extends SystemState>(size: Size2D, state: S, children: readonly ChildView[], mapFor: MapFor<S>): Placement2D[] {\r\n const map = systemMap(size, state, mapFor);\r\n const plane = systemPlane(state);\r\n settle(plane, map, children);\r\n const inner = insetsOps.insetBounds(size.width, size.height, state.padding);\r\n return placeOnMap(children, map, CENTRE, inner, plane);\r\n}\r\n\r\n/** Where a child dropped on a system would sit. */\r\nexport function systemOpenPlane<S extends SystemState>(size: Size2D, state: S, mapFor: MapFor<S>): ChildPlane {\r\n return openPlane(systemMap(size, state, mapFor), CENTRE);\r\n}\r\n\r\n/**\r\n * A system's paint: the backdrop, then the furniture under its children, kept\r\n * in the plot area where the map spills from it, then the children, confined\r\n * to the plot area when `clip` is set. The stroke is the axis line, drawn with\r\n * the furniture: painted after the children it would land over them.\r\n */\r\nexport function drawSystem(ctx: RenderContext, state: SystemState, map: CoordinateMap, furniture: (map: CoordinateMap) => Graphics2D[]): void {\r\n const { width, height } = ctx.size;\r\n const { minX, minY, maxX, maxY } = map.area;\r\n const area = new Graphics2D().rect({ x: (minX + maxX) / 2, y: (minY + maxY) / 2, width: maxX - minX, height: maxY - minY });\r\n ctx.inFront(() => {\r\n ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).shadow(state.shadow).fill(state.fill));\r\n const parts = furniture(map);\r\n if (map.spills) ctx.clip(area, () => ctx.draw(parts));\r\n else ctx.draw(parts);\r\n });\r\n // No shape of its own to paint here; the plot area is what clips the children and what picking tests.\r\n Paint.draw(ctx, state as unknown as Paint.PaintState, null, { clipShape: area });\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
- * What a math node built on a general shape inherits and may have no use for,
3
- * as `withdraw` takes it: a node that is only a line has no fill, an area no
4
- * outline, and one that reveals itself in its own way no outline trim.
2
+ * The paint entries and commands a math node may have no use for: a node that
3
+ * is only a line has no fill, an area no outline, and one that reveals itself
4
+ * in its own way no outline trim.
5
5
  */
6
6
  export declare const FILL_PAINT: readonly ["fill", "fillTo"];
7
7
  export declare const STROKE_PAINT: readonly ["stroke", "strokeTo"];
@@ -1,7 +1,7 @@
1
1
  /**
2
- * What a math node built on a general shape inherits and may have no use for,
3
- * as `withdraw` takes it: a node that is only a line has no fill, an area no
4
- * outline, and one that reveals itself in its own way no outline trim.
2
+ * The paint entries and commands a math node may have no use for: a node that
3
+ * is only a line has no fill, an area no outline, and one that reveals itself
4
+ * in its own way no outline trim.
5
5
  */
6
6
  export const FILL_PAINT = ["fill", "fillTo"];
7
7
  export const STROKE_PAINT = ["stroke", "strokeTo"];
@@ -1 +1 @@
1
- {"version":3,"file":"withdrawn.js","sourceRoot":"","sources":["../../src/kit/withdrawn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAU,CAAC;AAC5D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAU,CAAC","sourcesContent":["/**\r\n * What a math node built on a general shape inherits and may have no use for,\r\n * as `withdraw` takes it: a node that is only a line has no fill, an area no\r\n * outline, and one that reveals itself in its own way no outline trim.\r\n */\r\nexport const FILL_PAINT = [\"fill\", \"fillTo\"] as const;\r\nexport const STROKE_PAINT = [\"stroke\", \"strokeTo\"] as const;\r\nexport const OUTLINE_TRIM = [\"start\", \"end\", \"progressTo\", \"flash\"] as const;\r\n"]}
1
+ {"version":3,"file":"withdrawn.js","sourceRoot":"","sources":["../../src/kit/withdrawn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAU,CAAC;AAC5D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAU,CAAC","sourcesContent":["/**\r\n * The paint entries and commands a math node may have no use for: a node that\r\n * is only a line has no fill, an area no outline, and one that reveals itself\r\n * in its own way no outline trim.\r\n */\r\nexport const FILL_PAINT = [\"fill\", \"fillTo\"] as const;\r\nexport const STROKE_PAINT = [\"stroke\", \"strokeTo\"] as const;\r\nexport const OUTLINE_TRIM = [\"start\", \"end\", \"progressTo\", \"flash\"] as const;\r\n"]}
@@ -1,6 +1,5 @@
1
- import { type Command, type CommandArgs, type Fill, type NodeConfig, type PaintProps, type Vector2 } from "@motionscript/sdk";
2
- import type { CoordinateMap, Interval } from "../kit/coords.js";
3
- import { Mark } from "../kit/mark.js";
1
+ import { type NodeOf, type NodeView, type PaintProps, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved } from "@motionscript/sdk";
2
+ import type { Interval } from "../kit/coords.js";
4
3
  export interface CurveAreaProps extends PaintProps {
5
4
  on?: string;
6
5
  under?: string;
@@ -12,21 +11,41 @@ export interface CurveAreaProps extends PaintProps {
12
11
  * two, and it has a life of its own on the timeline, swept open or kept while
13
12
  * a curve changes.
14
13
  */
15
- export declare class CurveArea extends Mark<CurveAreaProps> {
14
+ export declare const CurveArea: import("@motionscript/sdk").Component<"curveArea", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
16
15
  /** The plot that bounds the area, by id. */
17
- on: string;
16
+ on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
18
17
  /** A second plot to fill down to, in place of the x axis. */
19
- under: string;
20
- domain: Interval;
21
- fill: Fill;
22
- constructor(props?: NodeConfig<CurveArea, CurveAreaProps>);
23
- /** Animate the span of x that is filled: sweep an area open, or slide it along. */
24
- domainTo(args: CommandArgs<{
25
- domain: Interval;
26
- }> & {
27
- duration: number;
28
- }): Command<CurveAreaProps>;
29
- protected isClosed(): boolean;
30
- protected trace(map: CoordinateMap): Vector2[][];
31
- }
18
+ under: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
19
+ domain: import("@motionscript/sdk").Type<Interval, Interval, false>;
20
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
21
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
22
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
23
+ }>, {
24
+ readonly domainTo: readonly ["domain"];
25
+ readonly fillTo: readonly ["fill"];
26
+ readonly shadowTo: readonly ["shadow"];
27
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
28
+ /** The plot that bounds the area, by id. */
29
+ on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
30
+ /** A second plot to fill down to, in place of the x axis. */
31
+ under: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
32
+ domain: import("@motionscript/sdk").Type<Interval, Interval, false>;
33
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
34
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
35
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
36
+ }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
37
+ /** The plot that bounds the area, by id. */
38
+ on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
39
+ /** A second plot to fill down to, in place of the x axis. */
40
+ under: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
41
+ domain: import("@motionscript/sdk").Type<Interval, Interval, false>;
42
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
43
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
44
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
45
+ }>, {
46
+ readonly domainTo: readonly ["domain"];
47
+ readonly fillTo: readonly ["fill"];
48
+ readonly shadowTo: readonly ["shadow"];
49
+ }, _Node2D<_Node2DProps>>>>;
50
+ export type CurveArea = NodeOf<typeof CurveArea>;
32
51
  //# sourceMappingURL=curve-area.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"curve-area.d.ts","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,OAAO,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAMnC,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBASa,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC;IAC/C,4CAA4C;IACwD,EAAE,EAAE,MAAM,CAAC;IAC/G,6DAA6D;IACuC,KAAK,EAAE,MAAM,CAAC;IAE1G,MAAM,EAAE,QAAQ,CAAC;IAE+D,IAAI,EAAE,IAAI,CAAC;gBAEvF,KAAK,CAAC,EAAE,UAAU,CAAC,SAAS,EAAE,cAAc,CAAC;IAIzD,mFAAmF;IAEnF,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,MAAM,EAAE,QAAQ,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;cAI9E,QAAQ,IAAI,OAAO;IAItC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,EAAE,EAAE;CAsBnD"}
1
+ {"version":3,"file":"curve-area.d.ts","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,UAAU,EAGf,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAO9C,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,QAAQ,CAAC;CACrB;AAmBD;;;;;GAKG;AACH,eAAO,MAAM,SAAS;IApBlB,4CAA4C;;IAE5C,6DAA6D;;;;;;;;;;;IAF7D,4CAA4C;;IAE5C,6DAA6D;;;;;;;IAF7D,4CAA4C;;IAE5C,6DAA6D;;;;;;;;;;2BA6BnD,CAAC;AAEf,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC"}
@@ -1,82 +1,59 @@
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, withdraw, } from "@motionscript/sdk";
8
- import { clamp, stated } from "../kit/geometry.js";
9
- import { Mark } from "../kit/mark.js";
10
- import { curveNamed, curveOf } from "../kit/curve.js";
1
+ import { component2d, Types, } from "@motionscript/sdk";
2
+ import { omit, PAINT, PAINT_COMMANDS } from "../kit/component.js";
3
+ import { curveValue } from "../kit/curve.js";
11
4
  import { lerpInterval, PLOT_COLOR, readInterval } from "../kit/furniture.js";
12
- import { SYSTEMS } from "../kit/placement.js";
13
- import { OUTLINE_TRIM, STROKE_PAINT } from "../kit/withdrawn.js";
5
+ import { clamp } from "../kit/geometry.js";
6
+ import { curveFor, PLANE_ENTRY, PLOT_REF } from "../kit/graph.js";
7
+ import { drawMark, inkSize, reading, traced } from "../kit/mark.js";
8
+ const state = {
9
+ // An area is only its fill, and has no outline to trim.
10
+ ...omit(PAINT, "stroke", "start", "end"),
11
+ /** The plot that bounds the area, by id. */
12
+ on: PLOT_REF,
13
+ /** A second plot to fill down to, in place of the x axis. */
14
+ under: PLOT_REF,
15
+ domain: Types.custom([0, 1], { resolve: readInterval, lerp: lerpInterval }),
16
+ graph: PLANE_ENTRY,
17
+ };
14
18
  /**
15
19
  * The region between a plot and the x axis, or between two plots, over a span
16
20
  * of x. It sits beside the plots it reads rather than inside one: it may read
17
21
  * two, and it has a life of its own on the timeline, swept open or kept while
18
22
  * a curve changes.
19
23
  */
20
- let CurveArea = class CurveArea extends Mark {
21
- constructor(props) {
22
- super(props ?? {});
23
- }
24
- /** Animate the span of x that is filled: sweep an area open, or slide it along. */
25
- domainTo(args) {
26
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
24
+ export const CurveArea = traced(component2d({
25
+ key: "curveArea",
26
+ state,
27
+ defaults: { fill: { type: "solid", color: PLOT_COLOR, opacity: 0.35 }, width: "hug", height: "hug" },
28
+ commands: {
29
+ ...omit(PAINT_COMMANDS, "strokeTo", "progressTo", "flash"),
30
+ /** Animate the span of x that is filled: sweep an area open, or slide it along. */
31
+ domainTo: { args: ["domain"] },
32
+ },
33
+ measure: (_measurer, s) => inkSize(traceArea(s, reading(s))),
34
+ render: (ctx, s) => drawMark(ctx, s, traceArea(s, reading(s)), { closed: true }),
35
+ }), traceArea);
36
+ function traceArea(s, { map, plane }) {
37
+ const top = curveFor(plane, s.on);
38
+ if (!top)
39
+ return [];
40
+ const floor = curveFor(plane, s.under, false);
41
+ const [yMin, yMax] = map.yRange;
42
+ const a = Math.max(s.domain[0], map.xRange[0]);
43
+ const b = Math.min(s.domain[1], map.xRange[1]);
44
+ if (!(b > a))
45
+ return [];
46
+ const width = Math.abs(map.toPoint(b, 0).x - map.toPoint(a, 0).x);
47
+ const steps = Math.max(8, Math.min(600, Math.round(width / 2)));
48
+ // Held inside the system's range, and at the axis where a curve has no value.
49
+ const height = (value) => (Number.isFinite(value) ? clamp(value, yMin, yMax) : clamp(0, yMin, yMax));
50
+ const upper = [];
51
+ const lower = [];
52
+ for (let i = 0; i <= steps; i++) {
53
+ const x = a + ((b - a) * i) / steps;
54
+ upper.push(map.toPoint(x, height(curveValue(top, x))));
55
+ lower.push(map.toPoint(x, height(floor ? curveValue(floor, x) : 0)));
27
56
  }
28
- isClosed() {
29
- return true;
30
- }
31
- trace(map) {
32
- const top = curveOf(this, this.on);
33
- if (!top)
34
- return [];
35
- const floor = curveNamed(this, this.under);
36
- const [yMin, yMax] = map.yRange;
37
- const a = Math.max(this.domain[0], map.xRange[0]);
38
- const b = Math.min(this.domain[1], map.xRange[1]);
39
- if (!(b > a))
40
- return [];
41
- const width = Math.abs(map.toPoint(b, 0).x - map.toPoint(a, 0).x);
42
- const steps = Math.max(8, Math.min(600, Math.round(width / 2)));
43
- // Held inside the system's range, and at the axis where a curve has no value.
44
- const height = (value) => (Number.isFinite(value) ? clamp(value, yMin, yMax) : clamp(0, yMin, yMax));
45
- const upper = [];
46
- const lower = [];
47
- for (let i = 0; i <= steps; i++) {
48
- const x = a + ((b - a) * i) / steps;
49
- upper.push(map.toPoint(x, height(top.valueAt(x))));
50
- lower.push(map.toPoint(x, height(floor ? floor.valueAt(x) : 0)));
51
- }
52
- return [[...upper, ...lower.reverse()]];
53
- }
54
- };
55
- __decorate([
56
- property({ default: "", kind: "nodeRef", nodeTypes: ["functionPlot"], animatable: false })
57
- ], CurveArea.prototype, "on", void 0);
58
- __decorate([
59
- property({ default: "", kind: "nodeRef", nodeTypes: ["functionPlot"], animatable: false })
60
- ], CurveArea.prototype, "under", void 0);
61
- __decorate([
62
- property({ default: [0, 1], mapper: readInterval, tween: lerpInterval })
63
- ], CurveArea.prototype, "domain", void 0);
64
- __decorate([
65
- fillProperty({ default: { type: "solid", color: PLOT_COLOR, opacity: 0.35 } })
66
- ], CurveArea.prototype, "fill", void 0);
67
- __decorate([
68
- command({ args: ["domain"] })
69
- ], CurveArea.prototype, "domainTo", null);
70
- CurveArea = __decorate([
71
- node({
72
- key: "curveArea",
73
- within: SYSTEMS,
74
- beside: ["functionPlot"],
75
- parentKey: "shape",
76
- forkable: true,
77
- layout: { children: "freeform", defaultWidthMode: "hug", defaultHeightMode: "hug", acceptsChildren: false },
78
- }),
79
- withdraw(...STROKE_PAINT, ...OUTLINE_TRIM)
80
- ], CurveArea);
81
- export { CurveArea };
57
+ return [[...upper, ...lower.reverse()]];
58
+ }
82
59
  //# sourceMappingURL=curve-area.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"curve-area.js","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,QAAQ,GAOX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,OAAO,E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ector2,\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 { curveNamed, curveOf } from \"../kit/curve\";\r\nimport { lerpInterval, PLOT_COLOR, readInterval } from \"../kit/furniture\";\r\nimport { SYSTEMS } from \"../kit/placement\";\r\nimport { OUTLINE_TRIM, STROKE_PAINT } from \"../kit/withdrawn\";\r\n\r\nexport interface CurveAreaProps extends PaintProps {\r\n on?: string;\r\n under?: string;\r\n domain?: Interval;\r\n}\r\n\r\n/**\r\n * The region between a plot and the x axis, or between two plots, over a span\r\n * of x. It sits beside the plots it reads rather than inside one: it may read\r\n * two, and it has a life of its own on the timeline, swept open or kept while\r\n * a curve changes.\r\n */\r\n@node({\r\n key: \"curveArea\",\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(...STROKE_PAINT, ...OUTLINE_TRIM)\r\nexport class CurveArea extends Mark<CurveAreaProps> {\r\n /** The plot that bounds the area, by id. */\r\n @property({ default: \"\", kind: \"nodeRef\", nodeTypes: [\"functionPlot\"], animatable: false }) declare on: string;\r\n /** A second plot to fill down to, in place of the x axis. */\r\n @property({ default: \"\", kind: \"nodeRef\", nodeTypes: [\"functionPlot\"], animatable: false }) declare under: string;\r\n @property({ default: [0, 1], mapper: readInterval, tween: lerpInterval })\r\n declare domain: Interval;\r\n\r\n @fillProperty({ default: { type: \"solid\", color: PLOT_COLOR, opacity: 0.35 } }) declare fill: Fill;\r\n\r\n constructor(props?: NodeConfig<CurveArea, CurveAreaProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n /** Animate the span of x that is filled: sweep an area open, or slide it along. */\r\n @command({ args: [\"domain\"] })\r\n domainTo(args: CommandArgs<{ domain: Interval }> & { duration: number }): Command<CurveAreaProps> {\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 top = curveOf(this, this.on);\r\n if (!top) return [];\r\n const floor = curveNamed(this, this.under);\r\n const [yMin, yMax] = map.yRange;\r\n const a = Math.max(this.domain[0], map.xRange[0]);\r\n const b = Math.min(this.domain[1], map.xRange[1]);\r\n if (!(b > a)) return [];\r\n\r\n const width = Math.abs(map.toPoint(b, 0).x - map.toPoint(a, 0).x);\r\n const steps = Math.max(8, Math.min(600, Math.round(width / 2)));\r\n // Held inside the system's range, and at the axis where a curve has no value.\r\n const height = (value: number) => (Number.isFinite(value) ? clamp(value, yMin, yMax) : clamp(0, yMin, yMax));\r\n const upper: Vector2[] = [];\r\n const lower: Vector2[] = [];\r\n for (let i = 0; i <= steps; i++) {\r\n const x = a + ((b - a) * i) / steps;\r\n upper.push(map.toPoint(x, height(top.valueAt(x))));\r\n lower.push(map.toPoint(x, height(floor ? floor.valueAt(x) : 0)));\r\n }\r\n return [[...upper, ...lower.reverse()]];\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"curve-area.js","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAYR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EA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AAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7G,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import {\r\n component2d,\r\n Types,\r\n type NodeOf,\r\n type NodeView,\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 Fill as _Fill,\r\n type FillResolved as _FillResolved,\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} from \"@motionscript/sdk\";\r\nimport { omit, PAINT, PAINT_COMMANDS } from \"../kit/component\";\r\nimport type { Interval } from \"../kit/coords\";\r\nimport { curveValue } from \"../kit/curve\";\r\nimport { lerpInterval, PLOT_COLOR, readInterval } from \"../kit/furniture\";\r\nimport { clamp } from \"../kit/geometry\";\r\nimport { curveFor, PLANE_ENTRY, PLOT_REF } from \"../kit/graph\";\r\nimport { drawMark, inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\r\n\r\nexport interface CurveAreaProps extends PaintProps {\r\n on?: string;\r\n under?: string;\r\n domain?: Interval;\r\n}\r\n\r\nconst state = {\r\n // An area is only its fill, and has no outline to trim.\r\n ...omit(PAINT, \"stroke\", \"start\", \"end\"),\r\n /** The plot that bounds the area, by id. */\r\n on: PLOT_REF,\r\n /** A second plot to fill down to, in place of the x axis. */\r\n under: PLOT_REF,\r\n domain: Types.custom<Interval>([0, 1], { resolve: readInterval, lerp: lerpInterval }),\r\n graph: PLANE_ENTRY,\r\n};\r\n\r\ninterface AreaValues {\r\n readonly on: NodeView | null;\r\n readonly under: NodeView | null;\r\n readonly domain: Interval;\r\n}\r\n\r\n/**\r\n * The region between a plot and the x axis, or between two plots, over a span\r\n * of x. It sits beside the plots it reads rather than inside one: it may read\r\n * two, and it has a life of its own on the timeline, swept open or kept while\r\n * a curve changes.\r\n */\r\nexport const CurveArea = traced(component2d({\r\n key: \"curveArea\",\r\n state,\r\n defaults: { fill: { type: \"solid\", color: PLOT_COLOR, opacity: 0.35 }, width: \"hug\", height: \"hug\" },\r\n commands: {\r\n ...omit(PAINT_COMMANDS, \"strokeTo\", \"progressTo\", \"flash\"),\r\n /** Animate the span of x that is filled: sweep an area open, or slide it along. */\r\n domainTo: { args: [\"domain\"] },\r\n },\r\n measure: (_measurer, s) => inkSize(traceArea(s, reading(s))),\r\n render: (ctx, s) => drawMark(ctx, s, traceArea(s, reading(s)), { closed: true }),\r\n}), traceArea);\r\n\r\nexport type CurveArea = NodeOf<typeof CurveArea>;\r\n\r\nfunction traceArea(s: AreaValues, { map, plane }: MarkReading): Vector2[][] {\r\n const top = curveFor(plane, s.on);\r\n if (!top) return [];\r\n const floor = curveFor(plane, s.under, false);\r\n const [yMin, yMax] = map.yRange;\r\n const a = Math.max(s.domain[0], map.xRange[0]);\r\n const b = Math.min(s.domain[1], map.xRange[1]);\r\n if (!(b > a)) return [];\r\n\r\n const width = Math.abs(map.toPoint(b, 0).x - map.toPoint(a, 0).x);\r\n const steps = Math.max(8, Math.min(600, Math.round(width / 2)));\r\n // Held inside the system's range, and at the axis where a curve has no value.\r\n const height = (value: number) => (Number.isFinite(value) ? clamp(value, yMin, yMax) : clamp(0, yMin, yMax));\r\n const upper: Vector2[] = [];\r\n const lower: Vector2[] = [];\r\n for (let i = 0; i <= steps; i++) {\r\n const x = a + ((b - a) * i) / steps;\r\n upper.push(map.toPoint(x, height(curveValue(top, x))));\r\n lower.push(map.toPoint(x, height(floor ? curveValue(floor, x) : 0)));\r\n }\r\n return [[...upper, ...lower.reverse()]];\r\n}\r\n"]}
@@ -1,6 +1,4 @@
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";
1
+ import { type NodeOf, type NodeView, type PaintProps, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
4
2
  export type DropAxis = "x" | "y" | "both";
5
3
  export interface DropLinesProps extends PaintProps {
6
4
  on?: string;
@@ -10,13 +8,50 @@ export interface DropLinesProps extends PaintProps {
10
8
  * Guide lines from a graph point to the axes, reading its coordinates off them.
11
9
  * The point is this node's `x`/`y`, or the point of a plot above its `x`.
12
10
  */
13
- export declare class DropLines extends Mark<DropLinesProps> {
11
+ export declare const DropLines: import("@motionscript/sdk").Component<"dropLines", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
14
12
  /** A plot to take the point's height from, by id. */
15
- on: string;
13
+ on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
16
14
  /** Which axis to drop to: `x` draws the vertical line, `y` the horizontal one. */
17
- axis: DropAxis;
18
- stroke: Stroke;
19
- constructor(props?: NodeConfig<DropLines, DropLinesProps>);
20
- protected trace(map: CoordinateMap): Vector2[][];
21
- }
15
+ axis: import("@motionscript/sdk").Type<"x" | "y" | "both", "x" | "y" | "both", false>;
16
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
17
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
18
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
19
+ start: import("@motionscript/sdk").Type<number, number, false>;
20
+ end: import("@motionscript/sdk").Type<number, number, false>;
21
+ }>, {
22
+ strokeTo: readonly ["stroke"];
23
+ shadowTo: readonly ["shadow"];
24
+ progressTo: readonly ["start", "end"];
25
+ flash: {
26
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
27
+ };
28
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
29
+ /** A plot to take the point's height from, by id. */
30
+ on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
31
+ /** Which axis to drop to: `x` draws the vertical line, `y` the horizontal one. */
32
+ axis: import("@motionscript/sdk").Type<"x" | "y" | "both", "x" | "y" | "both", false>;
33
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
34
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
35
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
36
+ start: import("@motionscript/sdk").Type<number, number, false>;
37
+ end: import("@motionscript/sdk").Type<number, number, false>;
38
+ }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
39
+ /** A plot to take the point's height from, by id. */
40
+ on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
41
+ /** Which axis to drop to: `x` draws the vertical line, `y` the horizontal one. */
42
+ axis: import("@motionscript/sdk").Type<"x" | "y" | "both", "x" | "y" | "both", false>;
43
+ graph: import("@motionscript/sdk").Type<import("../index.js").GraphPlane | null, import("../index.js").GraphPlane | null, true>;
44
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
45
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
46
+ start: import("@motionscript/sdk").Type<number, number, false>;
47
+ end: import("@motionscript/sdk").Type<number, number, false>;
48
+ }>, {
49
+ strokeTo: readonly ["stroke"];
50
+ shadowTo: readonly ["shadow"];
51
+ progressTo: readonly ["start", "end"];
52
+ flash: {
53
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
54
+ };
55
+ }, _Node2D<_Node2DProps>>>>;
56
+ export type DropLines = NodeOf<typeof DropLines>;
22
57
  //# sourceMappingURL=drop-lines.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"drop-lines.d.ts","sourceRoot":"","sources":["../../src/marks/drop-lines.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;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAMnC,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AAE1C,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,QAAQ,CAAC;CACnB;AAED;;;GAGG;AACH,qBAQa,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC;IAC/C,qDAAqD;IAC+C,EAAE,EAAE,MAAM,CA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