@algorisys/tinyfly 0.116.0 → 0.117.0

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.
package/README.md CHANGED
@@ -47,7 +47,7 @@ A lightweight, API-driven animation engine and visual editor for creating high-p
47
47
  - **Full screen** - `data-fullscreen="true"` adds a button that fills the screen with the figure, through the Fullscreen API or, on iPhone, an overlay; the drawing scales to the screen whatever the page's figure CSS says
48
48
  - **Scenarios** - Several timelines on one figure, and the reader chooses which plays: a group of options, a stepped slider, or clickable parts of the SVG (`data-tinyfly-choose`). Switching undoes the previous scenario's drawing and keeps the reader at the same step
49
49
  - **Authoring kit** - `lesson()` step builder and diagram primitives (array cells, pointer, stack, queue / channel, table, pipeline) in `@algorisys/tinyfly/teach`
50
- - **Maths animations** - `@algorisys/tinyfly/math`: figures as JSON (a grid a matrix warps, î and ĵ, vectors, function plots that break at asymptotes, polygons whose area shows the determinant, eigenlines, TeX labels; calculus: tangents and secants with exact slopes, Riemann sums, signed areas, Taylor polynomials from symbolic derivatives, limits), a built-in TeX subset (fractions, roots, sums and integrals with limits, matrices, Greek, live values) whose equations rewrite step by step with terms gliding, and ready linear algebra and calculus figures. One layout feeds lesson-page embeds (`<figure data-tinyfly-math>`, stepped with captions and questions), explorables where readers drag î and ĵ, and 9:16 or 16:9 videos ([guide](docs/math.md))
50
+ - **Maths animations** - `@algorisys/tinyfly/math`: figures as JSON (a grid a matrix warps, î and ĵ, vectors, function plots that break at asymptotes, polygons whose area shows the determinant, eigenlines, TeX labels; calculus: tangents and secants with exact slopes, Riemann sums, signed areas, Taylor polynomials from symbolic derivatives, limits; probability: seeded histograms, distributions with shaded probabilities, a Galton board, the central limit theorem, Monte Carlo π, regression and Bayes as areas), a built-in TeX subset (fractions, roots, sums and integrals with limits, matrices, Greek, live values) whose equations rewrite step by step with terms gliding, and ready linear algebra, calculus and probability figures. One layout feeds lesson-page embeds (`<figure data-tinyfly-math>`, stepped with captions and questions), explorables where readers drag î and ĵ, and 9:16 or 16:9 videos ([guide](docs/math.md))
51
51
  - **Build tools** - `npx @algorisys/tinyfly validate` catches broken figures in CI; `render` writes a frame to static SVG for RSS, email and print
52
52
 
53
53
  ### Video from Code
@@ -284,7 +284,7 @@ GSAP-shaped functions at the top level. Teaching embeds are included: add
284
284
  itself.
285
285
 
286
286
  ```html
287
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly.iife.js"></script>
287
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly.iife.js"></script>
288
288
  <script>
289
289
  tinyfly.to('.box', { x: 200, rotate: 90, duration: 1, ease: 'power2.out' })
290
290
 
@@ -321,7 +321,7 @@ A teaching figure needs no code at all:
321
321
  <script type="application/json" data-tinyfly-timeline>{ …timeline JSON with markers… }</script>
322
322
  <figcaption>Appending to a full slice</figcaption>
323
323
  </figure>
324
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly.iife.js" data-tinyfly-auto></script>
324
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly.iife.js" data-tinyfly-auto></script>
325
325
  ```
326
326
 
327
327
  See [Teaching Animations](docs/teaching.md).
@@ -420,7 +420,7 @@ Without a build step, the player bundle puts the same functions on a `tinyfly` g
420
420
  <div data-tinyfly="box" style="width: 60px; height: 60px; background: #4a9eff;"></div>
421
421
  </div>
422
422
 
423
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly-player.iife.js"></script>
423
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-player.iife.js"></script>
424
424
  <script>
425
425
  tinyfly.play('#animation', './animation.json', { loop: -1 })
426
426
  </script>
