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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +49 -0
  4. package/README.md +389 -2
  5. package/dist/annotate/angle-mark.d.ts +96 -0
  6. package/dist/annotate/angle-mark.d.ts.map +1 -0
  7. package/dist/annotate/angle-mark.js +97 -0
  8. package/dist/annotate/angle-mark.js.map +1 -0
  9. package/dist/annotate/curly-brace.d.ts +115 -0
  10. package/dist/annotate/curly-brace.d.ts.map +1 -0
  11. package/dist/annotate/curly-brace.js +99 -0
  12. package/dist/annotate/curly-brace.js.map +1 -0
  13. package/dist/annotate/emphasis-mark.d.ts +80 -0
  14. package/dist/annotate/emphasis-mark.d.ts.map +1 -0
  15. package/dist/annotate/emphasis-mark.js +80 -0
  16. package/dist/annotate/emphasis-mark.js.map +1 -0
  17. package/dist/browser/THIRD_PARTY_LICENSES.txt +420 -0
  18. package/dist/browser/chunks/chunk-IRZCG6PM.js +2 -0
  19. package/dist/browser/chunks/chunk-IRZCG6PM.js.map +7 -0
  20. package/dist/browser/chunks/chunk-WMVW6ZIV.js +2 -0
  21. package/dist/browser/chunks/chunk-WMVW6ZIV.js.map +7 -0
  22. package/dist/browser/chunks/mathjax-WV55AC2P.js +61 -0
  23. package/dist/browser/chunks/mathjax-WV55AC2P.js.map +7 -0
  24. package/dist/browser/index.js +2 -0
  25. package/dist/browser/index.js.map +7 -0
  26. package/dist/browser/kit.js +2 -0
  27. package/dist/browser/kit.js.map +7 -0
  28. package/dist/browser/manifest.json +30 -0
  29. package/dist/browser/tex.js +2 -0
  30. package/dist/browser/tex.js.map +7 -0
  31. package/dist/engine.d.ts +71 -0
  32. package/dist/engine.d.ts.map +1 -0
  33. package/dist/engine.js +45 -0
  34. package/dist/engine.js.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +30 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/kit/brace.d.ts +8 -0
  40. package/dist/kit/brace.d.ts.map +1 -0
  41. package/dist/kit/brace.js +36 -0
  42. package/dist/kit/brace.js.map +1 -0
  43. package/dist/kit/cache.d.ts +30 -0
  44. package/dist/kit/cache.d.ts.map +1 -0
  45. package/dist/kit/cache.js +53 -0
  46. package/dist/kit/cache.js.map +1 -0
  47. package/dist/kit/component.d.ts +51 -0
  48. package/dist/kit/component.d.ts.map +1 -0
  49. package/dist/kit/component.js +30 -0
  50. package/dist/kit/component.js.map +1 -0
  51. package/dist/kit/contour.d.ts +8 -0
  52. package/dist/kit/contour.d.ts.map +1 -0
  53. package/dist/kit/contour.js +93 -0
  54. package/dist/kit/contour.js.map +1 -0
  55. package/dist/kit/coords.d.ts +69 -0
  56. package/dist/kit/coords.d.ts.map +1 -0
  57. package/dist/kit/coords.js +224 -0
  58. package/dist/kit/coords.js.map +1 -0
  59. package/dist/kit/curve.d.ts +28 -0
  60. package/dist/kit/curve.d.ts.map +1 -0
  61. package/dist/kit/curve.js +29 -0
  62. package/dist/kit/curve.js.map +1 -0
  63. package/dist/kit/equation.d.ts +61 -0
  64. package/dist/kit/equation.d.ts.map +1 -0
  65. package/dist/kit/equation.js +168 -0
  66. package/dist/kit/equation.js.map +1 -0
  67. package/dist/kit/equation3d.d.ts +50 -0
  68. package/dist/kit/equation3d.d.ts.map +1 -0
  69. package/dist/kit/equation3d.js +103 -0
  70. package/dist/kit/equation3d.js.map +1 -0
  71. package/dist/kit/expression.d.ts +35 -0
  72. package/dist/kit/expression.d.ts.map +1 -0
  73. package/dist/kit/expression.js +124 -0
  74. package/dist/kit/expression.js.map +1 -0
  75. package/dist/kit/field-mark.d.ts +79 -0
  76. package/dist/kit/field-mark.d.ts.map +1 -0
  77. package/dist/kit/field-mark.js +109 -0
  78. package/dist/kit/field-mark.js.map +1 -0
  79. package/dist/kit/field.d.ts +14 -0
  80. package/dist/kit/field.d.ts.map +1 -0
  81. package/dist/kit/field.js +46 -0
  82. package/dist/kit/field.js.map +1 -0
  83. package/dist/kit/follow.d.ts +109 -0
  84. package/dist/kit/follow.d.ts.map +1 -0
  85. package/dist/kit/follow.js +163 -0
  86. package/dist/kit/follow.js.map +1 -0
  87. package/dist/kit/furniture.d.ts +32 -0
  88. package/dist/kit/furniture.d.ts.map +1 -0
  89. package/dist/kit/furniture.js +92 -0
  90. package/dist/kit/furniture.js.map +1 -0
  91. package/dist/kit/geometry.d.ts +13 -0
  92. package/dist/kit/geometry.d.ts.map +1 -0
  93. package/dist/kit/geometry.js +54 -0
  94. package/dist/kit/geometry.js.map +1 -0
  95. package/dist/kit/graph.d.ts +46 -0
  96. package/dist/kit/graph.d.ts.map +1 -0
  97. package/dist/kit/graph.js +90 -0
  98. package/dist/kit/graph.js.map +1 -0
  99. package/dist/kit/mark.d.ts +72 -0
  100. package/dist/kit/mark.d.ts.map +1 -0
  101. package/dist/kit/mark.js +87 -0
  102. package/dist/kit/mark.js.map +1 -0
  103. package/dist/kit/part-fills.d.ts +23 -0
  104. package/dist/kit/part-fills.d.ts.map +1 -0
  105. package/dist/kit/part-fills.js +46 -0
  106. package/dist/kit/part-fills.js.map +1 -0
  107. package/dist/kit/place.d.ts +20 -0
  108. package/dist/kit/place.d.ts.map +1 -0
  109. package/dist/kit/place.js +66 -0
  110. package/dist/kit/place.js.map +1 -0
  111. package/dist/kit/sampler.d.ts +17 -0
  112. package/dist/kit/sampler.d.ts.map +1 -0
  113. package/dist/kit/sampler.js +250 -0
  114. package/dist/kit/sampler.js.map +1 -0
  115. package/dist/kit/scale.d.ts +12 -0
  116. package/dist/kit/scale.d.ts.map +1 -0
  117. package/dist/kit/scale.js +37 -0
  118. package/dist/kit/scale.js.map +1 -0
  119. package/dist/kit/source.d.ts +22 -0
  120. package/dist/kit/source.d.ts.map +1 -0
  121. package/dist/kit/source.js +45 -0
  122. package/dist/kit/source.js.map +1 -0
  123. package/dist/kit/system.d.ts +31 -0
  124. package/dist/kit/system.d.ts.map +1 -0
  125. package/dist/kit/system.js +71 -0
  126. package/dist/kit/system.js.map +1 -0
  127. package/dist/kit/ticks.d.ts +19 -0
  128. package/dist/kit/ticks.d.ts.map +1 -0
  129. package/dist/kit/ticks.js +78 -0
  130. package/dist/kit/ticks.js.map +1 -0
  131. package/dist/kit/withdrawn.d.ts +9 -0
  132. package/dist/kit/withdrawn.d.ts.map +1 -0
  133. package/dist/kit/withdrawn.js +9 -0
  134. package/dist/kit/withdrawn.js.map +1 -0
  135. package/dist/marks/curve-area.d.ts +51 -0
  136. package/dist/marks/curve-area.d.ts.map +1 -0
  137. package/dist/marks/curve-area.js +59 -0
  138. package/dist/marks/curve-area.js.map +1 -0
  139. package/dist/marks/drop-lines.d.ts +57 -0
  140. package/dist/marks/drop-lines.d.ts.map +1 -0
  141. package/dist/marks/drop-lines.js +43 -0
  142. package/dist/marks/drop-lines.js.map +1 -0
  143. package/dist/marks/plot-point.d.ts +71 -0
  144. package/dist/marks/plot-point.d.ts.map +1 -0
  145. package/dist/marks/plot-point.js +71 -0
  146. package/dist/marks/plot-point.js.map +1 -0
  147. package/dist/marks/riemann-sum.d.ts +58 -0
  148. package/dist/marks/riemann-sum.d.ts.map +1 -0
  149. package/dist/marks/riemann-sum.js +63 -0
  150. package/dist/marks/riemann-sum.js.map +1 -0
  151. package/dist/marks/tangent-line.d.ts +71 -0
  152. package/dist/marks/tangent-line.d.ts.map +1 -0
  153. package/dist/marks/tangent-line.js +89 -0
  154. package/dist/marks/tangent-line.js.map +1 -0
  155. package/dist/marks/vector-arrow.d.ts +60 -0
  156. package/dist/marks/vector-arrow.d.ts.map +1 -0
  157. package/dist/marks/vector-arrow.js +67 -0
  158. package/dist/marks/vector-arrow.js.map +1 -0
  159. package/dist/nodes.d.ts +43 -0
  160. package/dist/nodes.d.ts.map +1 -0
  161. package/dist/nodes.js +57 -0
  162. package/dist/nodes.js.map +1 -0
  163. package/dist/plots/function-plot.d.ts +159 -0
  164. package/dist/plots/function-plot.d.ts.map +1 -0
  165. package/dist/plots/function-plot.js +184 -0
  166. package/dist/plots/function-plot.js.map +1 -0
  167. package/dist/plots/points-plot.d.ts +64 -0
  168. package/dist/plots/points-plot.d.ts.map +1 -0
  169. package/dist/plots/points-plot.js +72 -0
  170. package/dist/plots/points-plot.js.map +1 -0
  171. package/dist/plots/stream-lines.d.ts +76 -0
  172. package/dist/plots/stream-lines.d.ts.map +1 -0
  173. package/dist/plots/stream-lines.js +122 -0
  174. package/dist/plots/stream-lines.js.map +1 -0
  175. package/dist/plots/traced-path.d.ts +70 -0
  176. package/dist/plots/traced-path.d.ts.map +1 -0
  177. package/dist/plots/traced-path.js +41 -0
  178. package/dist/plots/traced-path.js.map +1 -0
  179. package/dist/plots/vector-field.d.ts +60 -0
  180. package/dist/plots/vector-field.d.ts.map +1 -0
  181. package/dist/plots/vector-field.js +77 -0
  182. package/dist/plots/vector-field.js.map +1 -0
  183. package/dist/structures/graph-layout.d.ts +11 -0
  184. package/dist/structures/graph-layout.d.ts.map +1 -0
  185. package/dist/structures/graph-layout.js +135 -0
  186. package/dist/structures/graph-layout.js.map +1 -0
  187. package/dist/structures/network-graph.d.ts +174 -0
  188. package/dist/structures/network-graph.d.ts.map +1 -0
  189. package/dist/structures/network-graph.js +240 -0
  190. package/dist/structures/network-graph.js.map +1 -0
  191. package/dist/structures/sample-space.d.ts +114 -0
  192. package/dist/structures/sample-space.d.ts.map +1 -0
  193. package/dist/structures/sample-space.js +161 -0
  194. package/dist/structures/sample-space.js.map +1 -0
  195. package/dist/systems/axes2d.d.ts +197 -0
  196. package/dist/systems/axes2d.d.ts.map +1 -0
  197. package/dist/systems/axes2d.js +157 -0
  198. package/dist/systems/axes2d.js.map +1 -0
  199. package/dist/systems/number-line.d.ts +101 -0
  200. package/dist/systems/number-line.d.ts.map +1 -0
  201. package/dist/systems/number-line.js +91 -0
  202. package/dist/systems/number-line.js.map +1 -0
  203. package/dist/systems/number-plane.d.ts +168 -0
  204. package/dist/systems/number-plane.d.ts.map +1 -0
  205. package/dist/systems/number-plane.js +186 -0
  206. package/dist/systems/number-plane.js.map +1 -0
  207. package/dist/systems/polar-plane.d.ts +98 -0
  208. package/dist/systems/polar-plane.d.ts.map +1 -0
  209. package/dist/systems/polar-plane.js +139 -0
  210. package/dist/systems/polar-plane.js.map +1 -0
  211. package/dist/tex/geometry.d.ts +85 -0
  212. package/dist/tex/geometry.d.ts.map +1 -0
  213. package/dist/tex/geometry.js +632 -0
  214. package/dist/tex/geometry.js.map +1 -0
  215. package/dist/tex/index.d.ts +11 -0
  216. package/dist/tex/index.d.ts.map +1 -0
  217. package/dist/tex/index.js +10 -0
  218. package/dist/tex/index.js.map +1 -0
  219. package/dist/tex/mathjax.d.ts +33 -0
  220. package/dist/tex/mathjax.d.ts.map +1 -0
  221. package/dist/tex/mathjax.js +74 -0
  222. package/dist/tex/mathjax.js.map +1 -0
  223. package/dist/tex/matrix.d.ts +101 -0
  224. package/dist/tex/matrix.d.ts.map +1 -0
  225. package/dist/tex/matrix.js +56 -0
  226. package/dist/tex/matrix.js.map +1 -0
  227. package/dist/tex/node.d.ts +98 -0
  228. package/dist/tex/node.d.ts.map +1 -0
  229. package/dist/tex/node.js +25 -0
  230. package/dist/tex/node.js.map +1 -0
  231. package/dist/tex/tween.d.ts +50 -0
  232. package/dist/tex/tween.d.ts.map +1 -0
  233. package/dist/tex/tween.js +253 -0
  234. package/dist/tex/tween.js.map +1 -0
  235. package/dist/tex/typeset.d.ts +133 -0
  236. package/dist/tex/typeset.d.ts.map +1 -0
  237. package/dist/tex/typeset.js +403 -0
  238. package/dist/tex/typeset.js.map +1 -0
  239. package/dist/three/axes3d.d.ts +247 -0
  240. package/dist/three/axes3d.d.ts.map +1 -0
  241. package/dist/three/axes3d.js +187 -0
  242. package/dist/three/axes3d.js.map +1 -0
  243. package/dist/three/curve-plot3d.d.ts +126 -0
  244. package/dist/three/curve-plot3d.d.ts.map +1 -0
  245. package/dist/three/curve-plot3d.js +109 -0
  246. package/dist/three/curve-plot3d.js.map +1 -0
  247. package/dist/three/entries.d.ts +17 -0
  248. package/dist/three/entries.d.ts.map +1 -0
  249. package/dist/three/entries.js +15 -0
  250. package/dist/three/entries.js.map +1 -0
  251. package/dist/three/label3d.d.ts +11 -0
  252. package/dist/three/label3d.d.ts.map +1 -0
  253. package/dist/three/label3d.js +42 -0
  254. package/dist/three/label3d.js.map +1 -0
  255. package/dist/three/plot-point3d.d.ts +99 -0
  256. package/dist/three/plot-point3d.d.ts.map +1 -0
  257. package/dist/three/plot-point3d.js +34 -0
  258. package/dist/three/plot-point3d.js.map +1 -0
  259. package/dist/three/space.d.ts +43 -0
  260. package/dist/three/space.d.ts.map +1 -0
  261. package/dist/three/space.js +58 -0
  262. package/dist/three/space.js.map +1 -0
  263. package/dist/three/surface-plot3d.d.ts +207 -0
  264. package/dist/three/surface-plot3d.d.ts.map +1 -0
  265. package/dist/three/surface-plot3d.js +261 -0
  266. package/dist/three/surface-plot3d.js.map +1 -0
  267. package/dist/three/vector-arrow3d.d.ts +96 -0
  268. package/dist/three/vector-arrow3d.d.ts.map +1 -0
  269. package/dist/three/vector-arrow3d.js +53 -0
  270. package/dist/three/vector-arrow3d.js.map +1 -0
  271. package/package.json +80 -3
  272. package/registry.json +251 -0
  273. package/src/annotate/angle-mark.ts +137 -0
  274. package/src/annotate/curly-brace.ts +148 -0
  275. package/src/annotate/emphasis-mark.ts +118 -0
  276. package/src/engine.ts +86 -0
  277. package/src/index.ts +29 -0
  278. package/src/kit/brace.ts +37 -0
  279. package/src/kit/cache.ts +61 -0
  280. package/src/kit/component.ts +57 -0
  281. package/src/kit/contour.ts +94 -0
  282. package/src/kit/coords.ts +278 -0
  283. package/src/kit/curve.ts +47 -0
  284. package/src/kit/equation.ts +181 -0
  285. package/src/kit/equation3d.ts +137 -0
  286. package/src/kit/expression.ts +159 -0
  287. package/src/kit/field-mark.ts +171 -0
  288. package/src/kit/field.ts +50 -0
  289. package/src/kit/follow.ts +229 -0
  290. package/src/kit/furniture.ts +113 -0
  291. package/src/kit/geometry.ts +49 -0
  292. package/src/kit/graph.ts +116 -0
  293. package/src/kit/mark.ts +152 -0
  294. package/src/kit/part-fills.ts +61 -0
  295. package/src/kit/place.ts +77 -0
  296. package/src/kit/sampler.ts +281 -0
  297. package/src/kit/scale.ts +39 -0
  298. package/src/kit/source.ts +57 -0
  299. package/src/kit/system.ts +105 -0
  300. package/src/kit/ticks.ts +85 -0
  301. package/src/kit/withdrawn.ts +8 -0
  302. package/src/marks/curve-area.ts +89 -0
  303. package/src/marks/drop-lines.ts +71 -0
  304. package/src/marks/plot-point.ts +102 -0
  305. package/src/marks/riemann-sum.ts +99 -0
  306. package/src/marks/tangent-line.ts +119 -0
  307. package/src/marks/vector-arrow.ts +98 -0
  308. package/src/nodes.ts +99 -0
  309. package/src/plots/function-plot.ts +220 -0
  310. package/src/plots/points-plot.ts +103 -0
  311. package/src/plots/stream-lines.ts +160 -0
  312. package/src/plots/traced-path.ts +70 -0
  313. package/src/plots/vector-field.ts +107 -0
  314. package/src/structures/graph-layout.ts +145 -0
  315. package/src/structures/network-graph.ts +291 -0
  316. package/src/structures/sample-space.ts +210 -0
  317. package/src/systems/axes2d.ts +226 -0
  318. package/src/systems/number-line.ts +130 -0
  319. package/src/systems/number-plane.ts +232 -0
  320. package/src/systems/polar-plane.ts +177 -0
  321. package/src/tex/geometry.ts +703 -0
  322. package/src/tex/index.ts +15 -0
  323. package/src/tex/mathjax.ts +82 -0
  324. package/src/tex/matrix.ts +97 -0
  325. package/src/tex/node.ts +74 -0
  326. package/src/tex/tween.ts +308 -0
  327. package/src/tex/typeset.ts +461 -0
  328. package/src/three/axes3d.ts +267 -0
  329. package/src/three/curve-plot3d.ts +146 -0
  330. package/src/three/entries.ts +42 -0
  331. package/src/three/label3d.ts +52 -0
  332. package/src/three/plot-point3d.ts +63 -0
  333. package/src/three/space.ts +92 -0
  334. package/src/three/surface-plot3d.ts +318 -0
  335. package/src/three/vector-arrow3d.ts +88 -0
