@algorisys/tinyfly 0.119.1 → 0.121.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; probability: seeded histograms, distributions with shaded probabilities, a Galton board, the central limit theorem, Monte Carlo π, regression and Bayes as areas; discrete: graphs searched step by step (BFS, DFS, Dijkstra) with their queue or stack, recursion trees, Venn diagrams of any set expression, clock arithmetic; AI/ML: neural networks with activations flowing, gradient descent on contoured loss surfaces, attention heatmaps, logistic regression finding its decision boundary, k-means), 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, probability, discrete maths and AI/ML 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; discrete: graphs searched step by step (BFS, DFS, Dijkstra) with their queue or stack, recursion trees, Venn diagrams of any set expression, clock arithmetic; AI/ML: neural networks with activations flowing, gradient descent on contoured loss surfaces, attention heatmaps, logistic regression finding its decision boundary, k-means, and a 3D loss surface with the ball rolling down it), 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, probability, discrete maths and AI/ML figures. A figure is also a surface (`mathSurface`): characters point at `tip:basis.j` or `term:eq:2x` and change the figure as they speak, with `surfaceScript`. 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.119.1/cdn/tinyfly.iife.js"></script>
287
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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.119.1/cdn/tinyfly.iife.js" data-tinyfly-auto></script>
324
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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.119.1/cdn/tinyfly-player.iife.js"></script>
423
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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.119.1/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
532
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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, probability, discrete maths, AI/ML, equation steps, embeds and explorables (`src/math`) | 119 |
842
+ | Maths figures, TeX, calculus, probability, discrete maths, AI/ML, presenter surfaces, equation steps, embeds and explorables (`src/math`) | 128 |
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.119.1/cdn/tinyfly-player.iife.js`
1146
+ `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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.119.1/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.121.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.119.1/cdn/tinyfly.iife.js"></script>
188
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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.119.1/cdn/tinyfly.iife.js"></script>
77
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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
@@ -278,7 +278,10 @@ lesson page (`<figure data-tinyfly-math>`), an explorable and a video
278
278
  `graph` (nodes with `at`, or `tree: { root }`; `search` stepped by `step`), `venn` (`highlight: "(A | B)'"`),
279
279
  `clock` (`modulus`, `value`). AI/ML: `network` (`flow`), `descent` (`steps`, exact gradient),
280
280
  `contours`, `heatmap` (`softmax: true` for attention), `classifier` (`epochs`), `kmeans`
281
- (`iteration`); all seeded. See `docs/math.md`.
281
+ (`iteration`); all seeded. For a presenter, `mathSurface(figure, { x, y })` gives the
282
+ figure anchors (`tip:basis.i`, `item:ID`, `term:ID:TEXT`, `node:GRAPH:NODE`) and edits
283
+ (`set` with `value`, `step` with `to`, `drawOn`) for `surfaceScript` beats. A 3D loss
284
+ surface: `lossSurface3D({ expr, start, rate })` returns scene-3d JSON and tracks. See `docs/math.md`.
282
285
 
283
286
  ## Your own behaviours
284
287
 
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.119.1/cdn/tinyfly.iife.js"></script>
18
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.119.1/cdn/tinyfly-maps.iife.js"></script>
17
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.0/cdn/tinyfly.iife.js"></script>
18
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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
@@ -142,6 +142,26 @@ every time:
142
142
  pre-mixed with the background, so neighbours never leave seams. Contours are
143
143
  traced by marching squares and joined into whole curves.
144
144
 
145
+ #### A loss surface in 3D
146
+
147
+ `lossSurface3D({ expr, start, rate, momentum?, steps?, region?, height?, orbit? })`
148
+ builds f(x, y) as a 3D scene for `@algorisys/tinyfly/scene-3d`. You get a mesh
149
+ coloured by height, a ball rolling down the exact-gradient path, the path
150
+ appearing behind it, and a slow camera orbit. It returns plain data:
151
+ `{ scene, tracks, duration, path, losses }`. The maths module does not import
152
+ scene-3d.
153
+
154
+ ```js
155
+ import { lossSurface3D } from '@algorisys/tinyfly/math'
156
+ import { loadScene3D, drawScene3D } from '@algorisys/tinyfly/scene-3d'
157
+ import { deserializeTimeline } from '@algorisys/tinyfly'
158
+
159
+ const loss = lossSurface3D({ expr: '(x^2 + 4 y^2) / 4 + sin(1.5 x) / 2', start: [-2.6, 2.2], rate: 0.18, momentum: 0.6 })
160
+ const scene = loadScene3D(loss.scene)
161
+ const timeline = deserializeTimeline({ id: 'loss', config: { duration: loss.duration }, tracks: loss.tracks })
162
+ // each frame: drawScene3D(ctx, scene, timeline.getStateAtTime(t).values, { width, height })
163
+ ```
164
+
145
165
  The pieces are also available on their own: `seededNetwork`, `forward`,
146
166
  `descentPath`, `trainLogistic`, `kmeansHistory`, `contourLines`, `colorAt`.
147
167
 
@@ -238,7 +258,7 @@ lesson's step options (`duration`, `easing`, `delay`).
238
258
  <figcaption>The determinant is the area of the unit square after the map.</figcaption>
