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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +48 -0
  4. package/README.md +385 -3
  5. package/dist/annotate/angle-mark.d.ts +46 -0
  6. package/dist/annotate/angle-mark.d.ts.map +1 -0
  7. package/dist/annotate/angle-mark.js +132 -0
  8. package/dist/annotate/angle-mark.js.map +1 -0
  9. package/dist/annotate/curly-brace.d.ts +46 -0
  10. package/dist/annotate/curly-brace.d.ts.map +1 -0
  11. package/dist/annotate/curly-brace.js +114 -0
  12. package/dist/annotate/curly-brace.js.map +1 -0
  13. package/dist/annotate/emphasis-mark.d.ts +20 -0
  14. package/dist/annotate/emphasis-mark.d.ts.map +1 -0
  15. package/dist/annotate/emphasis-mark.js +81 -0
  16. package/dist/annotate/emphasis-mark.js.map +1 -0
  17. package/dist/browser/THIRD_PARTY_LICENSES.txt +420 -0
  18. package/dist/browser/chunks/chunk-3GJB6AVO.js +2 -0
  19. package/dist/browser/chunks/chunk-3GJB6AVO.js.map +7 -0
  20. package/dist/browser/chunks/chunk-D5WHCVBC.js +2 -0
  21. package/dist/browser/chunks/chunk-D5WHCVBC.js.map +7 -0
  22. package/dist/browser/chunks/chunk-WL4KEX7Y.js +2 -0
  23. package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +7 -0
  24. package/dist/browser/chunks/mathjax-DNP3YRES.js +61 -0
  25. package/dist/browser/chunks/mathjax-DNP3YRES.js.map +7 -0
  26. package/dist/browser/index.js +2 -0
  27. package/dist/browser/index.js.map +7 -0
  28. package/dist/browser/kit.js +2 -0
  29. package/dist/browser/kit.js.map +7 -0
  30. package/dist/browser/manifest.json +30 -0
  31. package/dist/browser/tex.js +2 -0
  32. package/dist/browser/tex.js.map +7 -0
  33. package/dist/engine.d.ts +64 -0
  34. package/dist/engine.d.ts.map +1 -0
  35. package/dist/engine.js +42 -0
  36. package/dist/engine.js.map +1 -0
  37. package/dist/index.d.ts +30 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +30 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/kit/brace.d.ts +8 -0
  42. package/dist/kit/brace.d.ts.map +1 -0
  43. package/dist/kit/brace.js +36 -0
  44. package/dist/kit/brace.js.map +1 -0
  45. package/dist/kit/cache.d.ts +30 -0
  46. package/dist/kit/cache.d.ts.map +1 -0
  47. package/dist/kit/cache.js +53 -0
  48. package/dist/kit/cache.js.map +1 -0
  49. package/dist/kit/contour.d.ts +8 -0
  50. package/dist/kit/contour.d.ts.map +1 -0
  51. package/dist/kit/contour.js +93 -0
  52. package/dist/kit/contour.js.map +1 -0
  53. package/dist/kit/coords.d.ts +69 -0
  54. package/dist/kit/coords.d.ts.map +1 -0
  55. package/dist/kit/coords.js +224 -0
  56. package/dist/kit/coords.js.map +1 -0
  57. package/dist/kit/curve.d.ts +17 -0
  58. package/dist/kit/curve.d.ts.map +1 -0
  59. package/dist/kit/curve.js +22 -0
  60. package/dist/kit/curve.js.map +1 -0
  61. package/dist/kit/equation.d.ts +61 -0
  62. package/dist/kit/equation.d.ts.map +1 -0
  63. package/dist/kit/equation.js +168 -0
  64. package/dist/kit/equation.js.map +1 -0
  65. package/dist/kit/equation3d.d.ts +50 -0
  66. package/dist/kit/equation3d.d.ts.map +1 -0
  67. package/dist/kit/equation3d.js +103 -0
  68. package/dist/kit/equation3d.js.map +1 -0
  69. package/dist/kit/expression.d.ts +35 -0
  70. package/dist/kit/expression.d.ts.map +1 -0
  71. package/dist/kit/expression.js +124 -0
  72. package/dist/kit/expression.js.map +1 -0
  73. package/dist/kit/field-mark.d.ts +58 -0
  74. package/dist/kit/field-mark.d.ts.map +1 -0
  75. package/dist/kit/field-mark.js +129 -0
  76. package/dist/kit/field-mark.js.map +1 -0
  77. package/dist/kit/field.d.ts +14 -0
  78. package/dist/kit/field.d.ts.map +1 -0
  79. package/dist/kit/field.js +46 -0
  80. package/dist/kit/field.js.map +1 -0
  81. package/dist/kit/follow.d.ts +71 -0
  82. package/dist/kit/follow.d.ts.map +1 -0
  83. package/dist/kit/follow.js +159 -0
  84. package/dist/kit/follow.js.map +1 -0
  85. package/dist/kit/furniture.d.ts +30 -0
  86. package/dist/kit/furniture.d.ts.map +1 -0
  87. package/dist/kit/furniture.js +87 -0
  88. package/dist/kit/furniture.js.map +1 -0
  89. package/dist/kit/geometry.d.ts +13 -0
  90. package/dist/kit/geometry.d.ts.map +1 -0
  91. package/dist/kit/geometry.js +54 -0
  92. package/dist/kit/geometry.js.map +1 -0
  93. package/dist/kit/mark.d.ts +47 -0
  94. package/dist/kit/mark.d.ts.map +1 -0
  95. package/dist/kit/mark.js +103 -0
  96. package/dist/kit/mark.js.map +1 -0
  97. package/dist/kit/part-fills.d.ts +23 -0
  98. package/dist/kit/part-fills.d.ts.map +1 -0
  99. package/dist/kit/part-fills.js +46 -0
  100. package/dist/kit/part-fills.js.map +1 -0
  101. package/dist/kit/place.d.ts +18 -0
  102. package/dist/kit/place.d.ts.map +1 -0
  103. package/dist/kit/place.js +68 -0
  104. package/dist/kit/place.js.map +1 -0
  105. package/dist/kit/placement.d.ts +8 -0
  106. package/dist/kit/placement.d.ts.map +1 -0
  107. package/dist/kit/placement.js +8 -0
  108. package/dist/kit/placement.js.map +1 -0
  109. package/dist/kit/sampler.d.ts +17 -0
  110. package/dist/kit/sampler.d.ts.map +1 -0
  111. package/dist/kit/sampler.js +250 -0
  112. package/dist/kit/sampler.js.map +1 -0
  113. package/dist/kit/scale.d.ts +12 -0
  114. package/dist/kit/scale.d.ts.map +1 -0
  115. package/dist/kit/scale.js +37 -0
  116. package/dist/kit/scale.js.map +1 -0
  117. package/dist/kit/source.d.ts +22 -0
  118. package/dist/kit/source.d.ts.map +1 -0
  119. package/dist/kit/source.js +45 -0
  120. package/dist/kit/source.js.map +1 -0
  121. package/dist/kit/system.d.ts +33 -0
  122. package/dist/kit/system.d.ts.map +1 -0
  123. package/dist/kit/system.js +67 -0
  124. package/dist/kit/system.js.map +1 -0
  125. package/dist/kit/ticks.d.ts +19 -0
  126. package/dist/kit/ticks.d.ts.map +1 -0
  127. package/dist/kit/ticks.js +78 -0
  128. package/dist/kit/ticks.js.map +1 -0
  129. package/dist/kit/withdrawn.d.ts +9 -0
  130. package/dist/kit/withdrawn.d.ts.map +1 -0
  131. package/dist/kit/withdrawn.js +9 -0
  132. package/dist/kit/withdrawn.js.map +1 -0
  133. package/dist/marks/curve-area.d.ts +32 -0
  134. package/dist/marks/curve-area.d.ts.map +1 -0
  135. package/dist/marks/curve-area.js +82 -0
  136. package/dist/marks/curve-area.js.map +1 -0
  137. package/dist/marks/drop-lines.d.ts +22 -0
  138. package/dist/marks/drop-lines.d.ts.map +1 -0
  139. package/dist/marks/drop-lines.js +58 -0
  140. package/dist/marks/drop-lines.js.map +1 -0
  141. package/dist/marks/plot-point.d.ts +35 -0
  142. package/dist/marks/plot-point.d.ts.map +1 -0
  143. package/dist/marks/plot-point.js +97 -0
  144. package/dist/marks/plot-point.js.map +1 -0
  145. package/dist/marks/riemann-sum.d.ts +37 -0
  146. package/dist/marks/riemann-sum.d.ts.map +1 -0
  147. package/dist/marks/riemann-sum.js +91 -0
  148. package/dist/marks/riemann-sum.js.map +1 -0
  149. package/dist/marks/tangent-line.d.ts +27 -0
  150. package/dist/marks/tangent-line.d.ts.map +1 -0
  151. package/dist/marks/tangent-line.js +103 -0
  152. package/dist/marks/tangent-line.js.map +1 -0
  153. package/dist/marks/vector-arrow.d.ts +32 -0
  154. package/dist/marks/vector-arrow.d.ts.map +1 -0
  155. package/dist/marks/vector-arrow.js +87 -0
  156. package/dist/marks/vector-arrow.js.map +1 -0
  157. package/dist/nodes.d.ts +35 -0
  158. package/dist/nodes.d.ts.map +1 -0
  159. package/dist/nodes.js +63 -0
  160. package/dist/nodes.js.map +1 -0
  161. package/dist/plots/function-plot.d.ts +67 -0
  162. package/dist/plots/function-plot.d.ts.map +1 -0
  163. package/dist/plots/function-plot.js +215 -0
  164. package/dist/plots/function-plot.js.map +1 -0
  165. package/dist/plots/points-plot.d.ts +28 -0
  166. package/dist/plots/points-plot.d.ts.map +1 -0
  167. package/dist/plots/points-plot.js +99 -0
  168. package/dist/plots/points-plot.js.map +1 -0
  169. package/dist/plots/stream-lines.d.ts +35 -0
  170. package/dist/plots/stream-lines.d.ts.map +1 -0
  171. package/dist/plots/stream-lines.js +141 -0
  172. package/dist/plots/stream-lines.js.map +1 -0
  173. package/dist/plots/traced-path.d.ts +31 -0
  174. package/dist/plots/traced-path.d.ts.map +1 -0
  175. package/dist/plots/traced-path.js +56 -0
  176. package/dist/plots/traced-path.js.map +1 -0
  177. package/dist/plots/vector-field.d.ts +23 -0
  178. package/dist/plots/vector-field.d.ts.map +1 -0
  179. package/dist/plots/vector-field.js +91 -0
  180. package/dist/plots/vector-field.js.map +1 -0
  181. package/dist/structures/graph-layout.d.ts +11 -0
  182. package/dist/structures/graph-layout.d.ts.map +1 -0
  183. package/dist/structures/graph-layout.js +135 -0
  184. package/dist/structures/graph-layout.js.map +1 -0
  185. package/dist/structures/network-graph.d.ts +83 -0
  186. package/dist/structures/network-graph.d.ts.map +1 -0
  187. package/dist/structures/network-graph.js +289 -0
  188. package/dist/structures/network-graph.js.map +1 -0
  189. package/dist/structures/sample-space.d.ts +62 -0
  190. package/dist/structures/sample-space.d.ts.map +1 -0
  191. package/dist/structures/sample-space.js +199 -0
  192. package/dist/structures/sample-space.js.map +1 -0
  193. package/dist/systems/axes2d.d.ts +75 -0
  194. package/dist/systems/axes2d.d.ts.map +1 -0
  195. package/dist/systems/axes2d.js +193 -0
  196. package/dist/systems/axes2d.js.map +1 -0
  197. package/dist/systems/number-line.d.ts +49 -0
  198. package/dist/systems/number-line.d.ts.map +1 -0
  199. package/dist/systems/number-line.js +127 -0
  200. package/dist/systems/number-line.js.map +1 -0
  201. package/dist/systems/number-plane.d.ts +59 -0
  202. package/dist/systems/number-plane.d.ts.map +1 -0
  203. package/dist/systems/number-plane.js +193 -0
  204. package/dist/systems/number-plane.js.map +1 -0
  205. package/dist/systems/polar-plane.d.ts +48 -0
  206. package/dist/systems/polar-plane.d.ts.map +1 -0
  207. package/dist/systems/polar-plane.js +165 -0
  208. package/dist/systems/polar-plane.js.map +1 -0
  209. package/dist/tex/geometry.d.ts +85 -0
  210. package/dist/tex/geometry.d.ts.map +1 -0
  211. package/dist/tex/geometry.js +632 -0
  212. package/dist/tex/geometry.js.map +1 -0
  213. package/dist/tex/index.d.ts +11 -0
  214. package/dist/tex/index.d.ts.map +1 -0
  215. package/dist/tex/index.js +9 -0
  216. package/dist/tex/index.js.map +1 -0
  217. package/dist/tex/mathjax.d.ts +33 -0
  218. package/dist/tex/mathjax.d.ts.map +1 -0
  219. package/dist/tex/mathjax.js +74 -0
  220. package/dist/tex/mathjax.js.map +1 -0
  221. package/dist/tex/matrix.d.ts +31 -0
  222. package/dist/tex/matrix.d.ts.map +1 -0
  223. package/dist/tex/matrix.js +73 -0
  224. package/dist/tex/matrix.js.map +1 -0
  225. package/dist/tex/node.d.ts +215 -0
  226. package/dist/tex/node.d.ts.map +1 -0
  227. package/dist/tex/node.js +595 -0
  228. package/dist/tex/node.js.map +1 -0
  229. package/dist/tex/tween.d.ts +50 -0
  230. package/dist/tex/tween.d.ts.map +1 -0
  231. package/dist/tex/tween.js +253 -0
  232. package/dist/tex/tween.js.map +1 -0
  233. package/dist/three/axes3d.d.ts +87 -0
  234. package/dist/three/axes3d.d.ts.map +1 -0
  235. package/dist/three/axes3d.js +228 -0
  236. package/dist/three/axes3d.js.map +1 -0
  237. package/dist/three/curve-plot3d.d.ts +60 -0
  238. package/dist/three/curve-plot3d.d.ts.map +1 -0
  239. package/dist/three/curve-plot3d.js +143 -0
  240. package/dist/three/curve-plot3d.js.map +1 -0
  241. package/dist/three/label3d.d.ts +11 -0
  242. package/dist/three/label3d.d.ts.map +1 -0
  243. package/dist/three/label3d.js +40 -0
  244. package/dist/three/label3d.js.map +1 -0
  245. package/dist/three/plot-point3d.d.ts +26 -0
  246. package/dist/three/plot-point3d.d.ts.map +1 -0
  247. package/dist/three/plot-point3d.js +60 -0
  248. package/dist/three/plot-point3d.js.map +1 -0
  249. package/dist/three/space.d.ts +28 -0
  250. package/dist/three/space.d.ts.map +1 -0
  251. package/dist/three/space.js +47 -0
  252. package/dist/three/space.js.map +1 -0
  253. package/dist/three/surface-plot3d.d.ts +80 -0
  254. package/dist/three/surface-plot3d.d.ts.map +1 -0
  255. package/dist/three/surface-plot3d.js +290 -0
  256. package/dist/three/surface-plot3d.js.map +1 -0
  257. package/dist/three/vector-arrow3d.d.ts +25 -0
  258. package/dist/three/vector-arrow3d.d.ts.map +1 -0
  259. package/dist/three/vector-arrow3d.js +72 -0
  260. package/dist/three/vector-arrow3d.js.map +1 -0
  261. package/package.json +79 -3
  262. package/registry.json +251 -0
  263. package/src/annotate/angle-mark.ts +147 -0
  264. package/src/annotate/curly-brace.ts +126 -0
  265. package/src/annotate/emphasis-mark.ts +89 -0
  266. package/src/engine.ts +72 -0
  267. package/src/index.ts +29 -0
  268. package/src/kit/brace.ts +37 -0
  269. package/src/kit/cache.ts +61 -0
  270. package/src/kit/contour.ts +94 -0
  271. package/src/kit/coords.ts +278 -0
  272. package/src/kit/curve.ts +29 -0
  273. package/src/kit/equation.ts +181 -0
  274. package/src/kit/equation3d.ts +137 -0
  275. package/src/kit/expression.ts +159 -0
  276. package/src/kit/field-mark.ts +155 -0
  277. package/src/kit/field.ts +50 -0
  278. package/src/kit/follow.ts +203 -0
  279. package/src/kit/furniture.ts +108 -0
  280. package/src/kit/geometry.ts +49 -0
  281. package/src/kit/mark.ts +131 -0
  282. package/src/kit/part-fills.ts +61 -0
  283. package/src/kit/place.ts +101 -0
  284. package/src/kit/placement.ts +8 -0
  285. package/src/kit/sampler.ts +281 -0
  286. package/src/kit/scale.ts +39 -0
  287. package/src/kit/source.ts +57 -0
  288. package/src/kit/system.ts +99 -0
  289. package/src/kit/ticks.ts +85 -0
  290. package/src/kit/withdrawn.ts +8 -0
  291. package/src/marks/curve-area.ts +89 -0
  292. package/src/marks/drop-lines.ts +63 -0
  293. package/src/marks/plot-point.ts +107 -0
  294. package/src/marks/riemann-sum.ts +98 -0
  295. package/src/marks/tangent-line.ts +103 -0
  296. package/src/marks/vector-arrow.ts +98 -0
  297. package/src/nodes.ts +63 -0
  298. package/src/plots/function-plot.ts +236 -0
  299. package/src/plots/points-plot.ts +107 -0
  300. package/src/plots/stream-lines.ts +151 -0
  301. package/src/plots/traced-path.ts +52 -0
  302. package/src/plots/vector-field.ts +88 -0
  303. package/src/structures/graph-layout.ts +145 -0
  304. package/src/structures/network-graph.ts +308 -0
  305. package/src/structures/sample-space.ts +209 -0
  306. package/src/systems/axes2d.ts +217 -0
  307. package/src/systems/number-line.ts +131 -0
  308. package/src/systems/number-plane.ts +203 -0
  309. package/src/systems/polar-plane.ts +176 -0
  310. package/src/tex/geometry.ts +703 -0
  311. package/src/tex/index.ts +14 -0
  312. package/src/tex/mathjax.ts +82 -0
  313. package/src/tex/matrix.ts +75 -0
  314. package/src/tex/node.ts +641 -0
  315. package/src/tex/tween.ts +308 -0
  316. package/src/three/axes3d.ts +240 -0
  317. package/src/three/curve-plot3d.ts +147 -0
  318. package/src/three/label3d.ts +50 -0
  319. package/src/three/plot-point3d.ts +66 -0
  320. package/src/three/space.ts +67 -0
  321. package/src/three/surface-plot3d.ts +323 -0
  322. package/src/three/vector-arrow3d.ts +77 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sample-space.js","sourceRoot":"","sources":["../../src/structures/sample-space.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,aAAa,EACb,OAAO,EACP,OAAO,EACP,UAAU,EACV,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,cAAc,EACd,QAAQ,GAcX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAA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AY,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE;KAC/I,CAAC;IACD,QAAQ,CAAC,GAAG,UAAU,EAAE,GAAG,YAAY,CAAC;GAC5B,WAAW,CAuIvB","sourcesContent":["import {\r\n colorProperty,\r\n command,\r\n fillOps,\r\n Graphics2D,\r\n node,\r\n PaintNode,\r\n property,\r\n strokeProperty,\r\n withdraw,\r\n type AssetScope,\r\n type Color,\r\n type Command,\r\n type CommandArgs,\r\n type Fill,\r\n type FillResolved,\r\n type NodeConfig,\r\n type NormalizedColor,\r\n type PaintProps,\r\n type RenderContext2D,\r\n type Stroke,\r\n type StrokeResolved,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport { braceOutline } from \"../kit/brace\";\r\nimport { declareFormulas, drawLabels, type Label } from \"../kit/furniture\";\r\nimport { lerpFillScale, readFillScale } from \"../kit/scale\";\r\nimport { formatTick } from \"../kit/ticks\";\r\nimport { FILL_PAINT, OUTLINE_TRIM } from \"../kit/withdrawn\";\r\n\r\nexport interface SampleSpaceProps extends PaintProps {\r\n columnShares?: number[];\r\n rowShares?: number[];\r\n columnFills?: Fill[];\r\n columnLabels?: string[];\r\n rowLabels?: string[];\r\n values?: boolean;\r\n labelSize?: number;\r\n labelColor?: Color;\r\n fontFamily?: string;\r\n}\r\n\r\n/** The parts' paints until told otherwise, a column each, round again past the last. */\r\nconst PALETTE = [\"#58a6ff\", \"#f59e0b\", \"#4ade80\", \"#f472b6\", \"#a78bfa\", \"#2dd4bf\"];\r\n\r\n/** How strongly the lower part of a split column shows its paint. */\r\nconst LOWER = 0.45;\r\n\r\nfunction readShares(value: readonly number[] | undefined): number[] {\r\n return (Array.isArray(value) ? value : []).map((share) => (Number.isFinite(share) && share > 0 ? share : 0));\r\n}\r\n\r\n// Shares tween one by one; a different count has nothing to pair with, and changes at the end.\r\nfunction lerpShares(from: number[], to: number[], t: number): number[] {\r\n if (from.length !== to.length) return t < 1 ? from : to;\r\n return to.map((share, i) => from[i] + (share - from[i]) * t);\r\n}\r\n\r\n/**\r\n * A probability's whole, as a box cut into columns by `columnShares` (shares of\r\n * the whole, P(A) and P(not A)) and each column cut again by its `rowShares` entry\r\n * (P(B | A) above, the rest below): each part's area is its probability.\r\n * Braces name the columns below and the rows on the left; `divideTo` moves the\r\n * cuts.\r\n */\r\n@node({\r\n key: \"sampleSpace\",\r\n parentKey: \"shape\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"fixed\", defaultHeightMode: \"fixed\", acceptsChildren: false },\r\n seed: { width: 520, height: 420, columnShares: [0.4, 0.6], rowShares: [0.7, 0.25], columnLabels: [\"A\", \"not A\"], rowLabels: [\"B\", \"not B\"] },\r\n})\r\n@withdraw(...FILL_PAINT, ...OUTLINE_TRIM)\r\nexport class SampleSpace extends PaintNode<SampleSpaceProps> {\r\n /** How the whole is shared across, left to right; any numbers, read as shares of their sum. */\r\n @property({ default: [1], mapper: readShares, tween: lerpShares, kind: \"vector\" }) declare columnShares: number[];\r\n /** Each column's upper share, 0 to 1; a column without one is not cut across. */\r\n @property({ default: [], mapper: readShares, tween: lerpShares, kind: \"vector\" }) declare rowShares: number[];\r\n /** Each column's paint, left to right, round again past the last; its lower part shows it fainter. */\r\n @property({ default: [], mapper: readFillScale, tween: lerpFillScale, kind: \"vector\" }) declare columnFills: Fill[];\r\n @property({ default: [], animatable: false, kind: \"vector\" }) declare columnLabels: string[];\r\n /** The upper part's name and the lower's, written on the left. */\r\n @property({ default: [], animatable: false, kind: \"vector\" }) declare rowLabels: string[];\r\n /** Write each part's probability in it. */\r\n @property({ default: false, animatable: false }) declare values: boolean;\r\n @property({ default: 20, min: 1, unit: \"px\" }) declare labelSize: number;\r\n @colorProperty({ default: \"#e5e7eb\" }) declare labelColor: Color;\r\n @property({ default: \"\", animatable: false }) declare fontFamily: string;\r\n\r\n @strokeProperty({ default: { weight: 2, fill: \"#0b0d12\", align: \"center\" } }) declare stroke: Stroke;\r\n\r\n constructor(props?: NodeConfig<SampleSpace, SampleSpaceProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n /** Move the cuts: the columns' shares, each column's upper share, or both. */\r\n @command({ args: [\"columnShares\", \"rowShares\"] })\r\n divideTo(args: CommandArgs<{ columnShares?: number[]; rowShares?: number[] }> & { duration: number }): Command<SampleSpaceProps> {\r\n const data: Partial<SampleSpaceProps> = {};\r\n if (args.data?.columnShares !== undefined) data.columnShares = args.data.columnShares;\r\n if (args.data?.rowShares !== undefined) data.rowShares = args.data.rowShares;\r\n return this.to({ data, duration: args.duration, easing: args.easing });\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n if (this.fontFamily !== \"\") assets.font(this.fontFamily);\r\n declareFormulas(assets, [...this.columnLabels, ...this.rowLabels]);\r\n }\r\n\r\n /** Each part's box in pixels from the node's centre, y up, and its probability: columns left to right, upper part first. */\r\n parts(): { x: number; y: number; width: number; height: number; probability: number; column: number; upper: boolean }[] {\r\n const box = this._box();\r\n const shares = this.columnShares;\r\n const total = shares.reduce((sum, share) => sum + share, 0);\r\n if (!(total > 0) || box.width <= 0 || box.height <= 0) return [];\r\n const out: ReturnType<SampleSpace[\"parts\"]> = [];\r\n let left = box.x - box.width / 2;\r\n shares.forEach((share, column) => {\r\n const width = (box.width * share) / total;\r\n const p = share / total;\r\n const cut = this.rowShares[column];\r\n const top = box.y + box.height / 2;\r\n if (cut === undefined) {\r\n out.push({ x: left + width / 2, y: box.y, width, height: box.height, probability: p, column, upper: true });\r\n } else {\r\n const upper = Math.min(1, Math.max(0, cut));\r\n const h = box.height * upper;\r\n out.push({ x: left + width / 2, y: top - h / 2, width, height: h, probability: p * upper, column, upper: true });\r\n out.push({ x: left + width / 2, y: top - h - (box.height - h) / 2, width, height: box.height - h, probability: p * (1 - upper), column, upper: false });\r\n }\r\n left += width;\r\n });\r\n return out;\r\n }\r\n\r\n protected override renderSelf(ctx: RenderContext2D): void {\r\n const parts = this.parts();\r\n if (parts.length === 0) return;\r\n const fills = this.columnFills as unknown as FillResolved[][];\r\n const stroke = this.stroke as StrokeResolved[];\r\n const labels: Label[] = [];\r\n for (const part of parts) {\r\n if (!(part.width > 0) || !(part.height > 0)) continue;\r\n const base = fills.length > 0 ? fills[part.column % fills.length] : fillOps.resolve(PALETTE[part.column % PALETTE.length]);\r\n const paint = part.upper ? base : base.map((layer) => ({ ...layer, opacity: (layer.opacity ?? 1) * LOWER }));\r\n const g = new Graphics2D().rect({ x: part.x, y: part.y, width: part.width, height: part.height });\r\n ctx.draw(g.shadow(this.shadow).fill(paint));\r\n if (stroke.length > 0) ctx.draw(new Graphics2D().rect({ x: part.x, y: part.y, width: part.width, height: part.height }).stroke(stroke));\r\n if (this.values && part.height > this.labelSize && part.width > this.labelSize) {\r\n labels.push({ text: formatTick(Math.round(part.probability * 1000) / 1000, 0.001), at: { x: part.x, y: part.y }, align: \"center\" });\r\n }\r\n }\r\n labels.push(...this._braces(ctx, parts));\r\n const style = { fontSize: this.labelSize, fontFamily: this.fontFamily, color: this.labelColor as NormalizedColor };\r\n for (const part of drawLabels(labels, style)) ctx.draw(part);\r\n }\r\n\r\n // The outlines are drawn with the parts, and there is no outline of the node's own.\r\n protected override renderStroke(): void {}\r\n\r\n /** Room for the braces and their names, below and on the left, taken from the box. */\r\n private _box(): { x: number; y: number; width: number; height: number } {\r\n const { width, height } = this.layoutBounds;\r\n const room = this.labelSize * 2.6;\r\n const below = this.columnLabels.some((label) => label !== \"\") ? room : 0;\r\n const left = this.rowLabels.some((label) => label !== \"\") ? room * 1.6 : 0;\r\n return { x: left / 2, y: below / 2, width: Math.max(0, width - left), height: Math.max(0, height - below) };\r\n }\r\n\r\n /** Braces under each column and beside the first column's parts, and the labels that name them. */\r\n private _braces(ctx: RenderContext2D, parts: ReturnType<SampleSpace[\"parts\"]>): Label[] {\r\n const box = this._box();\r\n const reach = this.labelSize * 0.8;\r\n const gap = 6;\r\n const runs = new Graphics2D();\r\n const labels: Label[] = [];\r\n let drawn = false;\r\n const brace = (from: Vector2, to: Vector2, out: Vector2, text: string, align: Label[\"align\"]) => {\r\n if (text === \"\") return;\r\n // A frame centred on the node's own centre, so the path is drawn where it is and not moved onto it.\r\n runs.path({ data: braceOutline(from, to, out, reach), centerBounds: [-1, -1, 1, 1] });\r\n drawn = true;\r\n const mid = { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 };\r\n const far = reach + this.labelSize * 0.75;\r\n labels.push({ text, at: { x: mid.x + out.x * far, y: mid.y + out.y * far }, align });\r\n };\r\n const bottom = box.y - box.height / 2 - gap;\r\n for (const part of parts) {\r\n if (!part.upper && this.rowShares[part.column] !== undefined) continue;\r\n const text = this.columnLabels[part.column] ?? \"\";\r\n // Left to right along the bottom, so the bulge, to the edge's right, points down.\r\n brace({ x: part.x + part.width / 2, y: bottom }, { x: part.x - part.width / 2, y: bottom }, { x: 0, y: -1 }, text, \"center\");\r\n }\r\n const first = parts.filter((part) => part.column === 0);\r\n const left = box.x - box.width / 2 - gap;\r\n if (this.rowShares[0] !== undefined) {\r\n first.forEach((part) => {\r\n const text = this.rowLabels[part.upper ? 0 : 1] ?? \"\";\r\n brace({ x: left, y: part.y - part.height / 2 }, { x: left, y: part.y + part.height / 2 }, { x: -1, y: 0 }, text, \"right\");\r\n });\r\n }\r\n if (drawn) {\r\n const fill = fillOps.resolve({ type: \"solid\", color: this.labelColor as NormalizedColor });\r\n ctx.draw(runs.stroke({ weight: 2, fill, align: \"center\", cap: \"round\", join: \"round\" }));\r\n }\r\n return labels;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,75 @@
1
+ import { Graphics2D, type AssetScope, type Color, type Command, type CommandArgs, type Extents, type NodeConfig, type PaintProps, type Stroke, type Vector2 } from "@motionscript/sdk";
2
+ import { type AxisScaling, type CoordinateMap, type Interval } from "../kit/coords.js";
3
+ import { CoordinateSystem } from "../kit/system.js";
4
+ import { type Ticks } from "../kit/ticks.js";
5
+ export interface Axes2dProps extends PaintProps {
6
+ xRange?: Interval;
7
+ yRange?: Interval;
8
+ xStep?: number;
9
+ yStep?: number;
10
+ xScaling?: AxisScaling;
11
+ yScaling?: AxisScaling;
12
+ squareUnits?: boolean;
13
+ ticks?: boolean;
14
+ tickSize?: number;
15
+ labels?: boolean;
16
+ labelSize?: number;
17
+ labelColor?: Color;
18
+ fontFamily?: string;
19
+ xLabel?: string;
20
+ yLabel?: string;
21
+ }
22
+ /** One axis, as its furniture is drawn: its line's ends and what is marked along it. */
23
+ interface AxisLayout {
24
+ from: Vector2;
25
+ to: Vector2;
26
+ /** The pixel points that draw its line: its two ends, or more where the system's map bends it. */
27
+ line: Vector2[];
28
+ marks: Ticks;
29
+ /** The value on this axis the other one crosses at, which is left unmarked. */
30
+ crossing: number;
31
+ /** A mark's pixel point. */
32
+ at(value: number): Vector2;
33
+ }
34
+ /**
35
+ * An x and a y axis, crossing at the origin while it is in range and at the
36
+ * nearest edge otherwise. Children sit in its graph coordinates.
37
+ */
38
+ export declare class Axes2d<P extends Axes2dProps = Axes2dProps> extends CoordinateSystem<P> {
39
+ xRange: Interval;
40
+ yRange: Interval;
41
+ /** The spacing of each axis's ticks; zero picks a tidy one for the axis's length. */
42
+ xStep: number;
43
+ yStep: number;
44
+ xScaling: AxisScaling;
45
+ yScaling: AxisScaling;
46
+ /** Give a y unit the length of an x unit: `yRange` keeps its centre and takes the span that fits. */
47
+ squareUnits: boolean;
48
+ ticks: boolean;
49
+ tickSize: number;
50
+ labels: boolean;
51
+ labelSize: number;
52
+ labelColor: Color;
53
+ fontFamily: string;
54
+ /** A title at the positive end of each axis. */
55
+ xLabel: string;
56
+ yLabel: string;
57
+ stroke: Stroke;
58
+ constructor(props?: NodeConfig<Axes2d<P>, P>);
59
+ /** Animate the window of values the axes show: a pan when a range's ends move alike, a zoom when they do not. */
60
+ rangeTo(args: CommandArgs<{
61
+ xRange?: Interval;
62
+ yRange?: Interval;
63
+ }> & {
64
+ duration: number;
65
+ }): Command<P>;
66
+ declareAssets(assets: AssetScope): void;
67
+ protected mapFor(area: Extents): CoordinateMap;
68
+ protected furniture(map: CoordinateMap): Graphics2D[];
69
+ /** What is drawn behind the axes: nothing here, a grid on a number plane. */
70
+ protected backdrop(_map: CoordinateMap, _x: AxisLayout, _y: AxisLayout): Graphics2D[];
71
+ /** The two axes as laid out: where each runs, what it marks, and where the other crosses it. */
72
+ protected axes(map: CoordinateMap): [AxisLayout, AxisLayout];
73
+ }
74
+ export type { AxisLayout };
75
+ //# sourceMappingURL=axes2d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axes2d.d.ts","sourceRoot":"","sources":["../../src/systems/axes2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,UAAU,EAIV,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,KAAK,MAAM,EAEX,KAAK,OAAO,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA8C,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEhI,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAwB,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAGhE,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC3C,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC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AiH;IAEjH,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,MAAM,CAAC,EAAE,QAAQ,CAAC;QAAC,MAAM,CAAC,EAAE,QAAQ,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC;IAI9F,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAMhD,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa;IAY9C,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,EAAE;IAyDrD,6EAA6E;IAC7E,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,GAAG,UAAU,EAAE;IAIrF,gGAAgG;IAChG,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC;CA6B/D;AAED,YAAY,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,193 @@
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 { colorProperty, command, Graphics2D, node, property, strokeProperty, } from "@motionscript/sdk";
8
+ import { cartesianMap, lineThrough, resolveInterval } from "../kit/coords.js";
9
+ import { clamp, stated } from "../kit/geometry.js";
10
+ import { CoordinateSystem } from "../kit/system.js";
11
+ import { formatTick, ticksFor } from "../kit/ticks.js";
12
+ import { along, AXIS_COLOR, declareFormulas, drawLabels, drawn, lerpInterval, readInterval, withoutTips } from "../kit/furniture.js";
13
+ /**
14
+ * An x and a y axis, crossing at the origin while it is in range and at the
15
+ * nearest edge otherwise. Children sit in its graph coordinates.
16
+ */
17
+ let Axes2d = class Axes2d extends CoordinateSystem {
18
+ constructor(props) {
19
+ super((props ?? {}));
20
+ }
21
+ /** Animate the window of values the axes show: a pan when a range's ends move alike, a zoom when they do not. */
22
+ rangeTo(args) {
23
+ return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
24
+ }
25
+ declareAssets(assets) {
26
+ super.declareAssets(assets);
27
+ if (this.fontFamily !== "")
28
+ assets.font(this.fontFamily);
29
+ declareFormulas(assets, [this.xLabel, this.yLabel]);
30
+ }
31
+ mapFor(area) {
32
+ const xRange = resolveInterval(this.xRange, this.xScaling);
33
+ let yRange = resolveInterval(this.yRange, this.yScaling);
34
+ const width = area.maxX - area.minX;
35
+ if (this.squareUnits && this.xScaling === "linear" && this.yScaling === "linear" && width > 0) {
36
+ const span = ((xRange[1] - xRange[0]) * (area.maxY - area.minY)) / width;
37
+ const centre = (yRange[0] + yRange[1]) / 2;
38
+ if (span > 0)
39
+ yRange = [centre - span / 2, centre + span / 2];
40
+ }
41
+ return cartesianMap({ xRange, yRange, area, xScaling: this.xScaling, yScaling: this.yScaling });
42
+ }
43
+ furniture(map) {
44
+ const stroke = this.stroke;
45
+ const { start, end } = this;
46
+ const [x, y] = this.axes(map);
47
+ const parts = [...this.backdrop(map, x, y)];
48
+ if (stroke.length === 0 && !this.labels)
49
+ return parts;
50
+ if (stroke.length > 0) {
51
+ parts.push(new Graphics2D()
52
+ .line({ points: x.line, radius: 0, start, end })
53
+ .line({ points: y.line, radius: 0, start, end })
54
+ .stroke(stroke));
55
+ }
56
+ const half = this.tickSize / 2;
57
+ const gap = half + this.labelSize * 0.35;
58
+ const tickMarks = new Graphics2D();
59
+ const labels = [];
60
+ let ticked = false;
61
+ const mark = (axis, horizontal) => {
62
+ for (const value of axis.marks.values) {
63
+ if (Math.abs(value - axis.crossing) < 1e-9 * Math.max(1, Math.abs(value)))
64
+ continue;
65
+ const at = axis.at(value);
66
+ if (!drawn(along(at, axis.from, axis.to), start, end))
67
+ continue;
68
+ if (this.ticks && half > 0) {
69
+ tickMarks.line({
70
+ points: horizontal
71
+ ? [{ x: at.x, y: at.y - half }, { x: at.x, y: at.y + half }]
72
+ : [{ x: at.x - half, y: at.y }, { x: at.x + half, y: at.y }],
73
+ radius: 0,
74
+ });
75
+ ticked = true;
76
+ }
77
+ if (!this.labels)
78
+ continue;
79
+ labels.push(horizontal
80
+ ? { text: formatTick(value, axis.marks.step), at: { x: at.x, y: at.y - gap - this.labelSize / 2 }, align: "center" }
81
+ : { text: formatTick(value, axis.marks.step), at: { x: at.x - gap, y: at.y }, align: "right" });
82
+ }
83
+ };
84
+ mark(x, true);
85
+ mark(y, false);
86
+ if (ticked && stroke.length > 0)
87
+ parts.push(tickMarks.stroke(withoutTips(stroke)));
88
+ if (this.xLabel !== "" && end >= 1) {
89
+ labels.push({ text: this.xLabel, at: { x: x.to.x, y: x.to.y + gap + this.labelSize / 2 }, align: "right" });
90
+ }
91
+ if (this.yLabel !== "" && end >= 1) {
92
+ labels.push({ text: this.yLabel, at: { x: y.to.x + gap, y: y.to.y - this.labelSize / 2 }, align: "left" });
93
+ }
94
+ parts.push(...drawLabels(labels, { fontSize: this.labelSize, fontFamily: this.fontFamily, color: this.labelColor }));
95
+ return parts;
96
+ }
97
+ /** What is drawn behind the axes: nothing here, a grid on a number plane. */
98
+ backdrop(_map, _x, _y) {
99
+ return [];
100
+ }
101
+ /** The two axes as laid out: where each runs, what it marks, and where the other crosses it. */
102
+ axes(map) {
103
+ const [xMin, xMax] = map.xRange;
104
+ const [yMin, yMax] = map.yRange;
105
+ // An axis sits on the other's zero, or on its near edge when zero is out of range or it is logarithmic.
106
+ const crossX = this.xScaling === "log" ? xMin : clamp(0, xMin, xMax);
107
+ const crossY = this.yScaling === "log" ? yMin : clamp(0, yMin, yMax);
108
+ const xFrom = map.toPoint(xMin, crossY);
109
+ const xTo = map.toPoint(xMax, crossY);
110
+ const yFrom = map.toPoint(crossX, yMin);
111
+ const yTo = map.toPoint(crossX, yMax);
112
+ return [
113
+ {
114
+ from: xFrom,
115
+ to: xTo,
116
+ line: lineThrough(map, xMin, crossY, xMax, crossY),
117
+ marks: ticksFor(map.xRange, this.xStep, Math.hypot(xTo.x - xFrom.x, xTo.y - xFrom.y), this.xScaling),
118
+ crossing: crossX,
119
+ at: (value) => map.toPoint(value, crossY),
120
+ },
121
+ {
122
+ from: yFrom,
123
+ to: yTo,
124
+ line: lineThrough(map, crossX, yMin, crossX, yMax),
125
+ marks: ticksFor(map.yRange, this.yStep, Math.hypot(yTo.x - yFrom.x, yTo.y - yFrom.y), this.yScaling),
126
+ crossing: crossY,
127
+ at: (value) => map.toPoint(crossX, value),
128
+ },
129
+ ];
130
+ }
131
+ };
132
+ __decorate([
133
+ property({ default: [-5, 5], mapper: readInterval, tween: lerpInterval })
134
+ ], Axes2d.prototype, "xRange", void 0);
135
+ __decorate([
136
+ property({ default: [-3, 3], mapper: readInterval, tween: lerpInterval })
137
+ ], Axes2d.prototype, "yRange", void 0);
138
+ __decorate([
139
+ property({ default: 0, min: 0 })
140
+ ], Axes2d.prototype, "xStep", void 0);
141
+ __decorate([
142
+ property({ default: 0, min: 0 })
143
+ ], Axes2d.prototype, "yStep", void 0);
144
+ __decorate([
145
+ property({ default: "linear", options: ["linear", "log"], animatable: false })
146
+ ], Axes2d.prototype, "xScaling", void 0);
147
+ __decorate([
148
+ property({ default: "linear", options: ["linear", "log"], animatable: false })
149
+ ], Axes2d.prototype, "yScaling", void 0);
150
+ __decorate([
151
+ property({ default: false, animatable: false })
152
+ ], Axes2d.prototype, "squareUnits", void 0);
153
+ __decorate([
154
+ property({ default: true, animatable: false })
155
+ ], Axes2d.prototype, "ticks", void 0);
156
+ __decorate([
157
+ property({ default: 10, min: 0, unit: "px" })
158
+ ], Axes2d.prototype, "tickSize", void 0);
159
+ __decorate([
160
+ property({ default: true, animatable: false })
161
+ ], Axes2d.prototype, "labels", void 0);
162
+ __decorate([
163
+ property({ default: 18, min: 1, unit: "px" })
164
+ ], Axes2d.prototype, "labelSize", void 0);
165
+ __decorate([
166
+ colorProperty({ default: AXIS_COLOR })
167
+ ], Axes2d.prototype, "labelColor", void 0);
168
+ __decorate([
169
+ property({ default: "", animatable: false })
170
+ ], Axes2d.prototype, "fontFamily", void 0);
171
+ __decorate([
172
+ property({ default: "", animatable: false })
173
+ ], Axes2d.prototype, "xLabel", void 0);
174
+ __decorate([
175
+ property({ default: "", animatable: false })
176
+ ], Axes2d.prototype, "yLabel", void 0);
177
+ __decorate([
178
+ strokeProperty({ default: { weight: 2, fill: AXIS_COLOR, align: "center", endCap: "triangle", capScale: 5 } })
179
+ ], Axes2d.prototype, "stroke", void 0);
180
+ __decorate([
181
+ command({ args: ["xRange", "yRange"] })
182
+ ], Axes2d.prototype, "rangeTo", null);
183
+ Axes2d = __decorate([
184
+ node({
185
+ key: "axes2d",
186
+ parentKey: "node",
187
+ forkable: true,
188
+ layout: { children: "freeform", defaultWidthMode: "fixed", defaultHeightMode: "fixed", acceptsChildren: true },
189
+ seed: { width: 800, height: 500, padding: 32 },
190
+ })
191
+ ], Axes2d);
192
+ export { Axes2d };
193
+ //# sourceMappingURL=axes2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axes2d.js","sourceRoot":"","sources":["../../src/systems/axes2d.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACH,aAAa,EACb,OAAO,EACP,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,cAAc,GAYjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAuD,MAAM,eAAe,CAAC;AAChI,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,e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CAAC,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;qCAGvC;AAnCQ,MAAM;IAPlB,IAAI,CAAC;QACF,GAAG,EAAE,QAAQ;QACb,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE;QAC9G,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;KACjD,CAAC;GACW,MAAM,CAmJlB","sourcesContent":["import {\r\n colorProperty,\r\n command,\r\n Graphics2D,\r\n node,\r\n property,\r\n strokeProperty,\r\n type AssetScope,\r\n type Color,\r\n type Command,\r\n type CommandArgs,\r\n type Extents,\r\n type NodeConfig,\r\n type NormalizedColor,\r\n type PaintProps,\r\n type Stroke,\r\n type StrokeResolved,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport { cartesianMap, lineThrough, resolveInterval, type AxisScaling, type CoordinateMap, type Interval } from \"../kit/coords\";\r\nimport { clamp, stated } from \"../kit/geometry\";\r\nimport { CoordinateSystem } from \"../kit/system\";\r\nimport { formatTick, ticksFor, type Ticks } from \"../kit/ticks\";\r\nimport { along, AXIS_COLOR, declareFormulas, drawLabels, drawn, type Label, lerpInterval, readInterval, withoutTips } from \"../kit/furniture\";\r\n\r\nexport interface Axes2dProps extends PaintProps {\r\n xRange?: Interval;\r\n yRange?: Interval;\r\n xStep?: number;\r\n yStep?: number;\r\n xScaling?: AxisScaling;\r\n yScaling?: AxisScaling;\r\n squareUnits?: boolean;\r\n ticks?: boolean;\r\n tickSize?: number;\r\n labels?: boolean;\r\n labelSize?: number;\r\n labelColor?: Color;\r\n fontFamily?: string;\r\n xLabel?: string;\r\n yLabel?: string;\r\n}\r\n\r\n/** One axis, as its furniture is drawn: its line's ends and what is marked along it. */\r\ninterface AxisLayout {\r\n from: Vector2;\r\n to: Vector2;\r\n /** The pixel points that draw its line: its two ends, or more where the system's map bends it. */\r\n line: Vector2[];\r\n marks: Ticks;\r\n /** The value on this axis the other one crosses at, which is left unmarked. */\r\n crossing: number;\r\n /** A mark's pixel point. */\r\n at(value: number): Vector2;\r\n}\r\n\r\n/**\r\n * An x and a y axis, crossing at the origin while it is in range and at the\r\n * nearest edge otherwise. Children sit in its graph coordinates.\r\n */\r\n@node({\r\n key: \"axes2d\",\r\n parentKey: \"node\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"fixed\", defaultHeightMode: \"fixed\", acceptsChildren: true },\r\n seed: { width: 800, height: 500, padding: 32 },\r\n})\r\nexport class Axes2d<P extends Axes2dProps = Axes2dProps> extends CoordinateSystem<P> {\r\n @property({ default: [-5, 5], mapper: readInterval, tween: lerpInterval })\r\n declare xRange: Interval;\r\n @property({ default: [-3, 3], mapper: readInterval, tween: lerpInterval })\r\n declare yRange: Interval;\r\n\r\n /** The spacing of each axis's ticks; zero picks a tidy one for the axis's length. */\r\n @property({ default: 0, min: 0 }) declare xStep: number;\r\n @property({ default: 0, min: 0 }) declare yStep: number;\r\n @property({ default: \"linear\", options: [\"linear\", \"log\"], animatable: false }) declare xScaling: AxisScaling;\r\n @property({ default: \"linear\", options: [\"linear\", \"log\"], animatable: false }) declare yScaling: AxisScaling;\r\n /** Give a y unit the length of an x unit: `yRange` keeps its centre and takes the span that fits. */\r\n @property({ default: false, animatable: false }) declare squareUnits: boolean;\r\n\r\n @property({ default: true, animatable: false }) declare ticks: boolean;\r\n @property({ default: 10, min: 0, unit: \"px\" }) declare tickSize: number;\r\n @property({ default: true, animatable: false }) declare labels: boolean;\r\n @property({ default: 18, min: 1, unit: \"px\" }) declare labelSize: number;\r\n @colorProperty({ default: AXIS_COLOR }) declare labelColor: Color;\r\n @property({ default: \"\", animatable: false }) declare fontFamily: string;\r\n /** A title at the positive end of each axis. */\r\n @property({ default: \"\", animatable: false }) declare xLabel: string;\r\n @property({ default: \"\", animatable: false }) declare yLabel: string;\r\n\r\n @strokeProperty({ default: { weight: 2, fill: AXIS_COLOR, align: \"center\", endCap: \"triangle\", capScale: 5 } })\r\n declare stroke: Stroke;\r\n\r\n constructor(props?: NodeConfig<Axes2d<P>, P>) {\r\n super((props ?? {}) as NodeConfig<Axes2d<P>, P>);\r\n }\r\n\r\n /** Animate the window of values the axes show: a pan when a range's ends move alike, a zoom when they do not. */\r\n @command({ args: [\"xRange\", \"yRange\"] })\r\n rangeTo(args: CommandArgs<{ xRange?: Interval; yRange?: Interval }> & { duration: number }): Command<P> {\r\n return this.to({ data: stated(args.data) as Partial<P>, duration: args.duration, easing: args.easing });\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n if (this.fontFamily !== \"\") assets.font(this.fontFamily);\r\n declareFormulas(assets, [this.xLabel, this.yLabel]);\r\n }\r\n\r\n protected mapFor(area: Extents): CoordinateMap {\r\n const xRange = resolveInterval(this.xRange, this.xScaling);\r\n let yRange = resolveInterval(this.yRange, this.yScaling);\r\n const width = area.maxX - area.minX;\r\n if (this.squareUnits && this.xScaling === \"linear\" && this.yScaling === \"linear\" && width > 0) {\r\n const span = ((xRange[1] - xRange[0]) * (area.maxY - area.minY)) / width;\r\n const centre = (yRange[0] + yRange[1]) / 2;\r\n if (span > 0) yRange = [centre - span / 2, centre + span / 2];\r\n }\r\n return cartesianMap({ xRange, yRange, area, xScaling: this.xScaling, yScaling: this.yScaling });\r\n }\r\n\r\n protected furniture(map: CoordinateMap): Graphics2D[] {\r\n const stroke = this.stroke as StrokeResolved[];\r\n const { start, end } = this;\r\n const [x, y] = this.axes(map);\r\n const parts: Graphics2D[] = [...this.backdrop(map, x, y)];\r\n if (stroke.length === 0 && !this.labels) return parts;\r\n\r\n if (stroke.length > 0) {\r\n parts.push(\r\n new Graphics2D()\r\n .line({ points: x.line, radius: 0, start, end })\r\n .line({ points: y.line, radius: 0, start, end })\r\n .stroke(stroke),\r\n );\r\n }\r\n\r\n const half = this.tickSize / 2;\r\n const gap = half + this.labelSize * 0.35;\r\n const tickMarks = new Graphics2D();\r\n const labels: Label[] = [];\r\n let ticked = false;\r\n const mark = (axis: AxisLayout, horizontal: boolean): void => {\r\n for (const value of axis.marks.values) {\r\n if (Math.abs(value - axis.crossing) < 1e-9 * Math.max(1, Math.abs(value))) continue;\r\n const at = axis.at(value);\r\n if (!drawn(along(at, axis.from, axis.to), start, end)) continue;\r\n if (this.ticks && half > 0) {\r\n tickMarks.line({\r\n points: horizontal\r\n ? [{ x: at.x, y: at.y - half }, { x: at.x, y: at.y + half }]\r\n : [{ x: at.x - half, y: at.y }, { x: at.x + half, y: at.y }],\r\n radius: 0,\r\n });\r\n ticked = true;\r\n }\r\n if (!this.labels) continue;\r\n labels.push(\r\n horizontal\r\n ? { text: formatTick(value, axis.marks.step), at: { x: at.x, y: at.y - gap - this.labelSize / 2 }, align: \"center\" }\r\n : { text: formatTick(value, axis.marks.step), at: { x: at.x - gap, y: at.y }, align: \"right\" },\r\n );\r\n }\r\n };\r\n mark(x, true);\r\n mark(y, false);\r\n if (ticked && stroke.length > 0) parts.push(tickMarks.stroke(withoutTips(stroke)));\r\n\r\n if (this.xLabel !== \"\" && end >= 1) {\r\n labels.push({ text: this.xLabel, at: { x: x.to.x, y: x.to.y + gap + this.labelSize / 2 }, align: \"right\" });\r\n }\r\n if (this.yLabel !== \"\" && end >= 1) {\r\n labels.push({ text: this.yLabel, at: { x: y.to.x + gap, y: y.to.y - this.labelSize / 2 }, align: \"left\" });\r\n }\r\n parts.push(...drawLabels(labels, { fontSize: this.labelSize, fontFamily: this.fontFamily, color: this.labelColor as NormalizedColor }));\r\n return parts;\r\n }\r\n\r\n /** What is drawn behind the axes: nothing here, a grid on a number plane. */\r\n protected backdrop(_map: CoordinateMap, _x: AxisLayout, _y: AxisLayout): Graphics2D[] {\r\n return [];\r\n }\r\n\r\n /** The two axes as laid out: where each runs, what it marks, and where the other crosses it. */\r\n protected axes(map: CoordinateMap): [AxisLayout, AxisLayout] {\r\n const [xMin, xMax] = map.xRange;\r\n const [yMin, yMax] = map.yRange;\r\n // An axis sits on the other's zero, or on its near edge when zero is out of range or it is logarithmic.\r\n const crossX = this.xScaling === \"log\" ? xMin : clamp(0, xMin, xMax);\r\n const crossY = this.yScaling === \"log\" ? yMin : clamp(0, yMin, yMax);\r\n const xFrom = map.toPoint(xMin, crossY);\r\n const xTo = map.toPoint(xMax, crossY);\r\n const yFrom = map.toPoint(crossX, yMin);\r\n const yTo = map.toPoint(crossX, yMax);\r\n return [\r\n {\r\n from: xFrom,\r\n to: xTo,\r\n line: lineThrough(map, xMin, crossY, xMax, crossY),\r\n marks: ticksFor(map.xRange, this.xStep, Math.hypot(xTo.x - xFrom.x, xTo.y - xFrom.y), this.xScaling),\r\n crossing: crossX,\r\n at: (value) => map.toPoint(value, crossY),\r\n },\r\n {\r\n from: yFrom,\r\n to: yTo,\r\n line: lineThrough(map, crossX, yMin, crossX, yMax),\r\n marks: ticksFor(map.yRange, this.yStep, Math.hypot(yTo.x - yFrom.x, yTo.y - yFrom.y), this.yScaling),\r\n crossing: crossY,\r\n at: (value) => map.toPoint(crossX, value),\r\n },\r\n ];\r\n }\r\n}\r\n\r\nexport type { AxisLayout };\r\n"]}
@@ -0,0 +1,49 @@
1
+ import { Graphics2D, type AssetScope, type Color, type Command, type CommandArgs, type Extents, type NodeConfig, type PaintProps, type Stroke } from "@motionscript/sdk";
2
+ import { type AxisScaling, type CoordinateMap, type Interval } from "../kit/coords.js";
3
+ import { CoordinateSystem } from "../kit/system.js";
4
+ export interface NumberLineProps extends PaintProps {
5
+ range?: Interval;
6
+ step?: number;
7
+ scaling?: AxisScaling;
8
+ ticks?: boolean;
9
+ tickSize?: number;
10
+ longTicks?: number[];
11
+ labels?: boolean;
12
+ labelExclude?: number[];
13
+ labelSide?: "below" | "above";
14
+ labelSize?: number;
15
+ labelColor?: Color;
16
+ fontFamily?: string;
17
+ }
18
+ /**
19
+ * One axis with ticks and numbers. A child's `x` is a value on the line and its
20
+ * `y` is pixels above it, so a dot or a label sits on a number.
21
+ */
22
+ export declare class NumberLine extends CoordinateSystem<NumberLineProps> {
23
+ range: Interval;
24
+ /** The spacing of the ticks; zero picks a tidy one for the line's length. */
25
+ step: number;
26
+ scaling: AxisScaling;
27
+ ticks: boolean;
28
+ tickSize: number;
29
+ /** Values whose ticks are drawn twice as long. */
30
+ longTicks: number[];
31
+ labels: boolean;
32
+ labelExclude: number[];
33
+ labelSide: "below" | "above";
34
+ labelSize: number;
35
+ labelColor: Color;
36
+ fontFamily: string;
37
+ stroke: Stroke;
38
+ constructor(props?: NodeConfig<NumberLine, NumberLineProps>);
39
+ /** Animate the span of values the line shows: a pan when both ends move alike, a zoom when they do not. */
40
+ rangeTo(args: CommandArgs<{
41
+ range?: Interval;
42
+ }> & {
43
+ duration: number;
44
+ }): Command<NumberLineProps>;
45
+ declareAssets(assets: AssetScope): void;
46
+ protected mapFor(area: Extents): CoordinateMap;
47
+ protected furniture(map: CoordinateMap): Graphics2D[];
48
+ }
49
+ //# 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,EAGH,UAAU,EAIV,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,KAAK,MAAM,EAGd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAiC,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAIjD,MAAM,WAAW,eAAgB,SAAQ,UAAU;IAC/C,KAAK,CAAC,EA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AAU,GAAG,IAAI;IAKhD,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa;IAS9C,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,EAAE;CAkCxD"}
@@ -0,0 +1,127 @@
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 { colorProperty, command, Graphics2D, node, property, strokeProperty, } from "@motionscript/sdk";
8
+ import { cartesianMap, resolveInterval } from "../kit/coords.js";
9
+ import { stated } from "../kit/geometry.js";
10
+ import { CoordinateSystem } from "../kit/system.js";
11
+ import { formatTick, ticksFor } from "../kit/ticks.js";
12
+ import { along, AXIS_COLOR, drawLabels, drawn, lerpInterval, readInterval, withoutTips } from "../kit/furniture.js";
13
+ /**
14
+ * One axis with ticks and numbers. A child's `x` is a value on the line and its
15
+ * `y` is pixels above it, so a dot or a label sits on a number.
16
+ */
17
+ let NumberLine = class NumberLine extends CoordinateSystem {
18
+ constructor(props) {
19
+ super(props ?? {});
20
+ }
21
+ /** Animate the span of values the line shows: a pan when both ends move alike, a zoom when they do not. */
22
+ rangeTo(args) {
23
+ return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
24
+ }
25
+ declareAssets(assets) {
26
+ super.declareAssets(assets);
27
+ if (this.fontFamily !== "")
28
+ assets.font(this.fontFamily);
29
+ }
30
+ mapFor(area) {
31
+ return cartesianMap({
32
+ xRange: resolveInterval(this.range, this.scaling),
33
+ yRange: [area.minY, area.maxY],
34
+ area,
35
+ xScaling: this.scaling,
36
+ });
37
+ }
38
+ furniture(map) {
39
+ const stroke = this.stroke;
40
+ const { start, end } = this;
41
+ const [min, max] = map.xRange;
42
+ const from = map.toPoint(min, 0);
43
+ const to = map.toPoint(max, 0);
44
+ const parts = [];
45
+ if (stroke.length > 0)
46
+ parts.push(new Graphics2D().line({ points: [from, to], radius: 0, start, end }).stroke(stroke));
47
+ const marks = ticksFor(map.xRange, this.step, to.x - from.x, this.scaling);
48
+ const sign = this.labelSide === "below" ? -1 : 1;
49
+ const tickMarks = new Graphics2D();
50
+ const labels = [];
51
+ let ticked = false;
52
+ for (const value of marks.values) {
53
+ const at = map.toPoint(value, 0);
54
+ if (!drawn(along(at, from, to), start, end))
55
+ continue;
56
+ const half = this.longTicks.includes(value) ? this.tickSize : this.tickSize / 2;
57
+ if (this.ticks && half > 0) {
58
+ tickMarks.line({ points: [{ x: at.x, y: at.y - half }, { x: at.x, y: at.y + half }], radius: 0 });
59
+ ticked = true;
60
+ }
61
+ if (this.labels && !this.labelExclude.includes(value)) {
62
+ labels.push({
63
+ text: formatTick(value, marks.step),
64
+ at: { x: at.x, y: at.y + sign * (this.tickSize / 2 + this.labelSize * 0.9) },
65
+ align: "center",
66
+ });
67
+ }
68
+ }
69
+ if (ticked && stroke.length > 0)
70
+ parts.push(tickMarks.stroke(withoutTips(stroke)));
71
+ parts.push(...drawLabels(labels, { fontSize: this.labelSize, fontFamily: this.fontFamily, color: this.labelColor }));
72
+ return parts;
73
+ }
74
+ };
75
+ __decorate([
76
+ property({ default: [-5, 5], mapper: readInterval, tween: lerpInterval })
77
+ ], NumberLine.prototype, "range", void 0);
78
+ __decorate([
79
+ property({ default: 0, min: 0 })
80
+ ], NumberLine.prototype, "step", void 0);
81
+ __decorate([
82
+ property({ default: "linear", options: ["linear", "log"], animatable: false })
83
+ ], NumberLine.prototype, "scaling", void 0);
84
+ __decorate([
85
+ property({ default: true, animatable: false })
86
+ ], NumberLine.prototype, "ticks", void 0);
87
+ __decorate([
88
+ property({ default: 12, min: 0, unit: "px" })
89
+ ], NumberLine.prototype, "tickSize", void 0);
90
+ __decorate([
91
+ property({ default: [], animatable: false })
92
+ ], NumberLine.prototype, "longTicks", void 0);
93
+ __decorate([
94
+ property({ default: true, animatable: false })
95
+ ], NumberLine.prototype, "labels", void 0);
96
+ __decorate([
97
+ property({ default: [], animatable: false })
98
+ ], NumberLine.prototype, "labelExclude", void 0);
99
+ __decorate([
100
+ property({ default: "below", options: ["below", "above"], animatable: false })
101
+ ], NumberLine.prototype, "labelSide", void 0);
102
+ __decorate([
103
+ property({ default: 18, min: 1, unit: "px" })
104
+ ], NumberLine.prototype, "labelSize", void 0);
105
+ __decorate([
106
+ colorProperty({ default: AXIS_COLOR })
107
+ ], NumberLine.prototype, "labelColor", void 0);
108
+ __decorate([
109
+ property({ default: "", animatable: false })
110
+ ], NumberLine.prototype, "fontFamily", void 0);
111
+ __decorate([
112
+ strokeProperty({ default: { weight: 2, fill: AXIS_COLOR, align: "center" } })
113
+ ], NumberLine.prototype, "stroke", void 0);
114
+ __decorate([
115
+ command({ args: ["range"] })
116
+ ], NumberLine.prototype, "rangeTo", null);
117
+ NumberLine = __decorate([
118
+ node({
119
+ key: "numberLine",
120
+ parentKey: "node",
121
+ forkable: true,
122
+ layout: { children: "freeform", defaultWidthMode: "fixed", defaultHeightMode: "fixed", acceptsChildren: true },
123
+ seed: { width: 800, height: 120 },
124
+ })
125
+ ], NumberLine);
126
+ export { NumberLine };
127
+ //# 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,aAAa,EACb,OAAO,EACP,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,cAAc,GAYjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,eAAe,EAAuD,MAAM,eAAe,CAAC;AACnH,OAAO,EAAE,MAAM,EAAE,MAAM,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EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;6CAA2B;AACzB;IAA/C,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;8CAA2B;AACZ;IAArD,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;8CAA4B;AAGjE;IADP,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC;0CACvD;AAQvB;IADC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;yCAG5B;AA7BQ,UAAU;IAPtB,IAAI,CAAC;QACF,GAAG,EAAE,YAAY;QACjB,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE;QAC9G,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;KACpC,CAAC;GACW,UAAU,CA+EtB","sourcesContent":["import {\r\n colorProperty,\r\n command,\r\n Graphics2D,\r\n node,\r\n property,\r\n strokeProperty,\r\n type AssetScope,\r\n type Color,\r\n type Command,\r\n type CommandArgs,\r\n type Extents,\r\n type NodeConfig,\r\n type NormalizedColor,\r\n type PaintProps,\r\n type Stroke,\r\n type StrokeResolved,\r\n type Vector2,\r\n} from \"@motionscript/sdk\";\r\nimport { cartesianMap, resolveInterval, type AxisScaling, type CoordinateMap, type Interval } from \"../kit/coords\";\r\nimport { stated } from \"../kit/geometry\";\r\nimport { CoordinateSystem } from \"../kit/system\";\r\nimport { formatTick, ticksFor } from \"../kit/ticks\";\r\nimport { along, AXIS_COLOR, drawLabels, drawn, lerpInterval, readInterval, withoutTips, type Label } from \"../kit/furniture\";\r\n\r\nexport interface NumberLineProps extends PaintProps {\r\n range?: Interval;\r\n step?: number;\r\n scaling?: AxisScaling;\r\n ticks?: boolean;\r\n tickSize?: number;\r\n longTicks?: number[];\r\n labels?: boolean;\r\n labelExclude?: number[];\r\n labelSide?: \"below\" | \"above\";\r\n labelSize?: number;\r\n labelColor?: Color;\r\n fontFamily?: string;\r\n}\r\n\r\n/**\r\n * One axis with ticks and numbers. A child's `x` is a value on the line and its\r\n * `y` is pixels above it, so a dot or a label sits on a number.\r\n */\r\n@node({\r\n key: \"numberLine\",\r\n parentKey: \"node\",\r\n forkable: true,\r\n layout: { children: \"freeform\", defaultWidthMode: \"fixed\", defaultHeightMode: \"fixed\", acceptsChildren: true },\r\n seed: { width: 800, height: 120 },\r\n})\r\nexport class NumberLine extends CoordinateSystem<NumberLineProps> {\r\n @property({ default: [-5, 5], mapper: readInterval, tween: lerpInterval })\r\n declare range: Interval;\r\n\r\n /** The spacing of the ticks; zero picks a tidy one for the line's length. */\r\n @property({ default: 0, min: 0 }) declare step: number;\r\n @property({ default: \"linear\", options: [\"linear\", \"log\"], animatable: false }) declare scaling: AxisScaling;\r\n @property({ default: true, animatable: false }) declare ticks: boolean;\r\n @property({ default: 12, min: 0, unit: \"px\" }) declare tickSize: number;\r\n /** Values whose ticks are drawn twice as long. */\r\n @property({ default: [], animatable: false }) declare longTicks: number[];\r\n @property({ default: true, animatable: false }) declare labels: boolean;\r\n @property({ default: [], animatable: false }) declare labelExclude: number[];\r\n @property({ default: \"below\", options: [\"below\", \"above\"], animatable: false }) declare labelSide: \"below\" | \"above\";\r\n @property({ default: 18, min: 1, unit: \"px\" }) declare labelSize: number;\r\n @colorProperty({ default: AXIS_COLOR }) declare labelColor: Color;\r\n @property({ default: \"\", animatable: false }) declare fontFamily: string;\r\n\r\n @strokeProperty({ default: { weight: 2, fill: AXIS_COLOR, align: \"center\" } })\r\n declare stroke: Stroke;\r\n\r\n constructor(props?: NodeConfig<NumberLine, NumberLineProps>) {\r\n super(props ?? {});\r\n }\r\n\r\n /** Animate the span of values the line shows: a pan when both ends move alike, a zoom when they do not. */\r\n @command({ args: [\"range\"] })\r\n rangeTo(args: CommandArgs<{ range?: Interval }> & { duration: number }): Command<NumberLineProps> {\r\n return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n if (this.fontFamily !== \"\") assets.font(this.fontFamily);\r\n }\r\n\r\n protected mapFor(area: Extents): CoordinateMap {\r\n return cartesianMap({\r\n xRange: resolveInterval(this.range, this.scaling),\r\n yRange: [area.minY, area.maxY],\r\n area,\r\n xScaling: this.scaling,\r\n });\r\n }\r\n\r\n protected furniture(map: CoordinateMap): Graphics2D[] {\r\n const stroke = this.stroke as StrokeResolved[];\r\n const { start, end } = this;\r\n const [min, max] = map.xRange;\r\n const from = map.toPoint(min, 0);\r\n const to = map.toPoint(max, 0);\r\n const parts: Graphics2D[] = [];\r\n if (stroke.length > 0) parts.push(new Graphics2D().line({ points: [from, to], radius: 0, start, end }).stroke(stroke));\r\n\r\n const marks = ticksFor(map.xRange, this.step, to.x - from.x, this.scaling);\r\n const sign = this.labelSide === \"below\" ? -1 : 1;\r\n const tickMarks = new Graphics2D();\r\n const labels: Label[] = [];\r\n let ticked = false;\r\n for (const value of marks.values) {\r\n const at: Vector2 = map.toPoint(value, 0);\r\n if (!drawn(along(at, from, to), start, end)) continue;\r\n const half = this.longTicks.includes(value) ? this.tickSize : this.tickSize / 2;\r\n if (this.ticks && half > 0) {\r\n tickMarks.line({ points: [{ x: at.x, y: at.y - half }, { x: at.x, y: at.y + half }], radius: 0 });\r\n ticked = true;\r\n }\r\n if (this.labels && !this.labelExclude.includes(value)) {\r\n labels.push({\r\n text: formatTick(value, marks.step),\r\n at: { x: at.x, y: at.y + sign * (this.tickSize / 2 + this.labelSize * 0.9) },\r\n align: \"center\",\r\n });\r\n }\r\n }\r\n if (ticked && stroke.length > 0) parts.push(tickMarks.stroke(withoutTips(stroke)));\r\n parts.push(...drawLabels(labels, { fontSize: this.labelSize, fontFamily: this.fontFamily, color: this.labelColor as NormalizedColor }));\r\n return parts;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,59 @@
1
+ import { Graphics2D, type Command, type CommandArgs, type Extents, type NodeConfig, type Stroke } from "@motionscript/sdk";
2
+ import { type CoordinateMap, type Matrix2 } from "../kit/coords.js";
3
+ import { Axes2d, type Axes2dProps, type AxisLayout } from "./axes2d.js";
4
+ import { type PlotSource } from "../kit/source.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
+ /**
15
+ * Axes over a full grid, with square units unless told otherwise: the plane
16
+ * vectors and transformations are drawn on. Its `matrix` shears, turns or
17
+ * squeezes the whole plane about its origin, and its `warp` bends it by a
18
+ * function of its own points; the grid, the axes and everything on the plane
19
+ * go with it.
20
+ */
21
+ export declare class NumberPlane extends Axes2d<NumberPlaneProps> {
22
+ grid: boolean;
23
+ /** The line at every tick. */
24
+ gridStroke: Stroke;
25
+ /** The lines between ticks. */
26
+ minorStroke: Stroke;
27
+ /** How many parts the space between two ticks is cut into; one draws no line between them. */
28
+ minorDivisions: number;
29
+ /** A linear map of the plane, row by row: `[a, b, c, d]` sends `(x, y)` to `(ax + by, cx + dy)`. */
30
+ matrix: Matrix2;
31
+ /**
32
+ * Where each point of the plane is sent, two parts in x and y:
33
+ * `(x + sin(y), y + sin(x))`. Empty leaves the plane flat.
34
+ */
35
+ warp: PlotSource;
36
+ /** Leave the plane as it was, faintly, behind one that has been transformed or warped. */
37
+ ghost: boolean;
38
+ squareUnits: boolean;
39
+ stroke: Stroke;
40
+ constructor(props?: NodeConfig<NumberPlane, NumberPlaneProps>);
41
+ /** Send the plane through a matrix: a shear, a turn, a squeeze, a flip. */
42
+ transformTo(args: CommandArgs<{
43
+ matrix: Matrix2 | readonly (readonly number[])[];
44
+ }> & {
45
+ duration: number;
46
+ }): Command<NumberPlaneProps>;
47
+ /** Bend the plane, each point travelling to where the warp sends it; an empty one flattens it again. */
48
+ warpTo(args: CommandArgs<{
49
+ warp: string;
50
+ }> & {
51
+ duration: number;
52
+ }): Command<NumberPlaneProps>;
53
+ protected mapFor(area: Extents): CoordinateMap;
54
+ protected backdrop(map: CoordinateMap, x: AxisLayout, y: AxisLayout): Graphics2D[];
55
+ private _flat;
56
+ /** The grid of `map`: every line, or only the ones at a tick, in the fainter stroke, for a ghost. */
57
+ private _ruled;
58
+ }
59
+ //# sourceMappingURL=number-plane.d.ts.map