@@ -0,0 +1,157 @@
1
+ import { component2d, Graphics2D, Types, } from "@motionscript/sdk";
2
+ import { listed, PAINT, PAINT_COMMANDS } from "../kit/component.js";
3
+ import { cartesianMap, lineThrough, resolveInterval } from "../kit/coords.js";
4
+ import { clamp } from "../kit/geometry.js";
5
+ import { drawSystem, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from "../kit/system.js";
6
+ import { formatTick, ticksFor } from "../kit/ticks.js";
7
+ import { along, AXIS_COLOR, drawLabels, drawn, loadFormulas, lerpInterval, readInterval, withoutTips } from "../kit/furniture.js";
8
+ const interval = (initial) => Types.custom(initial, { resolve: readInterval, lerp: lerpInterval });
9
+ /** An x and a y axis's entries: what a number plane is built on too. */
10
+ export const AXES = {
11
+ ...PAINT,
12
+ xRange: interval([-5, 5]),
13
+ yRange: interval([-3, 3]),
14
+ /** The spacing of each axis's ticks; zero picks a tidy one for the axis's length. */
15
+ xStep: Types.number(0, { min: 0 }),
16
+ yStep: Types.number(0, { min: 0 }),
17
+ xScaling: listed(["linear", "log"], "linear", { animatable: false }),
18
+ yScaling: listed(["linear", "log"], "linear", { animatable: false }),
19
+ /** Give a y unit the length of an x unit: `yRange` keeps its centre and takes the span that fits. */
20
+ squareUnits: Types.boolean(false, { animatable: false }),
21
+ ticks: Types.boolean(true, { animatable: false }),
22
+ tickSize: Types.number(10, { min: 0, unit: "px" }),
23
+ labels: Types.boolean(true, { animatable: false }),
24
+ labelSize: Types.number(18, { min: 1, unit: "px" }),
25
+ labelColor: Types.color(AXIS_COLOR),
26
+ fontFamily: Types.text("", { animatable: false }),
27
+ /** A title at the positive end of each axis. */
28
+ xLabel: Types.text("", { animatable: false }),
29
+ yLabel: Types.text("", { animatable: false }),
30
+ };
31
+ /** The axes' own commands, beside a shape's paints. */
32
+ export const AXES_COMMANDS = {
33
+ ...PAINT_COMMANDS,
34
+ /** Animate the window of values the axes show: a pan when a range's ends move alike, a zoom when they do not. */
35
+ rangeTo: { args: ["xRange", "yRange"] },
36
+ };
37
+ /** What axes declare before they are laid out: their face, and MathJax for a title written as a formula. */
38
+ export function loadAxes(loader, s) {
39
+ if (s.fontFamily !== "")
40
+ loader.font(s.fontFamily);
41
+ loadFormulas(loader, [s.xLabel, s.yLabel]);
42
+ }
43
+ /** How the axes' values land on a plot area. */
44
+ export function axesMap(area, s) {
45
+ const xRange = resolveInterval(s.xRange, s.xScaling);
46
+ let yRange = resolveInterval(s.yRange, s.yScaling);
47
+ const width = area.maxX - area.minX;
48
+ if (s.squareUnits && s.xScaling === "linear" && s.yScaling === "linear" && width > 0) {
49
+ const span = ((xRange[1] - xRange[0]) * (area.maxY - area.minY)) / width;
50
+ const centre = (yRange[0] + yRange[1]) / 2;
51
+ if (span > 0)
52
+ yRange = [centre - span / 2, centre + span / 2];
53
+ }
54
+ return cartesianMap({ xRange, yRange, area, xScaling: s.xScaling, yScaling: s.yScaling });
55
+ }
56
+ /** The two axes as laid out on `map`: where each runs, what it marks, and where the other crosses it. */
57
+ export function axesOf(map, s) {
58
+ const [xMin, xMax] = map.xRange;
59
+ const [yMin, yMax] = map.yRange;
60
+ // An axis sits on the other's zero, or on its near edge when zero is out of range or it is logarithmic.
61
+ const crossX = s.xScaling === "log" ? xMin : clamp(0, xMin, xMax);
62
+ const crossY = s.yScaling === "log" ? yMin : clamp(0, yMin, yMax);
63
+ const xFrom = map.toPoint(xMin, crossY);
64
+ const xTo = map.toPoint(xMax, crossY);
65
+ const yFrom = map.toPoint(crossX, yMin);
66
+ const yTo = map.toPoint(crossX, yMax);
67
+ return [
68
+ {
69
+ from: xFrom,
70
+ to: xTo,
71
+ line: lineThrough(map, xMin, crossY, xMax, crossY),
72
+ marks: ticksFor(map.xRange, s.xStep, Math.hypot(xTo.x - xFrom.x, xTo.y - xFrom.y), s.xScaling),
73
+ crossing: crossX,
74
+ at: (value) => map.toPoint(value, crossY),
75
+ },
76
+ {
77
+ from: yFrom,
78
+ to: yTo,
79
+ line: lineThrough(map, crossX, yMin, crossX, yMax),
80
+ marks: ticksFor(map.yRange, s.yStep, Math.hypot(yTo.x - yFrom.x, yTo.y - yFrom.y), s.yScaling),
81
+ crossing: crossY,
82
+ at: (value) => map.toPoint(crossX, value),
83
+ },
84
+ ];
85
+ }
86
+ /** What the axes draw of themselves on `map`, over what `backdrop` draws behind them (a number plane's grid). */
87
+ export function axesFurniture(map, s, backdrop = () => []) {
88
+ const stroke = s.stroke;
89
+ const { start, end } = s;
90
+ const [x, y] = axesOf(map, s);
91
+ const parts = [...backdrop(x, y)];
92
+ if (stroke.length === 0 && !s.labels)
93
+ return parts;
94
+ if (stroke.length > 0) {
95
+ parts.push(new Graphics2D()
96
+ .line({ points: x.line, radius: 0, start, end })
97
+ .line({ points: y.line, radius: 0, start, end })
98
+ .stroke(stroke));
99
+ }
100
+ const half = s.tickSize / 2;
101
+ const gap = half + s.labelSize * 0.35;
102
+ const tickMarks = new Graphics2D();
103
+ const labels = [];
104
+ let ticked = false;
105
+ const mark = (axis, horizontal) => {
106
+ for (const value of axis.marks.values) {
107
+ if (Math.abs(value - axis.crossing) < 1e-9 * Math.max(1, Math.abs(value)))
108
+ continue;
109
+ const at = axis.at(value);
110
+ if (!drawn(along(at, axis.from, axis.to), start, end))
111
+ continue;
112
+ if (s.ticks && half > 0) {
113
+ tickMarks.line({
114
+ points: horizontal
115
+ ? [{ x: at.x, y: at.y - half }, { x: at.x, y: at.y + half }]
116
+ : [{ x: at.x - half, y: at.y }, { x: at.x + half, y: at.y }],
117
+ radius: 0,
118
+ });
119
+ ticked = true;
120
+ }
121
+ if (!s.labels)
122
+ continue;
123
+ labels.push(horizontal
124
+ ? { text: formatTick(value, axis.marks.step), at: { x: at.x, y: at.y - gap - s.labelSize / 2 }, align: "center" }
125
+ : { text: formatTick(value, axis.marks.step), at: { x: at.x - gap, y: at.y }, align: "right" });
126
+ }
127
+ };
128
+ mark(x, true);
129
+ mark(y, false);
130
+ if (ticked && stroke.length > 0)
131
+ parts.push(tickMarks.stroke(withoutTips(stroke)));
132
+ if (s.xLabel !== "" && end >= 1) {
133
+ labels.push({ text: s.xLabel, at: { x: x.to.x, y: x.to.y + gap + s.labelSize / 2 }, align: "right" });
134
+ }
135
+ if (s.yLabel !== "" && end >= 1) {
136
+ labels.push({ text: s.yLabel, at: { x: y.to.x + gap, y: y.to.y - s.labelSize / 2 }, align: "left" });
137
+ }
138
+ parts.push(...drawLabels(labels, { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor }));
139
+ return parts;
140
+ }
141
+ /**
142
+ * An x and a y axis, crossing at the origin while it is in range and at the
143
+ * nearest edge otherwise. Children sit in its graph coordinates.
144
+ */
145
+ export const Axes2d = component2d({
146
+ key: "axes2d",
147
+ state: AXES,
148
+ defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: "center", endCap: "triangle", capScale: 5 } },
149
+ load: (loader, s) => loadAxes(loader, s),
150
+ commands: AXES_COMMANDS,
151
+ provide: (s) => systemProvides(s),
152
+ measure: (_measurer, s) => systemSize(s),
153
+ layout: (box, s, children) => systemLayout(box, s, children, axesMap),
154
+ plane: (box, s) => systemOpenPlane(box, s, axesMap),
155
+ render: (ctx, s) => drawSystem(ctx, s, systemMap(ctx.size, s, axesMap), (map) => axesFurniture(map, s)),
156
+ });
157
+ //# sourceMappingURL=axes2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axes2d.js","sourceRoot":"","sources":["../../src/systems/axes2d.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,UAAU,EACV,KAAK,GAmBR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAuD,MAAM,eAAe,CAAC;AAChI,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,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QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IACjC,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC;IACrE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC;IACnD,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;CAC1G,CAAC,CAAC","sourcesContent":["import {\n component2d,\n Graphics2D,\n Types,\n type Color,\n type Extents,\n type InsetsResolved,\n type Loader,\n type NodeOf,\n type NormalizedColor,\n type PaintProps,\n type StrokeResolved,\n type Values,\n type Vector2,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n} from \"@motionscript/sdk\";\nimport { listed, PAINT, PAINT_COMMANDS } from \"../kit/component\";\nimport { cartesianMap, lineThrough, resolveInterval, type AxisScaling, type CoordinateMap, type Interval } from \"../kit/coords\";\nimport { clamp } from \"../kit/geometry\";\nimport { drawSystem, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from \"../kit/system\";\nimport { formatTick, ticksFor, type Ticks } from \"../kit/ticks\";\nimport { along, AXIS_COLOR, drawLabels, drawn, loadFormulas, type Label, lerpInterval, readInterval, withoutTips } from \"../kit/furniture\";\n\nexport interface Axes2dProps extends PaintProps {\n xRange?: Interval;\n yRange?: Interval;\n xStep?: number;\n yStep?: number;\n xScaling?: AxisScaling;\n yScaling?: AxisScaling;\n squareUnits?: boolean;\n ticks?: boolean;\n tickSize?: number;\n labels?: boolean;\n labelSize?: number;\n labelColor?: Color;\n fontFamily?: string;\n xLabel?: string;\n yLabel?: string;\n}\n\n/** One axis, as its furniture is drawn: its line's ends and what is marked along it. */\nexport interface AxisLayout {\n from: Vector2;\n to: Vector2;\n /** The pixel points that draw its line: its two ends, or more where the system's map bends it. */\n line: Vector2[];\n marks: Ticks;\n /** The value on this axis the other one crosses at, which is left unmarked. */\n crossing: number;\n /** A mark's pixel point. */\n at(value: number): Vector2;\n}\n\nconst interval = (initial: Interval) => Types.custom<Interval>(initial, { resolve: readInterval, lerp: lerpInterval });\n\n/** An x and a y axis's entries: what a number plane is built on too. */\nexport const AXES = {\n ...PAINT,\n xRange: interval([-5, 5]),\n yRange: interval([-3, 3]),\n /** The spacing of each axis's ticks; zero picks a tidy one for the axis's length. */\n xStep: Types.number(0, { min: 0 }),\n yStep: Types.number(0, { min: 0 }),\n xScaling: listed([\"linear\", \"log\"], \"linear\", { animatable: false }),\n yScaling: listed([\"linear\", \"log\"], \"linear\", { animatable: false }),\n /** Give a y unit the length of an x unit: `yRange` keeps its centre and takes the span that fits. */\n squareUnits: Types.boolean(false, { animatable: false }),\n ticks: Types.boolean(true, { animatable: false }),\n tickSize: Types.number(10, { min: 0, unit: \"px\" }),\n labels: Types.boolean(true, { animatable: false }),\n labelSize: Types.number(18, { min: 1, unit: \"px\" }),\n labelColor: Types.color(AXIS_COLOR),\n fontFamily: Types.text(\"\", { animatable: false }),\n /** A title at the positive end of each axis. */\n xLabel: Types.text(\"\", { animatable: false }),\n yLabel: Types.text(\"\", { animatable: false }),\n};\n\n/** The axes' own commands, beside a shape's paints. */\nexport const AXES_COMMANDS = {\n ...PAINT_COMMANDS,\n /** Animate the window of values the axes show: a pan when a range's ends move alike, a zoom when they do not. */\n rangeTo: { args: [\"xRange\", \"yRange\"] as const },\n};\n\n/** What axes are drawn from: their own entries, as a number plane's helpers read them too. */\nexport type AxesValues = Values<typeof AXES> & { readonly padding: InsetsResolved; readonly clip: boolean };\n\n/** What axes declare before they are laid out: their face, and MathJax for a title written as a formula. */\nexport function loadAxes(loader: Loader, s: AxesValues): void {\n if (s.fontFamily !== \"\") loader.font(s.fontFamily);\n loadFormulas(loader, [s.xLabel, s.yLabel]);\n}\n\n/** How the axes' values land on a plot area. */\nexport function axesMap(area: Extents, s: AxesValues): CoordinateMap {\n const xRange = resolveInterval(s.xRange, s.xScaling);\n let yRange = resolveInterval(s.yRange, s.yScaling);\n const width = area.maxX - area.minX;\n if (s.squareUnits && s.xScaling === \"linear\" && s.yScaling === \"linear\" && width > 0) {\n const span = ((xRange[1] - xRange[0]) * (area.maxY - area.minY)) / width;\n const centre = (yRange[0] + yRange[1]) / 2;\n if (span > 0) yRange = [centre - span / 2, centre + span / 2];\n }\n return cartesianMap({ xRange, yRange, area, xScaling: s.xScaling, yScaling: s.yScaling });\n}\n\n/** The two axes as laid out on `map`: where each runs, what it marks, and where the other crosses it. */\nexport function axesOf(map: CoordinateMap, s: AxesValues): [AxisLayout, AxisLayout] {\n const [xMin, xMax] = map.xRange;\n const [yMin, yMax] = map.yRange;\n // An axis sits on the other's zero, or on its near edge when zero is out of range or it is logarithmic.\n const crossX = s.xScaling === \"log\" ? xMin : clamp(0, xMin, xMax);\n const crossY = s.yScaling === \"log\" ? yMin : clamp(0, yMin, yMax);\n const xFrom = map.toPoint(xMin, crossY);\n const xTo = map.toPoint(xMax, crossY);\n const yFrom = map.toPoint(crossX, yMin);\n const yTo = map.toPoint(crossX, yMax);\n return [\n {\n from: xFrom,\n to: xTo,\n line: lineThrough(map, xMin, crossY, xMax, crossY),\n marks: ticksFor(map.xRange, s.xStep, Math.hypot(xTo.x - xFrom.x, xTo.y - xFrom.y), s.xScaling),\n crossing: crossX,\n at: (value) => map.toPoint(value, crossY),\n },\n {\n from: yFrom,\n to: yTo,\n line: lineThrough(map, crossX, yMin, crossX, yMax),\n marks: ticksFor(map.yRange, s.yStep, Math.hypot(yTo.x - yFrom.x, yTo.y - yFrom.y), s.yScaling),\n crossing: crossY,\n at: (value) => map.toPoint(crossX, value),\n },\n ];\n}\n\n/** What the axes draw of themselves on `map`, over what `backdrop` draws behind them (a number plane's grid). */\nexport function axesFurniture(\n map: CoordinateMap,\n s: AxesValues,\n backdrop: (x: AxisLayout, y: AxisLayout) => Graphics2D[] = () => [],\n): Graphics2D[] {\n const stroke = s.stroke as StrokeResolved[];\n const { start, end } = s;\n const [x, y] = axesOf(map, s);\n const parts: Graphics2D[] = [...backdrop(x, y)];\n if (stroke.length === 0 && !s.labels) return parts;\n\n if (stroke.length > 0) {\n parts.push(\n new Graphics2D()\n .line({ points: x.line, radius: 0, start, end })\n .line({ points: y.line, radius: 0, start, end })\n .stroke(stroke),\n );\n }\n\n const half = s.tickSize / 2;\n const gap = half + s.labelSize * 0.35;\n const tickMarks = new Graphics2D();\n const labels: Label[] = [];\n let ticked = false;\n const mark = (axis: AxisLayout, horizontal: boolean): void => {\n for (const value of axis.marks.values) {\n if (Math.abs(value - axis.crossing) < 1e-9 * Math.max(1, Math.abs(value))) continue;\n const at = axis.at(value);\n if (!drawn(along(at, axis.from, axis.to), start, end)) continue;\n if (s.ticks && half > 0) {\n tickMarks.line({\n points: horizontal\n ? [{ x: at.x, y: at.y - half }, { x: at.x, y: at.y + half }]\n : [{ x: at.x - half, y: at.y }, { x: at.x + half, y: at.y }],\n radius: 0,\n });\n ticked = true;\n }\n if (!s.labels) continue;\n labels.push(\n horizontal\n ? { text: formatTick(value, axis.marks.step), at: { x: at.x, y: at.y - gap - s.labelSize / 2 }, align: \"center\" }\n : { text: formatTick(value, axis.marks.step), at: { x: at.x - gap, y: at.y }, align: \"right\" },\n );\n }\n };\n mark(x, true);\n mark(y, false);\n if (ticked && stroke.length > 0) parts.push(tickMarks.stroke(withoutTips(stroke)));\n\n if (s.xLabel !== \"\" && end >= 1) {\n labels.push({ text: s.xLabel, at: { x: x.to.x, y: x.to.y + gap + s.labelSize / 2 }, align: \"right\" });\n }\n if (s.yLabel !== \"\" && end >= 1) {\n labels.push({ text: s.yLabel, at: { x: y.to.x + gap, y: y.to.y - s.labelSize / 2 }, align: \"left\" });\n }\n parts.push(...drawLabels(labels, { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor }));\n return parts;\n}\n\n/**\n * An x and a y axis, crossing at the origin while it is in range and at the\n * nearest edge otherwise. Children sit in its graph coordinates.\n */\nexport const Axes2d = component2d({\n key: \"axes2d\",\n state: AXES,\n defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: \"center\", endCap: \"triangle\", capScale: 5 } },\n load: (loader, s) => loadAxes(loader, s),\n commands: AXES_COMMANDS,\n provide: (s) => systemProvides(s),\n measure: (_measurer, s) => systemSize(s),\n layout: (box, s, children) => systemLayout(box, s, children, axesMap),\n plane: (box, s) => systemOpenPlane(box, s, axesMap),\n render: (ctx, s) => drawSystem(ctx, s, systemMap(ctx.size, s, axesMap), (map) => axesFurniture(map, s)),\n});\n\nexport type Axes2d = NodeOf<typeof Axes2d>;\n"]}
@@ -0,0 +1,101 @@
1
+ import { type Color, type NodeOf, type NormalizedColor, type PaintProps, type StrokeResolved, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke } from "@motionscript/sdk";
2
+ import { type AxisScaling, type Interval } from "../kit/coords.js";
3
+ export interface NumberLineProps extends PaintProps {
4
+ range?: Interval;
5
+ step?: number;
6
+ scaling?: AxisScaling;
7
+ ticks?: boolean;
8
+ tickSize?: number;
9
+ longTicks?: number[];
10
+ labels?: boolean;
11
+ labelExclude?: number[];
12
+ labelSide?: "below" | "above";
13
+ labelSize?: number;
14
+ labelColor?: Color;
15
+ fontFamily?: string;
16
+ }
17
+ /**
18
+ * One axis with ticks and numbers. A child's `x` is a value on the line and its
19
+ * `y` is pixels above it, so a dot or a label sits on a number.
20
+ */
21
+ export declare const NumberLine: import("@motionscript/sdk").Component<"numberLine", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
22
+ range: import("@motionscript/sdk").Type<Interval, Interval, false>;
23
+ /** The spacing of the ticks; zero picks a tidy one for the line's length. */
24
+ step: import("@motionscript/sdk").Type<number, number, false>;
25
+ scaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
26
+ ticks: import("@motionscript/sdk").Type<boolean, boolean, false>;
27
+ tickSize: import("@motionscript/sdk").Type<number, number, false>;
28
+ /** Values whose ticks are drawn twice as long. */
29
+ longTicks: import("@motionscript/sdk").Type<number[], number[], false>;
30
+ labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
31
+ labelExclude: import("@motionscript/sdk").Type<number[], number[], false>;
32
+ labelSide: import("@motionscript/sdk").Type<"below" | "above", "below" | "above", false>;
33
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
34
+ labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
35
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
36
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
37
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
38
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
39
+ start: import("@motionscript/sdk").Type<number, number, false>;
40
+ end: import("@motionscript/sdk").Type<number, number, false>;
41
+ }>, {
42
+ readonly rangeTo: readonly ["range"];
43
+ readonly fillTo: readonly ["fill"];
44
+ readonly strokeTo: readonly ["stroke"];
45
+ readonly shadowTo: readonly ["shadow"];
46
+ readonly progressTo: readonly ["start", "end"];
47
+ readonly flash: {
48
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
49
+ };
50
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
51
+ range: import("@motionscript/sdk").Type<Interval, Interval, false>;
52
+ /** The spacing of the ticks; zero picks a tidy one for the line's length. */
53
+ step: import("@motionscript/sdk").Type<number, number, false>;
54
+ scaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
55
+ ticks: import("@motionscript/sdk").Type<boolean, boolean, false>;
56
+ tickSize: import("@motionscript/sdk").Type<number, number, false>;
57
+ /** Values whose ticks are drawn twice as long. */
58
+ longTicks: import("@motionscript/sdk").Type<number[], number[], false>;
59
+ labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
60
+ labelExclude: import("@motionscript/sdk").Type<number[], number[], false>;
61
+ labelSide: import("@motionscript/sdk").Type<"below" | "above", "below" | "above", false>;
62
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
63
+ labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
64
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
65
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
66
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
67
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
68
+ start: import("@motionscript/sdk").Type<number, number, false>;
69
+ end: import("@motionscript/sdk").Type<number, number, false>;
70
+ }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
71
+ range: import("@motionscript/sdk").Type<Interval, Interval, false>;
72
+ /** The spacing of the ticks; zero picks a tidy one for the line's length. */
73
+ step: import("@motionscript/sdk").Type<number, number, false>;
74
+ scaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
75
+ ticks: import("@motionscript/sdk").Type<boolean, boolean, false>;
76
+ tickSize: import("@motionscript/sdk").Type<number, number, false>;
77
+ /** Values whose ticks are drawn twice as long. */
78
+ longTicks: import("@motionscript/sdk").Type<number[], number[], false>;
79
+ labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
80
+ labelExclude: import("@motionscript/sdk").Type<number[], number[], false>;
81
+ labelSide: import("@motionscript/sdk").Type<"below" | "above", "below" | "above", false>;
82
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
83
+ labelColor: import("@motionscript/sdk").Type<Color, NormalizedColor, false>;
84
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
85
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
86
+ stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
87
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
88
+ start: import("@motionscript/sdk").Type<number, number, false>;
89
+ end: import("@motionscript/sdk").Type<number, number, false>;
90
+ }>, {
91
+ readonly rangeTo: readonly ["range"];
92
+ readonly fillTo: readonly ["fill"];
93
+ readonly strokeTo: readonly ["stroke"];
94
+ readonly shadowTo: readonly ["shadow"];
95
+ readonly progressTo: readonly ["start", "end"];
96
+ readonly flash: {
97
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
98
+ };
99
+ }, _Node2D<_Node2DProps>>>>;
100
+ export type NumberLine = NodeOf<typeof NumberLine>;
101
+ //# sourceMappingURL=number-line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-line.d.ts","sourceRoot":"","sources":["../../src/systems/number-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,KAAK,EAEV,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,cAAc,EAInB,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,EACtC,KAAK,MAAM,IAAI,OAAO,EACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAiC,KAAK,WAAW,EAAsB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKnH,MAAM,WAAW,eAAgB,SAAQ,UAAU;IAC/C,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAsBD;;;GAGG;AACH,eAAO,MAAM,UAAU;;IArBnB,6EAA6E;;;;;IAK7E,kDAAkD;;;;;;;;;;;;;;;;;;;;;;;;IALlD,6EAA6E;;;;;IAK7E,kDAAkD;;;;;;;;;;;;;;;IALlD,6EAA6E;;;;;IAK7E,kDAAkD;;;;;;;;;;;;;;;;;;;;;;2BAiCpD,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { component2d, Graphics2D, Types, } from "@motionscript/sdk";
2
+ import { listed, PAINT, PAINT_COMMANDS } from "../kit/component.js";
3
+ import { cartesianMap, resolveInterval } from "../kit/coords.js";
4
+ import { along, AXIS_COLOR, drawLabels, drawn, lerpInterval, readInterval, withoutTips } from "../kit/furniture.js";
5
+ import { drawSystem, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from "../kit/system.js";
6
+ import { formatTick, ticksFor } from "../kit/ticks.js";
7
+ const state = {
8
+ ...PAINT,
9
+ range: Types.custom([-5, 5], { resolve: readInterval, lerp: lerpInterval }),
10
+ /** The spacing of the ticks; zero picks a tidy one for the line's length. */
11
+ step: Types.number(0, { min: 0 }),
12
+ scaling: listed(["linear", "log"], "linear", { animatable: false }),
13
+ ticks: Types.boolean(true, { animatable: false }),
14
+ tickSize: Types.number(12, { min: 0, unit: "px" }),
15
+ /** Values whose ticks are drawn twice as long. */
16
+ longTicks: Types.custom([], { animatable: false }),
17
+ labels: Types.boolean(true, { animatable: false }),
18
+ labelExclude: Types.custom([], { animatable: false }),
19
+ labelSide: listed(["below", "above"], "below", { animatable: false }),
20
+ labelSize: Types.number(18, { min: 1, unit: "px" }),
21
+ labelColor: Types.color(AXIS_COLOR),
22
+ fontFamily: Types.text("", { animatable: false }),
23
+ };
24
+ /**
25
+ * One axis with ticks and numbers. A child's `x` is a value on the line and its
26
+ * `y` is pixels above it, so a dot or a label sits on a number.
27
+ */
28
+ export const NumberLine = component2d({
29
+ key: "numberLine",
30
+ state,
31
+ defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: "center" } },
32
+ load: (loader, s) => {
33
+ if (s.fontFamily !== "")
34
+ loader.font(s.fontFamily);
35
+ },
36
+ commands: {
37
+ ...PAINT_COMMANDS,
38
+ /** Animate the span of values the line shows: a pan when both ends move alike, a zoom when they do not. */
39
+ rangeTo: { args: ["range"] },
40
+ },
41
+ provide: (s) => systemProvides(s),
42
+ measure: (_measurer, s) => systemSize(s),
43
+ layout: (box, s, children) => systemLayout(box, s, children, lineMap),
44
+ plane: (box, s) => systemOpenPlane(box, s, lineMap),
45
+ render: (ctx, s) => drawSystem(ctx, s, systemMap(ctx.size, s, lineMap), (map) => lineFurniture(map, s)),
46
+ });
47
+ function lineMap(area, s) {
48
+ return cartesianMap({
49
+ xRange: resolveInterval(s.range, s.scaling),
50
+ yRange: [area.minY, area.maxY],
51
+ area,
52
+ xScaling: s.scaling,
53
+ });
54
+ }
55
+ function lineFurniture(map, s) {
56
+ const stroke = s.stroke;
57
+ const { start, end } = s;
58
+ const [min, max] = map.xRange;
59
+ const from = map.toPoint(min, 0);
60
+ const to = map.toPoint(max, 0);
61
+ const parts = [];
62
+ if (stroke.length > 0)
63
+ parts.push(new Graphics2D().line({ points: [from, to], radius: 0, start, end }).stroke(stroke));
64
+ const marks = ticksFor(map.xRange, s.step, to.x - from.x, s.scaling);
65
+ const sign = s.labelSide === "below" ? -1 : 1;
66
+ const tickMarks = new Graphics2D();
67
+ const labels = [];
68
+ let ticked = false;
69
+ for (const value of marks.values) {
70
+ const at = map.toPoint(value, 0);
71
+ if (!drawn(along(at, from, to), start, end))
72
+ continue;
73
+ const half = s.longTicks.includes(value) ? s.tickSize : s.tickSize / 2;
74
+ if (s.ticks && half > 0) {
75
+ tickMarks.line({ points: [{ x: at.x, y: at.y - half }, { x: at.x, y: at.y + half }], radius: 0 });
76
+ ticked = true;
77
+ }
78
+ if (s.labels && !s.labelExclude.includes(value)) {
79
+ labels.push({
80
+ text: formatTick(value, marks.step),
81
+ at: { x: at.x, y: at.y + sign * (s.tickSize / 2 + s.labelSize * 0.9) },
82
+ align: "center",
83
+ });
84
+ }
85
+ }
86
+ if (ticked && stroke.length > 0)
87
+ parts.push(tickMarks.stroke(withoutTips(stroke)));
88
+ parts.push(...drawLabels(labels, { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor }));
89
+ return parts;
90
+ }
91
+ //# sourceMappingURL=number-line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-line.js","sourceRoot":"","sources":["../../src/systems/number-line.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,UAAU,EACV,KAAK,GAiBR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,eAAe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AClG,MAAM,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC;gBACnC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,EAAE;gBACtE,KAAK,EAAE,QAAQ;aAClB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IACD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACnF,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,UAA6B,EAAE,CAAC,CAAC,CAAC;IAC/H,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import {\n component2d,\n Graphics2D,\n Types,\n type Color,\n type Extents,\n type NodeOf,\n type NormalizedColor,\n type PaintProps,\n type StrokeResolved,\n type Values,\n type Vector2,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n} from \"@motionscript/sdk\";\nimport { listed, PAINT, PAINT_COMMANDS } from \"../kit/component\";\nimport { cartesianMap, resolveInterval, type AxisScaling, type CoordinateMap, type Interval } from \"../kit/coords\";\nimport { along, AXIS_COLOR, drawLabels, drawn, lerpInterval, readInterval, withoutTips, type Label } from \"../kit/furniture\";\nimport { drawSystem, systemLayout, systemMap, systemOpenPlane, systemProvides, systemSize } from \"../kit/system\";\nimport { formatTick, ticksFor } from \"../kit/ticks\";\n\nexport interface NumberLineProps extends PaintProps {\n range?: Interval;\n step?: number;\n scaling?: AxisScaling;\n ticks?: boolean;\n tickSize?: number;\n longTicks?: number[];\n labels?: boolean;\n labelExclude?: number[];\n labelSide?: \"below\" | \"above\";\n labelSize?: number;\n labelColor?: Color;\n fontFamily?: string;\n}\n\nconst state = {\n ...PAINT,\n range: Types.custom<Interval>([-5, 5], { resolve: readInterval, lerp: lerpInterval }),\n /** The spacing of the ticks; zero picks a tidy one for the line's length. */\n step: Types.number(0, { min: 0 }),\n scaling: listed([\"linear\", \"log\"], \"linear\", { animatable: false }),\n ticks: Types.boolean(true, { animatable: false }),\n tickSize: Types.number(12, { min: 0, unit: \"px\" }),\n /** Values whose ticks are drawn twice as long. */\n longTicks: Types.custom<number[]>([], { animatable: false }),\n labels: Types.boolean(true, { animatable: false }),\n labelExclude: Types.custom<number[]>([], { animatable: false }),\n labelSide: listed([\"below\", \"above\"], \"below\", { animatable: false }),\n labelSize: Types.number(18, { min: 1, unit: \"px\" }),\n labelColor: Types.color(AXIS_COLOR),\n fontFamily: Types.text(\"\", { animatable: false }),\n};\n\ntype LineValues = Values<typeof state>;\n\n/**\n * One axis with ticks and numbers. A child's `x` is a value on the line and its\n * `y` is pixels above it, so a dot or a label sits on a number.\n */\nexport const NumberLine = component2d({\n key: \"numberLine\",\n state,\n defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: \"center\" } },\n load: (loader, s) => {\n if (s.fontFamily !== \"\") loader.font(s.fontFamily);\n },\n commands: {\n ...PAINT_COMMANDS,\n /** Animate the span of values the line shows: a pan when both ends move alike, a zoom when they do not. */\n rangeTo: { args: [\"range\"] },\n },\n provide: (s) => systemProvides(s),\n measure: (_measurer, s) => systemSize(s),\n layout: (box, s, children) => systemLayout(box, s, children, lineMap),\n plane: (box, s) => systemOpenPlane(box, s, lineMap),\n render: (ctx, s) => drawSystem(ctx, s, systemMap(ctx.size, s, lineMap), (map) => lineFurniture(map, s)),\n});\n\nexport type NumberLine = NodeOf<typeof NumberLine>;\n\nfunction lineMap(area: Extents, s: LineValues): CoordinateMap {\n return cartesianMap({\n xRange: resolveInterval(s.range, s.scaling),\n yRange: [area.minY, area.maxY],\n area,\n xScaling: s.scaling,\n });\n}\n\nfunction lineFurniture(map: CoordinateMap, s: LineValues): Graphics2D[] {\n const stroke = s.stroke as StrokeResolved[];\n const { start, end } = s;\n const [min, max] = map.xRange;\n const from = map.toPoint(min, 0);\n const to = map.toPoint(max, 0);\n const parts: Graphics2D[] = [];\n if (stroke.length > 0) parts.push(new Graphics2D().line({ points: [from, to], radius: 0, start, end }).stroke(stroke));\n\n const marks = ticksFor(map.xRange, s.step, to.x - from.x, s.scaling);\n const sign = s.labelSide === \"below\" ? -1 : 1;\n const tickMarks = new Graphics2D();\n const labels: Label[] = [];\n let ticked = false;\n for (const value of marks.values) {\n const at: Vector2 = map.toPoint(value, 0);\n if (!drawn(along(at, from, to), start, end)) continue;\n const half = s.longTicks.includes(value) ? s.tickSize : s.tickSize / 2;\n if (s.ticks && half > 0) {\n tickMarks.line({ points: [{ x: at.x, y: at.y - half }, { x: at.x, y: at.y + half }], radius: 0 });\n ticked = true;\n }\n if (s.labels && !s.labelExclude.includes(value)) {\n labels.push({\n text: formatTick(value, marks.step),\n at: { x: at.x, y: at.y + sign * (s.tickSize / 2 + s.labelSize * 0.9) },\n align: \"center\",\n });\n }\n }\n if (ticked && stroke.length > 0) parts.push(tickMarks.stroke(withoutTips(stroke)));\n parts.push(...drawLabels(labels, { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor }));\n return parts;\n}\n"]}
@@ -0,0 +1,168 @@
1
+ import { type Extents, type NodeOf, type Stroke, type StrokeResolved, type Color as _Color, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type NormalizedColor as _NormalizedColor, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved } from "@motionscript/sdk";
2
+ import { type CoordinateMap, type Matrix2 } from "../kit/coords.js";
3
+ import { type PlotSource } from "../kit/source.js";
4
+ import { type Axes2dProps, type AxesValues } from "./axes2d.js";
5
+ export interface NumberPlaneProps extends Axes2dProps {
6
+ grid?: boolean;
7
+ gridStroke?: Stroke;
8
+ minorStroke?: Stroke;
9
+ minorDivisions?: number;
10
+ matrix?: Matrix2 | readonly (readonly number[])[];
11
+ warp?: string | PlotSource;
12
+ ghost?: boolean;
13
+ }
14
+ type PlaneValues = AxesValues & {
15
+ readonly grid: boolean;
16
+ readonly gridStroke: StrokeResolved[];
17
+ readonly minorStroke: StrokeResolved[];
18
+ readonly minorDivisions: number;
19
+ readonly matrix: Matrix2;
20
+ readonly warp: PlotSource;
21
+ readonly ghost: boolean;
22
+ };
23
+ /**
24
+ * Axes over a full grid, with square units unless told otherwise: the plane
25
+ * vectors and transformations are drawn on. Its `matrix` shears, turns or
26
+ * squeezes the whole plane about its origin, and its `warp` bends it by a
27
+ * function of its own points; the grid, the axes and everything on the plane
28
+ * go with it.
29
+ */
30
+ export declare const NumberPlane: import("@motionscript/sdk").Component<"numberPlane", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
31
+ grid: import("@motionscript/sdk").Type<boolean, boolean, false>;
32
+ /** The line at every tick. */
33
+ gridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
34
+ /** The lines between ticks. */
35
+ minorStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
36
+ /** How many parts the space between two ticks is cut into; one draws no line between them. */
37
+ minorDivisions: import("@motionscript/sdk").Type<number, number, false>;
38
+ /** A linear map of the plane, row by row: `[a, b, c, d]` sends `(x, y)` to `(ax + by, cx + dy)`. */
39
+ matrix: import("@motionscript/sdk").Type<Matrix2 | readonly (readonly number[])[], Matrix2, false>;
40
+ /**
41
+ * Where each point of the plane is sent, two parts in x and y:
42
+ * `(x + sin(y), y + sin(x))`. Empty leaves the plane flat.
43
+ */
44
+ warp: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
45
+ /** Leave the plane as it was, faintly, behind one that has been transformed or warped. */
46
+ ghost: import("@motionscript/sdk").Type<boolean, boolean, false>;
47
+ xRange: import("@motionscript/sdk").Type<import("../index.js").Interval, import("../index.js").Interval, false>;
48
+ yRange: import("@motionscript/sdk").Type<import("../index.js").Interval, import("../index.js").Interval, false>;
49
+ xStep: import("@motionscript/sdk").Type<number, number, false>;
50
+ yStep: import("@motionscript/sdk").Type<number, number, false>;
51
+ xScaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
52
+ yScaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
53
+ squareUnits: import("@motionscript/sdk").Type<boolean, boolean, false>;
54
+ ticks: import("@motionscript/sdk").Type<boolean, boolean, false>;
55
+ tickSize: import("@motionscript/sdk").Type<number, number, false>;
56
+ labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
57
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
58
+ labelColor: import("@motionscript/sdk").Type<_Color, _NormalizedColor, false>;
59
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
60
+ xLabel: import("@motionscript/sdk").Type<string, string, false>;
61
+ yLabel: import("@motionscript/sdk").Type<string, string, false>;
62
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
63
+ stroke: import("@motionscript/sdk").Attribute<Stroke, StrokeResolved[]>;
64
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
65
+ start: import("@motionscript/sdk").Type<number, number, false>;
66
+ end: import("@motionscript/sdk").Type<number, number, false>;
67
+ }>, {
68
+ readonly transformTo: readonly ["matrix"];
69
+ readonly warpTo: readonly ["warp"];
70
+ readonly rangeTo: readonly ["xRange", "yRange"];
71
+ readonly fillTo: readonly ["fill"];
72
+ readonly strokeTo: readonly ["stroke"];
73
+ readonly shadowTo: readonly ["shadow"];
74
+ readonly progressTo: readonly ["start", "end"];
75
+ readonly flash: {
76
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
77
+ };
78
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
79
+ grid: import("@motionscript/sdk").Type<boolean, boolean, false>;
80
+ /** The line at every tick. */
81
+ gridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
82
+ /** The lines between ticks. */
83
+ minorStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
84
+ /** How many parts the space between two ticks is cut into; one draws no line between them. */
85
+ minorDivisions: import("@motionscript/sdk").Type<number, number, false>;
86
+ /** A linear map of the plane, row by row: `[a, b, c, d]` sends `(x, y)` to `(ax + by, cx + dy)`. */
87
+ matrix: import("@motionscript/sdk").Type<Matrix2 | readonly (readonly number[])[], Matrix2, false>;
88
+ /**
89
+ * Where each point of the plane is sent, two parts in x and y:
90
+ * `(x + sin(y), y + sin(x))`. Empty leaves the plane flat.
91
+ */
92
+ warp: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
93
+ /** Leave the plane as it was, faintly, behind one that has been transformed or warped. */
94
+ ghost: import("@motionscript/sdk").Type<boolean, boolean, false>;
95
+ xRange: import("@motionscript/sdk").Type<import("../index.js").Interval, import("../index.js").Interval, false>;
96
+ yRange: import("@motionscript/sdk").Type<import("../index.js").Interval, import("../index.js").Interval, false>;
97
+ xStep: import("@motionscript/sdk").Type<number, number, false>;
98
+ yStep: import("@motionscript/sdk").Type<number, number, false>;
99
+ xScaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
100
+ yScaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
101
+ squareUnits: import("@motionscript/sdk").Type<boolean, boolean, false>;
102
+ ticks: import("@motionscript/sdk").Type<boolean, boolean, false>;
103
+ tickSize: import("@motionscript/sdk").Type<number, number, false>;
104
+ labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
105
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
106
+ labelColor: import("@motionscript/sdk").Type<_Color, _NormalizedColor, false>;
107
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
108
+ xLabel: import("@motionscript/sdk").Type<string, string, false>;
109
+ yLabel: import("@motionscript/sdk").Type<string, string, false>;
110
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
111
+ stroke: import("@motionscript/sdk").Attribute<Stroke, StrokeResolved[]>;
112
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
113
+ start: import("@motionscript/sdk").Type<number, number, false>;
114
+ end: import("@motionscript/sdk").Type<number, number, false>;
115
+ }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
116
+ grid: import("@motionscript/sdk").Type<boolean, boolean, false>;
117
+ /** The line at every tick. */
118
+ gridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
119
+ /** The lines between ticks. */
120
+ minorStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
121
+ /** How many parts the space between two ticks is cut into; one draws no line between them. */
122
+ minorDivisions: import("@motionscript/sdk").Type<number, number, false>;
123
+ /** A linear map of the plane, row by row: `[a, b, c, d]` sends `(x, y)` to `(ax + by, cx + dy)`. */
124
+ matrix: import("@motionscript/sdk").Type<Matrix2 | readonly (readonly number[])[], Matrix2, false>;
125
+ /**
126
+ * Where each point of the plane is sent, two parts in x and y:
127
+ * `(x + sin(y), y + sin(x))`. Empty leaves the plane flat.
128
+ */
129
+ warp: import("@motionscript/sdk").Type<string | PlotSource, PlotSource, false>;
130
+ /** Leave the plane as it was, faintly, behind one that has been transformed or warped. */
131
+ ghost: import("@motionscript/sdk").Type<boolean, boolean, false>;
132
+ xRange: import("@motionscript/sdk").Type<import("../index.js").Interval, import("../index.js").Interval, false>;
133
+ yRange: import("@motionscript/sdk").Type<import("../index.js").Interval, import("../index.js").Interval, false>;
134
+ xStep: import("@motionscript/sdk").Type<number, number, false>;
135
+ yStep: import("@motionscript/sdk").Type<number, number, false>;
136
+ xScaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
137
+ yScaling: import("@motionscript/sdk").Type<"linear" | "log", "linear" | "log", false>;
138
+ squareUnits: import("@motionscript/sdk").Type<boolean, boolean, false>;
139
+ ticks: import("@motionscript/sdk").Type<boolean, boolean, false>;
140
+ tickSize: import("@motionscript/sdk").Type<number, number, false>;
141
+ labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
142
+ labelSize: import("@motionscript/sdk").Type<number, number, false>;
143
+ labelColor: import("@motionscript/sdk").Type<_Color, _NormalizedColor, false>;
144
+ fontFamily: import("@motionscript/sdk").Type<string, string, false>;
145
+ xLabel: import("@motionscript/sdk").Type<string, string, false>;
146
+ yLabel: import("@motionscript/sdk").Type<string, string, false>;
147
+ fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
148
+ stroke: import("@motionscript/sdk").Attribute<Stroke, StrokeResolved[]>;
149
+ shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
150
+ start: import("@motionscript/sdk").Type<number, number, false>;
151
+ end: import("@motionscript/sdk").Type<number, number, false>;
152
+ }>, {
153
+ readonly transformTo: readonly ["matrix"];
154
+ readonly warpTo: readonly ["warp"];
155
+ readonly rangeTo: readonly ["xRange", "yRange"];
156
+ readonly fillTo: readonly ["fill"];
157
+ readonly strokeTo: readonly ["stroke"];
158
+ readonly shadowTo: readonly ["shadow"];
159
+ readonly progressTo: readonly ["start", "end"];
160
+ readonly flash: {
161
+ readonly portion: import("@motionscript/sdk").Type<number, number, false>;
162
+ };
163
+ }, _Node2D<_Node2DProps>>>>;
164
+ export type NumberPlane = NodeOf<typeof NumberPlane>;
165
+ /** The plane's map on a plot area: the flat one, sent through its matrix and its warp. */
166
+ export declare function planeMap(area: Extents, s: PlaneValues): CoordinateMap;
167
+ export {};
168
+ //# sourceMappingURL=number-plane.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-plane.d.ts","sourceRoot":"","sources":["../../src/systems/number-plane.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,cAAc,EAEnB,KAAK,KAAK,IAAI,MAAM,EACpB,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAOH,KAAK,aAAa,EAClB,KAAK,OAAO,EAEf,MAAM,eAAe,CAAC;AAGvB,OAAO,EAA0B,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAiE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAmB,MAAM,UAAU,CAAC;AAE7I,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACjD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;IAClD,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAsBD,KAAK,WAA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