239
259
  </figure>
240
260
 
241
- <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.119.1/cdn/tinyfly-math.iife.js" data-tinyfly-auto></script>
261
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.0/cdn/tinyfly-math.iife.js" data-tinyfly-auto></script>
242
262
  ```
243
263
 
244
264
  The figure draws itself into an SVG and redraws from the timeline whenever the
@@ -296,6 +316,50 @@ figure's smaller side, so a figure reads the same as a 600 px card and as a
296
316
  1080×1920 short. `mathTarget()` is a canvas custom target: register it on any
297
317
  `CanvasAdapter` too, and `describeTarget` / `checkTracks` know its props.
298
318
 
319
+ ## Presenting with characters
320
+
321
+ `mathSurface(figure, { x, y })` makes a figure a **surface**, the way a code
322
+ panel, a whiteboard or a chart is one. Its places have names, so a character's
323
+ beats can aim at them as plain data. Its edits change the figure when a beat
324
+ says so, recorded on the figure's own props:
325
+
326
+ ```js
327
+ import { linearMapFigure, mathSurface } from '@algorisys/tinyfly/math'
328
+ import { surfaceScript } from '@algorisys/tinyfly/characters'
329
+
330
+ const fig = mathSurface(linearMapFigure({ width: 400, height: 400 }), { x: 20, y: 20 })
331
+ const on = (anchor) => ({ surface: 'fig', anchor })
332
+ const result = surfaceScript('teacher', { fig }, [
333
+ { do: 'walk', to: 560 },
334
+ { do: 'point', target: on('tip:basis.j'), say: 'Now slide it over…',
335
+ then: { surface: 'fig', edit: 'set', anchor: 'value:M', value: [1, 1, 0, 1] } },
336
+ { do: 'point', target: on('item:square'), say: 'A shear: the area stays 1.' },
337
+ ], { from: 740, ground: 420, height: 190 })
338
+ // result.tracks: the figure's and the teacher's tracks; draw fig.target with its props
339
+ ```
340
+
341
+ | Anchor | Names |
342
+ |---|---|
343
+ | `box` | the whole figure |
344
+ | `item:ID` | everything an item draws |
345
+ | `tip:ID` | the tip of a vector (`tip:basis.i`, `tip:basis.j` for î and ĵ) |
346
+ | `point:ID` | a point, including one riding a curve |
347
+ | `node:GRAPH:NODE` | a node of a graph |
348
+ | `term:ID:TEXT` | glyphs of an equation or label by their text (`term:eq:2x`; `term:eq#2:x` for the second) |
349
+ | `value:NAME` | a value, for `set` (its box is the whole figure) |
350
+
351
+ | Edit | Does |
352
+ |---|---|
353
+ | `drawOn`, `erase` | draws an item on, or off (`item:ID`) |
354
+ | `show`, `hide` | fades an item in or out |
355
+ | `step` | moves an equation to step `to`, terms gliding |
356
+ | `set` | tweens a value to `value`: a number, `[x, y]` or `[a, b, c, d]` |
357
+
358
+ Anchors are worked out from the figure as it is at that moment, so after a
359
+ `set` warps the plane, `tip:basis.i` is where î has gone. Parts of a figure do
360
+ not come loose: `piece`, `fling`, `follow` and `move` explain that edits are
361
+ the way to change it.
362
+
299
363
  ## Equations
300
364
 
301
365
  Equations are typeset by a built-in TeX subset, with no KaTeX or MathJax:
@@ -365,14 +429,15 @@ identity unless `matrix` is given.
365
429
  **Derivative**, **Riemann Sums**, **Taylor Series**, **Galton Board**, **Central Limit
366
430
  Theorem**, **Monte Carlo π**, **Bayes: a Positive Test**, **Graph Search**, **Recursion
367
431
  Tree**, **Set Operations**, **Clock Arithmetic**, **Neural Network**, **Gradient Descent**,
368
- **Decision Boundary**, **K-Means** and **Attention Weights**.
432
+ **Decision Boundary**, **K-Means**, **Attention Weights**, **Maths Presenter** and
433
+ **Loss Surface in 3D**.
369
434
  - Videos: `linear-map-short.mjs`, `riemann-short.mjs`, `galton-short.mjs`,
370
435
  `graph-search-short.mjs` and `gradient-descent-short.mjs` (9:16); `eigen-explainer.mjs`,
371
436
  `taylor-explainer.mjs`, `clt-explainer.mjs`, `de-morgan-explainer.mjs` and
372
- `neural-network-explainer.mjs` (16:9), in `examples/headless-video/`.
437
+ `neural-network-explainer.mjs` (16:9); `loss-surface-3d.mjs` (16:9, with scene-3d), in
438
+ `examples/headless-video/`.
373
439
 
374
440
  ## Next
375
441
 
376
- Characters can already stand beside a figure in a video; letting them point at
377
- named parts of it (a vector's tip, an equation term) is planned. See `todo.md`.
442
+ See `todo.md` for what is planned next.
378
443
  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.119.1/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
28
+ <script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.121.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