@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,2 @@
1
+ import{$ as ra,A as S,Aa as Sa,B as T,Ba as Ta,C as U,Ca as Ua,D as V,Da as Va,E as W,Ea as Wa,F as X,Fa as Xa,G as Y,Ga as Ya,H as Z,I as _,J as $,K as aa,L as ba,M as ca,N as da,O as ea,P as fa,Q as ga,R as ha,S as ia,T as ja,U as ka,V as la,W as ma,X as na,Y as oa,Z as pa,_ as qa,a as t,aa as sa,b as u,ba as ta,c as v,ca as ua,d as w,da as va,e as x,ea as wa,f as y,fa as xa,g as z,ga as ya,h as A,ha as za,i as B,ia as Aa,j as C,ja as Ba,k as D,ka as Ca,l as E,la as Da,m as F,ma as Ea,n as G,na as Fa,o as H,oa as Ga,p as I,pa as Ha,q as J,qa as Ia,r as K,ra as Ja,s as L,sa as Ka,t as M,ta as La,u as N,ua as Ma,v as O,va as Na,w as P,wa as Oa,x as Q,xa as Pa,ya as Qa,z as R,za as Ra}from"./chunks/chunk-3GJB6AVO.js";import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s}from"./chunks/chunk-WL4KEX7Y.js";export{O as AXIS_COLOR,W as Axes2d,L as CoordinateSystem,Pa as EQUATION_KINDS,$ as EQUATION_VARIABLES,Ia as EQUATION_VARIABLES_3D,da as FIELD_VARIABLES,p as FILL_PAINT,Wa as FieldMark,ya as FollowMark,ta as FunctionPlot,Xa as GRAPH_LAYOUTS,x as IDENTITY_MATRIX,s as Latex,g as LatexError,f as LatexNotLoaded,b as MATHJAX_LOADER,X as MATH_DIALECT,pa as Mark,r as OUTLINE_TRIM,w as PIXEL_MAP,P as PLOT_COLOR,q as STROKE_PAINT,ra as SYSTEMS,sa as SYSTEMS_AND_PLOT,ka as UNSET_PARAM,za as add,Ha as aim,T as along,u as axisScale,Aa as between,e as blankLatex,F as boundsOfRuns,Da as braceOutline,h as buildLatexPath,v as cartesianMap,H as clamp,Sa as colorAt,Z as compileExpression,_ as compileExpressionCached,a as createBoundedCache,ua as curveNamed,va as curveOf,k as defaultLatexMorph,Ea as drawLabel3D,R as drawLabels,S as drawn,ba as equationError,ca as equationParams,Y as expressionVocabulary,ga as fieldError,ea as fieldParams,Va as fillAt,j as findLatexParts,wa as followed,N as formatTick,Fa as graphSpace,Ca as grown,Ba as heading,G as inflate,A as isIdentityMatrix,i as latexPartNames,Ya as layOut,ja as lerpDomain,Ua as lerpFillScale,U as lerpInterval,z as lerpMatrix,la as lerpParams,m as lerpPartFills,Ra as lerpScale,ia as lerpSource,D as lineThrough,c as loadMathJax,d as mathJaxLoaded,K as openPlane,aa as parseEquation,fa as parseField,Ma as parseSpaceCurve,La as parseSurface,o as partPaint,J as placeOnMap,xa as quadOf,Ta as readFillScale,V as readInterval,y as readMatrix,l as readPartFills,Qa as readScale,ha as readSource,t as resolveInterval,na as revisionOf,E as runsToPath,qa as sampleCurve,ma as scopeFor,Oa as spaceCurveError,Ka as spaceCurveParams,Ga as spaceOf,I as stated,Na as surfaceError,Ja as surfaceParams,M as ticksFor,oa as traceContour,B as transformedMap,C as warpedMap,n as withPartFill,Q as withoutTips};
2
+ //# sourceMappingURL=kit.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@motionscript/math",
3
+ "version": "0.1.0-alpha.4",
4
+ "exports": {
5
+ ".": "dist/browser/index.js",
6
+ "./kit": "dist/browser/kit.js",
7
+ "./tex": "dist/browser/tex.js"
8
+ },
9
+ "peers": [
10
+ "@motionscript/sdk"
11
+ ],
12
+ "assets": {},
13
+ "thirdParty": [
14
+ {
15
+ "name": "@mathjax/mathjax-newcm-font",
16
+ "version": "4.1.2",
17
+ "license": "Apache-2.0"
18
+ },
19
+ {
20
+ "name": "@mathjax/src",
21
+ "version": "4.1.2",
22
+ "license": "Apache-2.0"
23
+ },
24
+ {
25
+ "name": "mhchemparser",
26
+ "version": "4.2.1",
27
+ "license": "Apache-2.0"
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,2 @@
1
+ import{a as l,b as a}from"./chunks/chunk-D5WHCVBC.js";import{b as o,c as r,d as e,e as x,f as L,g as m,h as d,i as f,j as p,k as i,s as t}from"./chunks/chunk-WL4KEX7Y.js";var M=[t,a];export{t as Latex,m as LatexError,a as LatexMatrix,L as LatexNotLoaded,o as MATHJAX_LOADER,M as TEX_NODES,x as blankLatex,d as buildLatexPath,i as defaultLatexMorph,p as findLatexParts,f as latexPartNames,r as loadMathJax,e as mathJaxLoaded,l as matrixSource};
2
+ //# sourceMappingURL=tex.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tex/index.ts"],
4
+ "sourcesContent": ["import { LatexMatrix } from './matrix';\r\nimport { Latex } from './node';\r\n\r\nexport * from './node';\r\nexport * from './matrix';\r\nexport {\r\n blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER,\r\n} from './geometry';\r\nexport type { LatexPart, LatexToken, LatexPathResult } from './geometry';\r\nexport { defaultLatexMorph } from './tween';\r\nexport type { AnimatedToken, LatexMorphStrategy } from './tween';\r\n\r\n/** The typeset-math node types, for a host that registers only these. */\r\nexport const TEX_NODES = [Latex, LatexMatrix];\r\n"],
5
+ "mappings": "2KAaO,IAAMA,EAAY,CAACC,EAAOC,CAAW",
6
+ "names": ["TEX_NODES", "Latex", "LatexMatrix"]
7
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The math **kit**: what the nodes share, and what a copied one does not copy.
3
+ *
4
+ * `ms add` writes a node's own files into a project and rewrites its reach for
5
+ * these to `@motionscript/math`, so MathJax, the morph and every shared class
6
+ * stay a real dependency with one identity.
7
+ */
8
+ export { blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER, } from './tex/geometry.js';
9
+ export type { LatexPart, LatexToken, LatexPathResult } from './tex/geometry.js';
10
+ export { defaultLatexMorph } from './tex/tween.js';
11
+ export type { AnimatedToken, LatexMorphStrategy } from './tex/tween.js';
12
+ export { Latex } from './tex/node.js';
13
+ export type { LatexProps, LatexStrategies } from './tex/node.js';
14
+ export { lerpPartFills, partPaint, readPartFills, withPartFill } from './kit/part-fills.js';
15
+ export type { PartFill, PartFillResolved } from './kit/part-fills.js';
16
+ export { FILL_PAINT, OUTLINE_TRIM, STROKE_PAINT } from './kit/withdrawn.js';
17
+ export { createBoundedCache } from './kit/cache.js';
18
+ export type { BoundedCache } from './kit/cache.js';
19
+ export { CoordinateSystem } from './kit/system.js';
20
+ export { Axes2d } from './systems/axes2d.js';
21
+ export type { Axes2dProps, AxisLayout } from './systems/axes2d.js';
22
+ export type { Anchored } from './kit/place.js';
23
+ export { openPlane, placeOnMap } from './kit/place.js';
24
+ export { Mark } from './kit/mark.js';
25
+ export { axisScale, cartesianMap, resolveInterval, PIXEL_MAP } from './kit/coords.js';
26
+ export type { AxisScale, AxisScaling, CartesianOptions, CoordinateMap, Interval } from './kit/coords.js';
27
+ export { compileExpression, compileExpressionCached, expressionVocabulary, MATH_DIALECT } from './kit/expression.js';
28
+ export type { CompiledExpression, ExpressionScope, ExpressionVocabulary } from './kit/expression.js';
29
+ export { equationError, equationParams, parseEquation, EQUATION_VARIABLES } from './kit/equation.js';
30
+ export type { Equation } from './kit/equation.js';
31
+ export { lerpDomain, lerpParams, lerpSource, readSource, revisionOf, scopeFor, UNSET_PARAM } from './kit/source.js';
32
+ export type { PlotSource } from './kit/source.js';
33
+ export { sampleCurve } from './kit/sampler.js';
34
+ export type { CurveProjection, SampleOptions } from './kit/sampler.js';
35
+ export { formatTick, ticksFor } from './kit/ticks.js';
36
+ export type { Ticks } from './kit/ticks.js';
37
+ export { boundsOfRuns, clamp, inflate, runsToPath, stated } from './kit/geometry.js';
38
+ export { curveNamed, curveOf } from './kit/curve.js';
39
+ export type { Curve } from './kit/curve.js';
40
+ export { along, AXIS_COLOR, drawLabels, drawn, lerpInterval, PLOT_COLOR, readInterval, withoutTips } from './kit/furniture.js';
41
+ export type { Label, LabelStyle } from './kit/furniture.js';
42
+ export { add, between, followed, FollowMark, grown, heading, quadOf } from './kit/follow.js';
43
+ export type { FollowProps, Parted, Quad, Retarget, Target } from './kit/follow.js';
44
+ export { parseSpaceCurve, parseSurface, spaceCurveError, spaceCurveParams, surfaceError, surfaceParams, EQUATION_KINDS, EQUATION_VARIABLES_3D, } from './kit/equation3d.js';
45
+ export type { EquationLanguage, SpaceCurveEquation, SurfaceEquation } from './kit/equation3d.js';
46
+ export { aim, graphSpace, spaceOf } from './three/space.js';
47
+ export type { GraphSpace } from './three/space.js';
48
+ export { drawLabel3D } from './three/label3d.js';
49
+ export type { LabelStyle3D } from './three/label3d.js';
50
+ export { FunctionPlot } from './plots/function-plot.js';
51
+ export type { FunctionPlotProps } from './plots/function-plot.js';
52
+ export { FieldMark } from './kit/field-mark.js';
53
+ export type { FieldProps, FieldSampler, FieldStroke } from './kit/field-mark.js';
54
+ export { fieldError, fieldParams, parseField, FIELD_VARIABLES } from './kit/field.js';
55
+ export type { FieldEquation } from './kit/field.js';
56
+ export { traceContour } from './kit/contour.js';
57
+ export { colorAt, fillAt, lerpFillScale, lerpScale, readFillScale, readScale } from './kit/scale.js';
58
+ export { SYSTEMS, SYSTEMS_AND_PLOT } from './kit/placement.js';
59
+ export { IDENTITY_MATRIX, isIdentityMatrix, lerpMatrix, lineThrough, readMatrix, transformedMap, warpedMap, } from './kit/coords.js';
60
+ export type { Matrix2, Warp } from './kit/coords.js';
61
+ export { braceOutline } from './kit/brace.js';
62
+ export { GRAPH_LAYOUTS, layOut } from './structures/graph-layout.js';
63
+ export type { GraphEdge, GraphLayout } from './structures/graph-layout.js';
64
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACH,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,GACrI,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CA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E,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/engine.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The math **kit**: what the nodes share, and what a copied one does not copy.
3
+ *
4
+ * `ms add` writes a node's own files into a project and rewrites its reach for
5
+ * these to `@motionscript/math`, so MathJax, the morph and every shared class
6
+ * stay a real dependency with one identity.
7
+ */
8
+ export { blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER, } from './tex/geometry.js';
9
+ export { defaultLatexMorph } from './tex/tween.js';
10
+ export { Latex } from './tex/node.js';
11
+ export { lerpPartFills, partPaint, readPartFills, withPartFill } from './kit/part-fills.js';
12
+ export { FILL_PAINT, OUTLINE_TRIM, STROKE_PAINT } from './kit/withdrawn.js';
13
+ export { createBoundedCache } from './kit/cache.js';
14
+ export { CoordinateSystem } from './kit/system.js';
15
+ // A number plane is axes with a grid, so a copied one extends these rather than a copy of them.
16
+ export { Axes2d } from './systems/axes2d.js';
17
+ export { openPlane, placeOnMap } from './kit/place.js';
18
+ export { Mark } from './kit/mark.js';
19
+ export { axisScale, cartesianMap, resolveInterval, PIXEL_MAP } from './kit/coords.js';
20
+ export { compileExpression, compileExpressionCached, expressionVocabulary, MATH_DIALECT } from './kit/expression.js';
21
+ export { equationError, equationParams, parseEquation, EQUATION_VARIABLES } from './kit/equation.js';
22
+ export { lerpDomain, lerpParams, lerpSource, readSource, revisionOf, scopeFor, UNSET_PARAM } from './kit/source.js';
23
+ export { sampleCurve } from './kit/sampler.js';
24
+ export { formatTick, ticksFor } from './kit/ticks.js';
25
+ export { boundsOfRuns, clamp, inflate, runsToPath, stated } from './kit/geometry.js';
26
+ export { curveNamed, curveOf } from './kit/curve.js';
27
+ export { along, AXIS_COLOR, drawLabels, drawn, lerpInterval, PLOT_COLOR, readInterval, withoutTips } from './kit/furniture.js';
28
+ export { add, between, followed, FollowMark, grown, heading, quadOf } from './kit/follow.js';
29
+ export { parseSpaceCurve, parseSurface, spaceCurveError, spaceCurveParams, surfaceError, surfaceParams, EQUATION_KINDS, EQUATION_VARIABLES_3D, } from './kit/equation3d.js';
30
+ export { aim, graphSpace, spaceOf } from './three/space.js';
31
+ export { drawLabel3D } from './three/label3d.js';
32
+ // A traced path is a plot whose span follows a value, so a copied one extends this rather than a copy of it.
33
+ export { FunctionPlot } from './plots/function-plot.js';
34
+ export { FieldMark } from './kit/field-mark.js';
35
+ export { fieldError, fieldParams, parseField, FIELD_VARIABLES } from './kit/field.js';
36
+ export { traceContour } from './kit/contour.js';
37
+ export { colorAt, fillAt, lerpFillScale, lerpScale, readFillScale, readScale } from './kit/scale.js';
38
+ export { SYSTEMS, SYSTEMS_AND_PLOT } from './kit/placement.js';
39
+ export { IDENTITY_MATRIX, isIdentityMatrix, lerpMatrix, lineThrough, readMatrix, transformedMap, warpedMap, } from './kit/coords.js';
40
+ export { braceOutline } from './kit/brace.js';
41
+ export { GRAPH_LAYOUTS, layOut } from './structures/graph-layout.js';
42
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACH,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,GACrI,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,E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AE,qBAAqB,GACvI,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,6GAA6G;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACH,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,GACpG,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["/**\r\n * The math **kit**: what the nodes share, and what a copied one does not copy.\r\n *\r\n * `ms add` writes a node's own files into a project and rewrites its reach for\r\n * these to `@motionscript/math`, so MathJax, the morph and every shared class\r\n * stay a real dependency with one identity.\r\n */\r\nexport {\r\n blankLatex, buildLatexPath, findLatexParts, latexPartNames, LatexError, LatexNotLoaded, loadMathJax, mathJaxLoaded, MATHJAX_LOADER,\r\n} from './tex/geometry';\r\nexport type { LatexPart, LatexToken, LatexPathResult } from './tex/geometry';\r\nexport { defaultLatexMorph } from './tex/tween';\r\nexport type { AnimatedToken, LatexMorphStrategy } from './tex/tween';\r\nexport { Latex } from './tex/node';\r\nexport type { LatexProps, LatexStrategies } from './tex/node';\r\nexport { lerpPartFills, partPaint, readPartFills, withPartFill } from './kit/part-fills';\r\nexport type { PartFill, PartFillResolved } from './kit/part-fills';\r\nexport { FILL_PAINT, OUTLINE_TRIM, STROKE_PAINT } from './kit/withdrawn';\r\nexport { createBoundedCache } from './kit/cache';\r\nexport type { BoundedCache } from './kit/cache';\r\n\r\nexport { CoordinateSystem } from './kit/system';\r\n// A number plane is axes with a grid, so a copied one extends these rather than a copy of them.\r\nexport { Axes2d } from './systems/axes2d';\r\nexport type { Axes2dProps, AxisLayout } from './systems/axes2d';\r\nexport type { Anchored } from './kit/place';\r\nexport { openPlane, placeOnMap } from './kit/place';\r\nexport { Mark } from './kit/mark';\r\nexport { axisScale, cartesianMap, resolveInterval, PIXEL_MAP } from './kit/coords';\r\nexport type { AxisScale, AxisScaling, CartesianOptions, CoordinateMap, Interval } from './kit/coords';\r\nexport { compileExpression, compileExpressionCached, expressionVocabulary, MATH_DIALECT } from './kit/expression';\r\nexport type { CompiledExpression, ExpressionScope, ExpressionVocabulary } from './kit/expression';\r\nexport { equationError, equationParams, parseEquation, EQUATION_VARIABLES } from './kit/equation';\r\nexport type { Equation } from './kit/equation';\r\nexport { lerpDomain, lerpParams, lerpSource, readSource, revisionOf, scopeFor, UNSET_PARAM } from './kit/source';\r\nexport type { PlotSource } from './kit/source';\r\nexport { sampleCurve } from './kit/sampler';\r\nexport type { CurveProjection, SampleOptions } from './kit/sampler';\r\nexport { formatTick, ticksFor } from './kit/ticks';\r\nexport type { Ticks } from './kit/ticks';\r\nexport { boundsOfRuns, clamp, inflate, runsToPath, stated } from './kit/geometry';\r\nexport { curveNamed, curveOf } from './kit/curve';\r\nexport type { Curve } from './kit/curve';\r\nexport { along, AXIS_COLOR, drawLabels, drawn, lerpInterval, PLOT_COLOR, readInterval, withoutTips } from './kit/furniture';\r\nexport type { Label, LabelStyle } from './kit/furniture';\r\nexport { add, between, followed, FollowMark, grown, heading, quadOf } from './kit/follow';\r\nexport type { FollowProps, Parted, Quad, Retarget, Target } from './kit/follow';\r\nexport {\r\n parseSpaceCurve, parseSurface, spaceCurveError, spaceCurveParams, surfaceError, surfaceParams, EQUATION_KINDS, EQUATION_VARIABLES_3D,\r\n} from './kit/equation3d';\r\nexport type { EquationLanguage, SpaceCurveEquation, SurfaceEquation } from './kit/equation3d';\r\nexport { aim, graphSpace, spaceOf } from './three/space';\r\nexport type { GraphSpace } from './three/space';\r\nexport { drawLabel3D } from './three/label3d';\r\nexport type { LabelStyle3D } from './three/label3d';\r\n// A traced path is a plot whose span follows a value, so a copied one extends this rather than a copy of it.\r\nexport { FunctionPlot } from './plots/function-plot';\r\nexport type { FunctionPlotProps } from './plots/function-plot';\r\nexport { FieldMark } from './kit/field-mark';\r\nexport type { FieldProps, FieldSampler, FieldStroke } from './kit/field-mark';\r\nexport { fieldError, fieldParams, parseField, FIELD_VARIABLES } from './kit/field';\r\nexport type { FieldEquation } from './kit/field';\r\nexport { traceContour } from './kit/contour';\r\nexport { colorAt, fillAt, lerpFillScale, lerpScale, readFillScale, readScale } from './kit/scale';\r\nexport { SYSTEMS, SYSTEMS_AND_PLOT } from './kit/placement';\r\nexport {\r\n IDENTITY_MATRIX, isIdentityMatrix, lerpMatrix, lineThrough, readMatrix, transformedMap, warpedMap,\r\n} from './kit/coords';\r\nexport type { Matrix2, Warp } from './kit/coords';\r\nexport { braceOutline } from './kit/brace';\r\nexport { GRAPH_LAYOUTS, layOut } from './structures/graph-layout';\r\nexport type { GraphEdge, GraphLayout } from './structures/graph-layout';\r\n"]}
@@ -0,0 +1,30 @@
1
+ export * from './tex/node.js';
2
+ export * from './tex/matrix.js';
3
+ export * from './systems/number-line.js';
4
+ export * from './systems/axes2d.js';
5
+ export * from './systems/number-plane.js';
6
+ export * from './plots/function-plot.js';
7
+ export * from './plots/points-plot.js';
8
+ export * from './marks/plot-point.js';
9
+ export * from './marks/vector-arrow.js';
10
+ export * from './marks/curve-area.js';
11
+ export * from './marks/riemann-sum.js';
12
+ export * from './marks/tangent-line.js';
13
+ export * from './marks/drop-lines.js';
14
+ export * from './annotate/curly-brace.js';
15
+ export * from './annotate/angle-mark.js';
16
+ export * from './annotate/emphasis-mark.js';
17
+ export * from './three/axes3d.js';
18
+ export * from './three/surface-plot3d.js';
19
+ export * from './three/curve-plot3d.js';
20
+ export * from './three/plot-point3d.js';
21
+ export * from './three/vector-arrow3d.js';
22
+ export * from './systems/polar-plane.js';
23
+ export * from './plots/vector-field.js';
24
+ export * from './plots/stream-lines.js';
25
+ export * from './plots/traced-path.js';
26
+ export * from './structures/network-graph.js';
27
+ export * from './structures/sample-space.js';
28
+ export * from './engine.js';
29
+ export { NODES } from "./nodes.js";
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ export * from './tex/node.js';
2
+ export * from './tex/matrix.js';
3
+ export * from './systems/number-line.js';
4
+ export * from './systems/axes2d.js';
5
+ export * from './systems/number-plane.js';
6
+ export * from './plots/function-plot.js';
7
+ export * from './plots/points-plot.js';
8
+ export * from './marks/plot-point.js';
9
+ export * from './marks/vector-arrow.js';
10
+ export * from './marks/curve-area.js';
11
+ export * from './marks/riemann-sum.js';
12
+ export * from './marks/tangent-line.js';
13
+ export * from './marks/drop-lines.js';
14
+ export * from './annotate/curly-brace.js';
15
+ export * from './annotate/angle-mark.js';
16
+ export * from './annotate/emphasis-mark.js';
17
+ export * from './three/axes3d.js';
18
+ export * from './three/surface-plot3d.js';
19
+ export * from './three/curve-plot3d.js';
20
+ export * from './three/plot-point3d.js';
21
+ export * from './three/vector-arrow3d.js';
22
+ export * from './systems/polar-plane.js';
23
+ export * from './plots/vector-field.js';
24
+ export * from './plots/stream-lines.js';
25
+ export * from './plots/traced-path.js';
26
+ export * from './structures/network-graph.js';
27
+ export * from './structures/sample-space.js';
28
+ export * from './engine.js';
29
+ export { NODES } from "./nodes.js";
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export * from './tex/node';\r\nexport * from './tex/matrix';\r\nexport * from './systems/number-line';\r\nexport * from './systems/axes2d';\r\nexport * from './systems/number-plane';\r\nexport * from './plots/function-plot';\r\nexport * from './plots/points-plot';\r\nexport * from './marks/plot-point';\r\nexport * from './marks/vector-arrow';\r\nexport * from './marks/curve-area';\r\nexport * from './marks/riemann-sum';\r\nexport * from './marks/tangent-line';\r\nexport * from './marks/drop-lines';\r\nexport * from './annotate/curly-brace';\r\nexport * from './annotate/angle-mark';\r\nexport * from './annotate/emphasis-mark';\r\nexport * from './three/axes3d';\r\nexport * from './three/surface-plot3d';\r\nexport * from './three/curve-plot3d';\r\nexport * from './three/plot-point3d';\r\nexport * from './three/vector-arrow3d';\r\nexport * from './systems/polar-plane';\r\nexport * from './plots/vector-field';\r\nexport * from './plots/stream-lines';\r\nexport * from './plots/traced-path';\r\nexport * from './structures/network-graph';\r\nexport * from './structures/sample-space';\r\nexport * from './engine';\r\nexport { NODES } from \"./nodes\";\r\n"]}
@@ -0,0 +1,8 @@
1
+ import type { PathCommand, Vector2 } from "@motionscript/sdk";
2
+ /**
3
+ * A curly brace from `from` to `to`, bulging toward `out` (a unit vector) and
4
+ * `reach` deep at its tip: what a brace node draws, and a sample space beside
5
+ * its parts. Path commands, y-up.
6
+ */
7
+ export declare function braceOutline(from: Vector2, to: Vector2, out: Vector2, reach: number): PathCommand[];
8
+ //# sourceMappingURL=brace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brace.d.ts","sourceRoot":"","sources":["../../src/kit/brace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAM9D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAyBnG"}
@@ -0,0 +1,36 @@
1
+ import { add, between, heading } from "./follow.js";
2
+ /** How far a quarter circle's control points sit along its tangents, as a share of its radius. */
3
+ const QUARTER = 0.5523;
4
+ /**
5
+ * A curly brace from `from` to `to`, bulging toward `out` (a unit vector) and
6
+ * `reach` deep at its tip: what a brace node draws, and a sample space beside
7
+ * its parts. Path commands, y-up.
8
+ */
9
+ export function braceOutline(from, to, out, reach) {
10
+ const { unit, length } = heading(from, to);
11
+ if (length === 0)
12
+ return [];
13
+ const r = Math.min(reach / 2, length / 4);
14
+ const mid = between(from, to);
15
+ const lift = (p, k) => add(p, out, k * r);
16
+ const along = (p, k) => add(p, unit, k * r);
17
+ const h = QUARTER;
18
+ const curve = (c1, c2, end) => ({
19
+ type: "C", x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: end.x, y: end.y,
20
+ });
21
+ const a = lift(along(from, 1), 1);
22
+ const b = lift(along(mid, -1), 1);
23
+ const tip = lift(mid, 2);
24
+ const c = lift(along(mid, 1), 1);
25
+ const d = lift(along(to, -1), 1);
26
+ return [
27
+ { type: "M", x: from.x, y: from.y },
28
+ curve(lift(from, h), lift(along(from, 1 - h), 1), a),
29
+ { type: "L", x: b.x, y: b.y },
30
+ curve(lift(along(mid, -1 + h), 1), lift(mid, 2 - h), tip),
31
+ curve(lift(mid, 2 - h), lift(along(mid, 1 - h), 1), c),
32
+ { type: "L", x: d.x, y: d.y },
33
+ curve(lift(along(to, -1 + h), 1), lift(to, h), to),
34
+ ];
35
+ }
36
+ //# sourceMappingURL=brace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brace.js","sourceRoot":"","sources":["../../src/kit/brace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEjD,kGAAkG;AAClG,MAAM,OAAO,GAAG,MAAM,CAAC;AAEvB;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,EAAW,EAAE,GAAY,EAAE,KAAa;IAChF,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC3C,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,CAAC,CAAU,EAAE,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,CAAC,GAAG,OAAO,CAAC;IAClB,MAAM,KAAK,GAAG,CAAC,EAAW,EAAE,EAAW,EAAE,GAAY,EAAe,EAAE,CAAC,CAAC;QACpE,IAAI,EAAE,GAAG,EAAE,EAAE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,GAAG,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACtD,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QAC7B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;KACrD,CAAC;AACN,CAAC","sourcesContent":["import type { PathCommand, Vector2 } from \"@motionscript/sdk\";\r\nimport { add, between, heading } from \"./follow\";\r\n\r\n/** How far a quarter circle's control points sit along its tangents, as a share of its radius. */\r\nconst QUARTER = 0.5523;\r\n\r\n/**\r\n * A curly brace from `from` to `to`, bulging toward `out` (a unit vector) and\r\n * `reach` deep at its tip: what a brace node draws, and a sample space beside\r\n * its parts. Path commands, y-up.\r\n */\r\nexport function braceOutline(from: Vector2, to: Vector2, out: Vector2, reach: number): PathCommand[] {\r\n const { unit, length } = heading(from, to);\r\n if (length === 0) return [];\r\n const r = Math.min(reach / 2, length / 4);\r\n const mid = between(from, to);\r\n const lift = (p: Vector2, k: number) => add(p, out, k * r);\r\n const along = (p: Vector2, k: number) => add(p, unit, k * r);\r\n const h = QUARTER;\r\n const curve = (c1: Vector2, c2: Vector2, end: Vector2): PathCommand => ({\r\n type: \"C\", x1: c1.x, y1: c1.y, x2: c2.x, y2: c2.y, x: end.x, y: end.y,\r\n });\r\n const a = lift(along(from, 1), 1);\r\n const b = lift(along(mid, -1), 1);\r\n const tip = lift(mid, 2);\r\n const c = lift(along(mid, 1), 1);\r\n const d = lift(along(to, -1), 1);\r\n return [\r\n { type: \"M\", x: from.x, y: from.y },\r\n curve(lift(from, h), lift(along(from, 1 - h), 1), a),\r\n { type: \"L\", x: b.x, y: b.y },\r\n curve(lift(along(mid, -1 + h), 1), lift(mid, 2 - h), tip),\r\n curve(lift(mid, 2 - h), lift(along(mid, 1 - h), 1), c),\r\n { type: \"L\", x: d.x, y: d.y },\r\n curve(lift(along(to, -1 + h), 1), lift(to, h), to),\r\n ];\r\n}\r\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A bounded, least-recently-used memo.
3
+ *
4
+ * Sits under `geometry.ts`, and imports nothing, so it is testable in bare Node:
5
+ * everything else in this package reaches MathJax's browser adaptor at module
6
+ * scope, which means a test that touches it needs a DOM. The one piece of logic
7
+ * here worth being sure about — what gets thrown away when the memo is full —
8
+ * is exactly the piece that does not need one.
9
+ *
10
+ * Least-recently-used rather than oldest-first, and that matters for the shape
11
+ * of work this sees. A `Latex` node re-resolves its formula whenever `fontSize`
12
+ * changes, so animating the size of one formula inserts a fresh key every frame
13
+ * and would, under a first-in-first-out rule, walk the whole memo out of it in a
14
+ * couple of seconds — including the entries for every *other* formula in the
15
+ * scene, none of which had done anything wrong. Touching an entry on read keeps
16
+ * the formulas that are actually being asked for ahead of the ones streaming
17
+ * past.
18
+ */
19
+ export interface BoundedCache<T> {
20
+ get(key: string): T | undefined;
21
+ set(key: string, value: T): void;
22
+ /** Entries held. For tests and for anyone measuring. */
23
+ readonly size: number;
24
+ }
25
+ /**
26
+ * @param limit Most entries to hold. One more arriving evicts the least
27
+ * recently read or written.
28
+ */
29
+ export declare function createBoundedCache<T>(limit: number): BoundedCache<T>;
30
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/kit/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC3B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACjC,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CA8BpE"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * A bounded, least-recently-used memo.
3
+ *
4
+ * Sits under `geometry.ts`, and imports nothing, so it is testable in bare Node:
5
+ * everything else in this package reaches MathJax's browser adaptor at module
6
+ * scope, which means a test that touches it needs a DOM. The one piece of logic
7
+ * here worth being sure about — what gets thrown away when the memo is full —
8
+ * is exactly the piece that does not need one.
9
+ *
10
+ * Least-recently-used rather than oldest-first, and that matters for the shape
11
+ * of work this sees. A `Latex` node re-resolves its formula whenever `fontSize`
12
+ * changes, so animating the size of one formula inserts a fresh key every frame
13
+ * and would, under a first-in-first-out rule, walk the whole memo out of it in a
14
+ * couple of seconds — including the entries for every *other* formula in the
15
+ * scene, none of which had done anything wrong. Touching an entry on read keeps
16
+ * the formulas that are actually being asked for ahead of the ones streaming
17
+ * past.
18
+ */
19
+ /**
20
+ * @param limit Most entries to hold. One more arriving evicts the least
21
+ * recently read or written.
22
+ */
23
+ export function createBoundedCache(limit) {
24
+ // Insertion order is the eviction order, which is what makes a plain `Map`
25
+ // an LRU as long as every read re-inserts.
26
+ const entries = new Map();
27
+ return {
28
+ get(key) {
29
+ if (!entries.has(key))
30
+ return undefined;
31
+ const value = entries.get(key);
32
+ // Delete-then-set moves the key to the end, so the next eviction
33
+ // takes the genuinely coldest entry rather than the oldest one.
34
+ entries.delete(key);
35
+ entries.set(key, value);
36
+ return value;
37
+ },
38
+ set(key, value) {
39
+ entries.delete(key);
40
+ entries.set(key, value);
41
+ while (entries.size > limit) {
42
+ const coldest = entries.keys().next().value;
43
+ if (coldest === undefined)
44
+ break;
45
+ entries.delete(coldest);
46
+ }
47
+ },
48
+ get size() {
49
+ return entries.size;
50
+ },
51
+ };
52
+ }
53
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/kit/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAI,KAAa;IAC/C,2EAA2E;IAC3E,2CAA2C;IAC3C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAa,CAAC;IAErC,OAAO;QACH,GAAG,CAAC,GAAG;YACH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,OAAO,SAAS,CAAC;YACxC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAM,CAAC;YACpC,iEAAiE;YACjE,gEAAgE;YAChE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACxB,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,GAAG,CAAC,GAAG,EAAE,KAAK;YACV,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACxB,OAAO,OAAO,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC;gBAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;gBAC5C,IAAI,OAAO,KAAK,SAAS;oBAAE,MAAM;gBACjC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;QAED,IAAI,IAAI;YACJ,OAAO,OAAO,CAAC,IAAI,CAAC;QACxB,CAAC;KACJ,CAAC;AACN,CAAC","sourcesContent":["/**\r\n * A bounded, least-recently-used memo.\r\n *\r\n * Sits under `geometry.ts`, and imports nothing, so it is testable in bare Node:\r\n * everything else in this package reaches MathJax's browser adaptor at module\r\n * scope, which means a test that touches it needs a DOM. The one piece of logic\r\n * here worth being sure about — what gets thrown away when the memo is full —\r\n * is exactly the piece that does not need one.\r\n *\r\n * Least-recently-used rather than oldest-first, and that matters for the shape\r\n * of work this sees. A `Latex` node re-resolves its formula whenever `fontSize`\r\n * changes, so animating the size of one formula inserts a fresh key every frame\r\n * and would, under a first-in-first-out rule, walk the whole memo out of it in a\r\n * couple of seconds — including the entries for every *other* formula in the\r\n * scene, none of which had done anything wrong. Touching an entry on read keeps\r\n * the formulas that are actually being asked for ahead of the ones streaming\r\n * past.\r\n */\r\n\r\nexport interface BoundedCache<T> {\r\n get(key: string): T | undefined;\r\n set(key: string, value: T): void;\r\n /** Entries held. For tests and for anyone measuring. */\r\n readonly size: number;\r\n}\r\n\r\n/**\r\n * @param limit Most entries to hold. One more arriving evicts the least\r\n * recently read or written.\r\n */\r\nexport function createBoundedCache<T>(limit: number): BoundedCache<T> {\r\n // Insertion order is the eviction order, which is what makes a plain `Map`\r\n // an LRU as long as every read re-inserts.\r\n const entries = new Map<string, T>();\r\n\r\n return {\r\n get(key) {\r\n if (!entries.has(key)) return undefined;\r\n const value = entries.get(key) as T;\r\n // Delete-then-set moves the key to the end, so the next eviction\r\n // takes the genuinely coldest entry rather than the oldest one.\r\n entries.delete(key);\r\n entries.set(key, value);\r\n return value;\r\n },\r\n\r\n set(key, value) {\r\n entries.delete(key);\r\n entries.set(key, value);\r\n while (entries.size > limit) {\r\n const coldest = entries.keys().next().value;\r\n if (coldest === undefined) break;\r\n entries.delete(coldest);\r\n }\r\n },\r\n\r\n get size() {\r\n return entries.size;\r\n },\r\n };\r\n}\r\n"]}
@@ -0,0 +1,8 @@
1
+ import type { Vector2 } from "@motionscript/sdk";
2
+ /**
3
+ * The lines along which a function of two variables is zero, over a box of
4
+ * graph values: marching squares, its crossings placed by linear interpolation
5
+ * and joined end to end into runs. Points are graph coordinates.
6
+ */
7
+ export declare function traceContour(f: (x: number, y: number) => number, [x0, x1]: readonly [number, number], [y0, y1]: readonly [number, number], columns: number, rows: number): Vector2[][];
8
+ //# sourceMappingURL=contour.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contour.d.ts","sourceRoot":"","sources":["../../src/kit/contour.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,YAAY,CACxB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,EACnC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACb,OAAO,EAAE,EAAE,CAgFb"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The lines along which a function of two variables is zero, over a box of
3
+ * graph values: marching squares, its crossings placed by linear interpolation
4
+ * and joined end to end into runs. Points are graph coordinates.
5
+ */
6
+ export function traceContour(f, [x0, x1], [y0, y1], columns, rows) {
7
+ if (!(x1 > x0) || !(y1 > y0) || columns < 1 || rows < 1)
8
+ return [];
9
+ const dx = (x1 - x0) / columns;
10
+ const dy = (y1 - y0) / rows;
11
+ const stride = columns + 1;
12
+ const values = new Float64Array(stride * (rows + 1));
13
+ for (let j = 0; j <= rows; j++) {
14
+ for (let i = 0; i <= columns; i++)
15
+ values[j * stride + i] = f(x0 + i * dx, y0 + j * dy);
16
+ }
17
+ // A crossing lives on a grid edge, which is its name: two cells sharing the edge share the point.
18
+ const points = new Map();
19
+ const edgeCount = stride * (rows + 1);
20
+ const crossing = (i, j, vertical) => {
21
+ const a = values[j * stride + i];
22
+ const b = vertical ? values[(j + 1) * stride + i] : values[j * stride + i + 1];
23
+ if (!Number.isFinite(a) || !Number.isFinite(b) || a < 0 === b < 0)
24
+ return null;
25
+ const key = (vertical ? edgeCount : 0) + j * stride + i;
26
+ if (!points.has(key)) {
27
+ const t = a / (a - b);
28
+ points.set(key, vertical ? { x: x0 + i * dx, y: y0 + (j + t) * dy } : { x: x0 + (i + t) * dx, y: y0 + j * dy });
29
+ }
30
+ return key;
31
+ };
32
+ const next = new Map();
33
+ const join = (a, b) => {
34
+ if (a === null || b === null)
35
+ return;
36
+ (next.get(a) ?? next.set(a, []).get(a)).push(b);
37
+ (next.get(b) ?? next.set(b, []).get(b)).push(a);
38
+ };
39
+ for (let j = 0; j < rows; j++) {
40
+ for (let i = 0; i < columns; i++) {
41
+ const bottom = crossing(i, j, false);
42
+ const top = crossing(i, j + 1, false);
43
+ const left = crossing(i, j, true);
44
+ const right = crossing(i + 1, j, true);
45
+ const found = [bottom, right, top, left].filter((edge) => edge !== null);
46
+ if (found.length === 2)
47
+ join(found[0], found[1]);
48
+ else if (found.length === 4) {
49
+ // A saddle: the centre's sign says which pairs of edges the curve joins.
50
+ const centre = f(x0 + (i + 0.5) * dx, y0 + (j + 0.5) * dy);
51
+ const corner = values[j * stride + i];
52
+ if (centre < 0 === corner < 0) {
53
+ join(bottom, right);
54
+ join(top, left);
55
+ }
56
+ else {
57
+ join(bottom, left);
58
+ join(top, right);
59
+ }
60
+ }
61
+ }
62
+ }
63
+ const runs = [];
64
+ const used = new Set();
65
+ const walk = (from) => {
66
+ const run = [points.get(from)];
67
+ used.add(from);
68
+ let at = from;
69
+ for (;;) {
70
+ const onward = (next.get(at) ?? []).find((key) => !used.has(key));
71
+ if (onward === undefined)
72
+ break;
73
+ used.add(onward);
74
+ run.push(points.get(onward));
75
+ at = onward;
76
+ }
77
+ return run;
78
+ };
79
+ // Open runs first, from their ends, so each is one run and not two halves.
80
+ for (const [key, links] of next) {
81
+ if (links.length === 1 && !used.has(key))
82
+ runs.push(walk(key));
83
+ }
84
+ for (const key of next.keys()) {
85
+ if (used.has(key))
86
+ continue;
87
+ const run = walk(key);
88
+ run.push(run[0]);
89
+ runs.push(run);
90
+ }
91
+ return runs.filter((run) => run.length > 1);
92
+ }
93
+ //# sourceMappingURL=contour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contour.js","sourceRoot":"","sources":["../../src/kit/contour.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CACxB,CAAmC,EACnC,CAAC,EAAE,EAAE,EAAE,CAA4B,EACnC,CAAC,EAAE,EAAE,EAAE,CAA4B,EACnC,OAAe,EACf,IAAY;IAEZ,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IACnE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;IAC5B,MAAM,MAAM,GAAG,OAAO,GAAG,CAAC,CAAC;IAC3B,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;IACrD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC,EAAE;YAAE,MAAM,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,kGAAkG;IAClG,MAAM,MAAM,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AE,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAClE,IAAI,MAAM,KAAK,SAAS;gBAAE,MAAM;YAChC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,CAAC;YAC9B,EAAE,GAAG,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC,CAAC;IACF,2EAA2E;IAC3E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { Vector2 } from \"@motionscript/sdk\";\r\n\r\n/**\r\n * The lines along which a function of two variables is zero, over a box of\r\n * graph values: marching squares, its crossings placed by linear interpolation\r\n * and joined end to end into runs. Points are graph coordinates.\r\n */\r\nexport function traceContour(\r\n f: (x: number, y: number) => number,\r\n [x0, x1]: readonly [number, number],\r\n [y0, y1]: readonly [number, number],\r\n columns: number,\r\n rows: number,\r\n): Vector2[][] {\r\n if (!(x1 > x0) || !(y1 > y0) || columns < 1 || rows < 1) return [];\r\n const dx = (x1 - x0) / columns;\r\n const dy = (y1 - y0) / rows;\r\n const stride = columns + 1;\r\n const values = new Float64Array(stride * (rows + 1));\r\n for (let j = 0; j <= rows; j++) {\r\n for (let i = 0; i <= columns; i++) values[j * stride + i] = f(x0 + i * dx, y0 + j * dy);\r\n }\r\n\r\n // A crossing lives on a grid edge, which is its name: two cells sharing the edge share the point.\r\n const points = new Map<number, Vector2>();\r\n const edgeCount = stride * (rows + 1);\r\n const crossing = (i: number, j: number, vertical: boolean): number | null => {\r\n const a = values[j * stride + i];\r\n const b = vertical ? values[(j + 1) * stride + i] : values[j * stride + i + 1];\r\n if (!Number.isFinite(a) || !Number.isFinite(b) || a < 0 === b < 0) return null;\r\n const key = (vertical ? edgeCount : 0) + j * stride + i;\r\n if (!points.has(key)) {\r\n const t = a / (a - b);\r\n points.set(key, vertical ? { x: x0 + i * dx, y: y0 + (j + t) * dy } : { x: x0 + (i + t) * dx, y: y0 + j * dy });\r\n }\r\n return key;\r\n };\r\n\r\n const next = new Map<number, number[]>();\r\n const join = (a: number | null, b: number | null): void => {\r\n if (a === null || b === null) return;\r\n (next.get(a) ?? next.set(a, []).get(a)!).push(b);\r\n (next.get(b) ?? next.set(b, []).get(b)!).push(a);\r\n };\r\n for (let j = 0; j < rows; j++) {\r\n for (let i = 0; i < columns; i++) {\r\n const bottom = crossing(i, j, false);\r\n const top = crossing(i, j + 1, false);\r\n const left = crossing(i, j, true);\r\n const right = crossing(i + 1, j, true);\r\n const found = [bottom, right, top, left].filter((edge) => edge !== null);\r\n if (found.length === 2) join(found[0], found[1]);\r\n else if (found.length === 4) {\r\n // A saddle: the centre's sign says which pairs of edges the curve joins.\r\n const centre = f(x0 + (i + 0.5) * dx, y0 + (j + 0.5) * dy);\r\n const corner = values[j * stride + i];\r\n if (centre < 0 === corner < 0) {\r\n join(bottom, right);\r\n join(top, left);\r\n } else {\r\n join(bottom, left);\r\n join(top, right);\r\n }\r\n }\r\n }\r\n }\r\n\r\n const runs: Vector2[][] = [];\r\n const used = new Set<number>();\r\n const walk = (from: number): Vector2[] => {\r\n const run: Vector2[] = [points.get(from)!];\r\n used.add(from);\r\n let at = from;\r\n for (;;) {\r\n const onward = (next.get(at) ?? []).find((key) => !used.has(key));\r\n if (onward === undefined) break;\r\n used.add(onward);\r\n run.push(points.get(onward)!);\r\n at = onward;\r\n }\r\n return run;\r\n };\r\n // Open runs first, from their ends, so each is one run and not two halves.\r\n for (const [key, links] of next) {\r\n if (links.length === 1 && !used.has(key)) runs.push(walk(key));\r\n }\r\n for (const key of next.keys()) {\r\n if (used.has(key)) continue;\r\n const run = walk(key);\r\n run.push(run[0]);\r\n runs.push(run);\r\n }\r\n return runs.filter((run) => run.length > 1);\r\n}\r\n"]}