@@ -529,7 +529,7 @@ Or skip the code entirely with declarative embeds (see [Teaching Animations](doc
529
529
  <svg viewBox="0 0 720 200">…</svg>
530
530
  <script type="application/json" data-tinyfly-timeline>{ …timeline JSON… }</script>
531
531
  </figure>
532
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
532
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
533
533
  ```
534
534
 
535
535
  ### Audio / Video Sync
@@ -839,7 +839,7 @@ Characters browser suite checks 74 desktop/mobile scenarios per browser.
839
839
  | Docs viewer and `llms.txt` (`src/docs`) | 18 |
840
840
  | Embeds, teaching kit, framework hooks, landing (`src/embed`, `src/teach`, `src/frameworks`, `src/landing`) | 33 |
841
841
  | Headless rendering and audio (`src/headless`) | 63 |
842
- | Maths figures, TeX, calculus, equation steps, embeds and explorables (`src/math`) | 76 |
842
+ | Maths figures, TeX, calculus, probability, equation steps, embeds and explorables (`src/math`) | 99 |
843
843
  | Entry boundaries | 3 |
844
844
 
845
845
  ## Contributing
@@ -1143,7 +1143,7 @@ The dialog shows the generated HTML/JavaScript code with a **Copy Code** button.
1143
1143
  **Steps to embed:**
1144
1144
  1. Build the player: `npm run build:player`
1145
1145
  2. Copy `lib/player/tinyfly-player.iife.js` to your project (or load
1146
- `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly-player.iife.js`
1146
+ `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-player.iife.js`
1147
1147
  instead; see [Deployment](DEPLOYMENT.md))
1148
1148
  3. Copy the generated code into your HTML
1149
1149
  4. Adjust the script `src` path if needed
package/docs/examples.md CHANGED
@@ -743,7 +743,7 @@ For simple website embedding without a build system.
743
743
  </html>
744
744
  ```
745
745
 
746
- Build the player with `npm run build:player` to generate `lib/player/tinyfly-player.iife.js`, or load it from the CDN: `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly-player.iife.js`.
746
+ Build the player with `npm run build:player` to generate `lib/player/tinyfly-player.iife.js`, or load it from the CDN: `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-player.iife.js`.
747
747
 
748
748
  ---
749
749
 
@@ -185,7 +185,7 @@ with a GSAP-style call (durations are in seconds here):
185
185
  ```html
186
186
  <div class="box" style="width:60px;height:60px;background:#4a9eff"></div>
187
187
 
188
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly.iife.js"></script>
188
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly.iife.js"></script>
189
189
  <script>
190
190
  tinyfly.to('.box', { x: 200, duration: 1 })
191
191
  </script>
@@ -74,7 +74,7 @@ Without a build step, the all-in-one bundle exposes the same functions on a
74
74
  global — `tinyfly.to()`, `tinyfly.timeline()` and so on:
75
75
 
76
76
  ```html
77
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly.iife.js"></script>
77
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly.iife.js"></script>
78
78
  <script>
79
79
  tinyfly.to('.box', { x: 200, duration: 1 })
80
80
  </script>
package/docs/llm-guide.md CHANGED
@@ -272,7 +272,9 @@ or `scale`: those belong to the figure's target. The same figure plays in a
272
272
  lesson page (`<figure data-tinyfly-math>`), an explorable and a video
273
273
  (`mathTarget`). Calculus items (`tangent`, `riemann`, `area`, `taylor`, a
274
274
  `point` with `on` and `x`) take numbers or number-value names for `at`, `n`,
275
- `to`, `order`, and publish `\\val{ID.slope}`, `ID.sum`, `ID.value` for TeX. See `docs/math.md`.
275
+ `to`, `order`, and publish `\\val{ID.slope}`, `ID.sum`, `ID.value` for TeX. Probability items
276
+ (`histogram`, `distribution`, `galton`, `scatter`, `bayes`) take a distribution as data
277
+ (`{ kind: 'normal', mean: 'mu', sd: 1 }`) and draw seeded samples, never `Math.random`. See `docs/math.md`.
276
278
 
277
279
  ## Your own behaviours
278
280
 
package/docs/maps.md CHANGED
@@ -14,8 +14,8 @@ On a page with no build step, load the maps add-on after the browser bundle; it
14
14
  adds to the same `tinyfly` global:
15
15
 
16
16
  ```html
17
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly.iife.js"></script>
18
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly-maps.iife.js"></script>
17
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly.iife.js"></script>
18
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-maps.iife.js"></script>
19
19
  ```
20
20
 
21
21
  It is a separate script because the offline world map it carries adds about
package/docs/math.md CHANGED
@@ -78,6 +78,12 @@ Some names are reserved, because a track on them would move the whole figure:
78
78
  | `area` | `expr`, `from`, `to`, `lower?` (another function), `negativeColor?`, `fillOpacity?` |
79
79
  | `taylor` | `expr`, `at`, `order` (0–20; a fractional order grows the next term in), `domain?` |
80
80
 
81
+ | `histogram` | `distribution`, `count` (samples so far), `bins?: [from, to, n]`, `scale?: 'density' \| 'count'`, `curve?`, `seed?` |
82
+ | `distribution` | `distribution`, `shade?: [a, b]` (P(a ≤ X ≤ b)), `domain?` |
83
+ | `galton` | `rows?`, `balls` (fractional: the next ball on its way), `spacing?`, `top?`, `seed?` |
84
+ | `scatter` | `points: { kind: 'uniform', x, y }` or `{ kind: 'linear', slope, intercept, noise, x }`, `count`, `inside?` (an expression in x and y, true when ≤ 0), `fit?`, `seed?` |
85
+ | `bayes` | `prior`, `truePositive`, `falsePositive`, `at?`, `size?`, `labels?` |
86
+
81
87
  `point` also rides a curve: `{ on: 'sin(x)', x: 'p' }` is the point (p, sin p), and
82
88
  `hollow: true` draws an open circle for a hole or a limit. `function` takes
83
89
  `derivative: n` to plot f′, f″ … and `dashed: true`.
@@ -97,6 +103,25 @@ Items work out numbers that TeX can show with `\val{…}`:
97
103
  | `area` | `ID.value` (the signed integral) |
98
104
  | `point` on a curve | `ID.x`, `ID.y` |
99
105
  | `taylor` | `ID.order`, `ID.degree` (its whole part) |
106
+ | `histogram` | `ID.count`, `ID.mean`, `ID.sd` (of the samples so far) |
107
+ | `distribution` | `ID.p` (the shaded probability), `ID.mean`, `ID.sd` |
108
+ | `galton` | `ID.landed` |
109
+ | `scatter` | `ID.count`, `ID.inside`, `ID.ratio`, `ID.slope`, `ID.intercept`, `ID.r` |
110
+ | `bayes` | `ID.prior`, `ID.posterior`, `ID.positive`, `ID.truePositive`, `ID.falsePositive` |
111
+
112
+ ### Distributions and randomness
113
+
114
+ A distribution is data: `{ kind: 'normal', mean, sd }`, `uniform` (`min`,
115
+ `max`), `exponential` (`rate`), `binomial` (`n`, `p`), `poisson` (`rate`),
116
+ `dice` (`count`, `sides`), or `{ kind: 'mean', of, count }`, the average of
117
+ `count` draws (what the central limit theorem is about). Any of its numbers
118
+ may be a value name, so a slider moves the mean or n. `density`, `meanOf`,
119
+ `sdOf`, `sample` and `samples` work on them directly.
120
+
121
+ Every sample comes from a seed (the item id unless `seed` is given), through
122
+ the engine's `createRandom`, `randomNormal` and `shuffled`. A histogram that
123
+ grows from 10 to 1000 samples keeps its first 10, and every render, video and
124
+ reader sees the same draws.
100
125
 
101
126
  Slopes, derivative plots and Taylor coefficients come from symbolic
102
127
  differentiation of the expression (`differentiate`, `compileDerivative`), so
@@ -162,7 +187,7 @@ lesson's step options (`duration`, `easing`, `delay`).
162
187
  <figcaption>The determinant is the area of the unit square after the map.</figcaption>
163
188
  </figure>
164
189
 
165
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly-math.iife.js" data-tinyfly-auto></script>
190
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-math.iife.js" data-tinyfly-auto></script>
166
191
  ```
167
192
 
168
193
  The figure draws itself into an SVG and redraws from the timeline whenever the
@@ -261,6 +286,13 @@ their own.
261
286
  | `areaFigure({ expr, from, to })` | The area up to `b`, its value shown |
262
287
  | `taylorFigure({ expr, at, order })` | Taylor polynomials of degree `order` |
263
288
  | `limitFigure({ expr, at, limit })` | A point `p` sliding toward a hole |
289
+ | `normalFigure({ mean, sd, shade })` | The normal curve with P(a ≤ X ≤ b) shaded (`mu`, `sigma`, `a`, `b`) |
290
+ | `binomialFigure({ n, p })` | Binomial bars |
291
+ | `cltFigure({ of, k, samples })` | Means of `k` draws piling into a normal curve |
292
+ | `galtonFigure({ rows, balls })` | A Galton board |
293
+ | `monteCarloPiFigure({ count })` | Points in a square; the share inside the circle ≈ π/4 |
294
+ | `regressionFigure({ slope, intercept, noise, count })` | Noisy points and the least-squares line |
295
+ | `bayesFigure({ prior, sensitivity, falsePositive })` | A medical test as areas: P(condition given a positive) |
264
296
 
265
297
  Each returns a plain figure to change or extend. In each, `M` starts at the
266
298
  identity unless `matrix` is given.
@@ -268,13 +300,14 @@ identity unless `matrix` is given.
268
300
  ## Examples
269
301
 
270
302
  - Gallery: **Linear Map**, **Eigenvectors**, **Equation Steps**, **Matrix Lesson**,
271
- **Derivative**, **Riemann Sums** and **Taylor Series**.
272
- - Videos: `linear-map-short.mjs` and `riemann-short.mjs` (9:16), `eigen-explainer.mjs`
273
- and `taylor-explainer.mjs` (16:9), in `examples/headless-video/`.
303
+ **Derivative**, **Riemann Sums**, **Taylor Series**, **Galton Board**, **Central Limit
304
+ Theorem**, **Monte Carlo π** and **Bayes: a Positive Test**.
305
+ - Videos: `linear-map-short.mjs`, `riemann-short.mjs` and `galton-short.mjs` (9:16);
306
+ `eigen-explainer.mjs`, `taylor-explainer.mjs` and `clt-explainer.mjs` (16:9), in
307
+ `examples/headless-video/`.
274
308
 
275
309
  ## Next
276
310
 
277
- Probability and statistics (sampling, histograms, the Galton board), discrete
278
- maths (graphs, trees, sets) and AI/ML (networks, gradient descent on a loss
279
- surface) build on the same figure model.
311
+ Discrete maths (graphs, trees, sets) and AI/ML (networks, gradient descent on
312
+ a loss surface) build on the same figure model.
280
313
  See `todo.md` for their status.
package/docs/teaching.md CHANGED
@@ -25,7 +25,7 @@ path for all of that:
25
25
  </figure>
26
26
 
27
27
  <!-- once, anywhere on the page (a site-wide footer is fine) -->
28
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.116.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
28
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
29
29
  ```
30
30
 
31
31
  Every `[data-tinyfly-embed]` mounts when the page is ready, with no per-post
@@ -7887,6 +7887,8 @@ function _0(e, o = {}) {
7887
7887
  "linearMapFigure, determinantFigure, eigenFigure, vectorSumFigure, spanFigure": "ready linear algebra figures; the matrix is the value M",
7888
7888
  "tangentFigure, secantFigure, riemannFigure, areaFigure, taylorFigure, limitFigure": "ready calculus figures; their moving parts are number values (a, h, n, b, order, p)",
7889
7889
  "differentiate / compileDerivative / integrate": "exact symbolic derivatives of expressions; Simpson integration",
7890
+ "normalFigure, binomialFigure, cltFigure, galtonFigure, monteCarloPiFigure, regressionFigure, bayesFigure": "ready probability and statistics figures",
7891
+ distributions: "{ kind: normal | uniform | exponential | binomial | poisson | dice | mean, …numbers or value names }; density, meanOf, sdOf, samples (seeded)",
7890
7892
  "layoutTex(tex) / morphEquation(a, b, t)": "the built-in TeX subset, and term-by-term transitions",
7891
7893
  "vec2, mat2": "2D vectors and 2×2 matrices (apply, multiply, determinant, inverse, eigen)"
7892
7894
  },
@@ -7905,7 +7907,12 @@ function _0(e, o = {}) {
7905
7907
  tangent: "{ expr, at, h? (secant), label? }: \\val{ID.slope} is the exact slope",
7906
7908
  riemann: "{ expr, from, to, n, rule?: left | right | midpoint | trapezoid }: \\val{ID.sum}, \\val{ID.exact}",
7907
7909
  area: "{ expr, from, to, lower? }: signed, coloured by sign; \\val{ID.value}",
7908
- taylor: "{ expr, at, order }: exact Taylor polynomials; a fractional order grows the next term in"
7910
+ taylor: "{ expr, at, order }: exact Taylor polynomials; a fractional order grows the next term in",
7911
+ histogram: "{ distribution, count, bins?, scale?, curve?, seed? }: seeded samples, binned; fills as count grows",
7912
+ distribution: "{ distribution, shade?: [a, b] }: a density curve (bars when discrete); \\val{ID.p}",
7913
+ galton: "{ rows?, balls, spacing?, top?, seed? }: a Galton board; fractional balls = the next one falling",
7914
+ scatter: "{ points: uniform | linear, count, inside?, fit?, seed? }: Monte Carlo and regression; \\val{ID.ratio}, \\val{ID.r}",
7915
+ bayes: "{ prior, truePositive, falsePositive }: Bayes as areas; \\val{ID.posterior}"
7909
7916
  },
7910
7917
  props: {
7911
7918
  NAME: "a value: a number, [x, y] vector or [a, b, c, d] matrix (row by row; columns are where î and ĵ land)",