@algorisys/tinyfly 0.115.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 +11 -6
- package/docs/api-reference.md +2 -1
- package/docs/editor-guide.md +1 -1
- package/docs/examples.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +18 -0
- package/docs/maps.md +2 -2
- package/docs/math.md +313 -0
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +2614 -2548
- package/lib/addons/math.js +3384 -0
- package/lib/browser/tinyfly-math.iife.js +53 -0
- package/lib/browser/tinyfly.iife.js +12 -12
- package/lib/browser/tinyfly.js +993 -905
- package/lib/browser/tinyfly.umd.js +12 -12
- package/lib/embed/tinyfly-embed.iife.js +1 -1
- package/lib/embed/tinyfly-embed.js +8 -0
- package/lib/engine/tinyfly-engine.js +112 -98
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/player/tinyfly-player.es.js +8 -0
- package/lib/player/tinyfly-player.iife.js +1 -1
- package/lib/player/tinyfly-player.umd.js +1 -1
- package/lib/types/characters/capabilities.d.ts +8 -0
- package/lib/types/engine/authoring/random.d.ts +7 -0
- package/lib/types/math/browser-entry.d.ts +3 -0
- package/lib/types/math/embed/auto-mount-math.d.ts +7 -0
- package/lib/types/math/embed/explorable.d.ts +46 -0
- package/lib/types/math/embed/mount-math.d.ts +31 -0
- package/lib/types/math/expr/differentiate.d.ts +7 -0
- package/lib/types/math/expr/evaluate.d.ts +21 -0
- package/lib/types/math/expr/parse-expression.d.ts +50 -0
- package/lib/types/math/figure/derived.d.ts +17 -0
- package/lib/types/math/figure/display-list.d.ts +87 -0
- package/lib/types/math/figure/figure-spec.d.ts +349 -0
- package/lib/types/math/figure/item-context.d.ts +39 -0
- package/lib/types/math/figure/items/calculus.d.ts +7 -0
- package/lib/types/math/figure/items/curves.d.ts +7 -0
- package/lib/types/math/figure/items/grid.d.ts +5 -0
- package/lib/types/math/figure/items/probability.d.ts +13 -0
- package/lib/types/math/figure/items/regions.d.ts +5 -0
- package/lib/types/math/figure/items/text.d.ts +5 -0
- package/lib/types/math/figure/items/vectors.d.ts +9 -0
- package/lib/types/math/figure/layout-figure.d.ts +13 -0
- package/lib/types/math/figure/plane.d.ts +20 -0
- package/lib/types/math/figure/validate-spec.d.ts +2 -0
- package/lib/types/math/index.d.ts +49 -0
- package/lib/types/math/linear/mat2.d.ts +41 -0
- package/lib/types/math/linear/vec2.d.ts +18 -0
- package/lib/types/math/presets/calculus.d.ts +59 -0
- package/lib/types/math/presets/linear-algebra.d.ts +42 -0
- package/lib/types/math/presets/probability.d.ts +62 -0
- package/lib/types/math/prob/bayes.d.ts +16 -0
- package/lib/types/math/prob/distributions.d.ts +58 -0
- package/lib/types/math/prob/galton.d.ts +18 -0
- package/lib/types/math/prob/histogram.d.ts +20 -0
- package/lib/types/math/prob/scatter.d.ts +24 -0
- package/lib/types/math/render/arrow.d.ts +10 -0
- package/lib/types/math/render/display-list-to-svg.d.ts +10 -0
- package/lib/types/math/render/draw-display-list.d.ts +6 -0
- package/lib/types/math/steps/math-steps.d.ts +34 -0
- package/lib/types/math/targets/math-target.d.ts +43 -0
- package/lib/types/math/tex/equation-morph.d.ts +21 -0
- package/lib/types/math/tex/glyph-metrics.d.ts +24 -0
- package/lib/types/math/tex/tex-layout.d.ts +59 -0
- package/lib/types/math/tex/tex-parser.d.ts +88 -0
- package/lib/types/player/player.d.ts +6 -0
- package/llms-full.txt +400 -10
- package/llms.txt +32 -31
- package/package.json +6 -2
- package/skills/tinyfly/SKILL.md +12 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type TexNode } from './tex-parser';
|
|
2
|
+
/**
|
|
3
|
+
* Typesets a parsed TeX tree into positioned pieces, in ems.
|
|
4
|
+
*
|
|
5
|
+
* Coordinates: x grows right from the left edge, y grows DOWN from the
|
|
6
|
+
* baseline (screen convention), so a superscript has a negative y.
|
|
7
|
+
*
|
|
8
|
+
* Every piece carries an `id`. Plain symbols are numbered by their text and
|
|
9
|
+
* occurrence (`x#1`, `=#1`, `2#2`), so two steps of an equation pair up their
|
|
10
|
+
* matching terms with no extra markup; `\id{name}{…}` names a whole term
|
|
11
|
+
* explicitly. Pure: the same TeX and values always give the same layout.
|
|
12
|
+
*/
|
|
13
|
+
export interface TexGlyph {
|
|
14
|
+
kind: 'glyph';
|
|
15
|
+
text: string;
|
|
16
|
+
/** Left edge of the glyph's advance cell; draw it centred in `width` */
|
|
17
|
+
x: number;
|
|
18
|
+
/** Baseline */
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
size: number;
|
|
22
|
+
italic: boolean;
|
|
23
|
+
color?: string;
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TexRule {
|
|
27
|
+
kind: 'rule';
|
|
28
|
+
x: number;
|
|
29
|
+
/** Top edge */
|
|
30
|
+
y: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
color?: string;
|
|
34
|
+
id: string;
|
|
35
|
+
}
|
|
36
|
+
export interface TexStroke {
|
|
37
|
+
kind: 'stroke';
|
|
38
|
+
points: [number, number][];
|
|
39
|
+
width: number;
|
|
40
|
+
color?: string;
|
|
41
|
+
id: string;
|
|
42
|
+
}
|
|
43
|
+
export type TexPiece = TexGlyph | TexRule | TexStroke;
|
|
44
|
+
export interface TexLayout {
|
|
45
|
+
width: number;
|
|
46
|
+
/** Above the baseline */
|
|
47
|
+
height: number;
|
|
48
|
+
/** Below the baseline */
|
|
49
|
+
depth: number;
|
|
50
|
+
pieces: TexPiece[];
|
|
51
|
+
}
|
|
52
|
+
export interface TexLayoutOptions {
|
|
53
|
+
/** `display` (default) puts big-operator limits above and below; `inline` beside */
|
|
54
|
+
style?: 'display' | 'inline';
|
|
55
|
+
/** Live numbers for `\val{name}` */
|
|
56
|
+
values?: Record<string, number>;
|
|
57
|
+
}
|
|
58
|
+
/** Typeset TeX source (or an already-parsed tree) into pieces, in ems. */
|
|
59
|
+
export declare function layoutTex(source: string | TexNode, options?: TexLayoutOptions): TexLayout;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TeX subset tinyfly typesets, parsed into a small tree.
|
|
3
|
+
*
|
|
4
|
+
* Supported:
|
|
5
|
+
* - Letters (italic), digits, `+ - = < > ( ) [ ] | , . ; : ! '`
|
|
6
|
+
* - `^` and `_` with a single token or a `{group}`
|
|
7
|
+
* - `\frac{a}{b}`, `\sqrt{x}`, `\vec{v}`, `\hat{x}`, `\bar{x}`
|
|
8
|
+
* - Big operators `\sum \prod \int` (limits from `_` and `^`), and named
|
|
9
|
+
* operators `\sin \cos \tan \log \ln \exp \det \lim \max \min \arg`
|
|
10
|
+
* - Greek letters and the symbols in SYMBOLS (`\cdot \times \le \to \infty` …)
|
|
11
|
+
* - `\begin{pmatrix} a & b \\ c & d \end{pmatrix}` (also `bmatrix`, `vmatrix`, `matrix`)
|
|
12
|
+
* - `\text{words}`, `\color{name or #hex}{…}`, spacing `\, \; \quad \qquad`
|
|
13
|
+
* - `\id{name}{…}`: names a term, so an equation step can move it to its
|
|
14
|
+
* place in the next step (see equation-morph.ts)
|
|
15
|
+
* - `\val{name}` or `\val{name:2}`: a live number from the figure's values,
|
|
16
|
+
* with up to that many decimals (default 2), so a matrix shown in TeX
|
|
17
|
+
* follows the matrix being animated
|
|
18
|
+
*
|
|
19
|
+
* Anything else is an error that names the position, never a silent guess.
|
|
20
|
+
*/
|
|
21
|
+
export type TexClass = 'ord' | 'bin' | 'rel' | 'open' | 'close' | 'punct' | 'op';
|
|
22
|
+
export type TexNode = {
|
|
23
|
+
type: 'symbol';
|
|
24
|
+
text: string;
|
|
25
|
+
cls: TexClass;
|
|
26
|
+
italic: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
type: 'group';
|
|
29
|
+
body: TexNode[];
|
|
30
|
+
} | {
|
|
31
|
+
type: 'scripts';
|
|
32
|
+
base: TexNode;
|
|
33
|
+
sup?: TexNode;
|
|
34
|
+
sub?: TexNode;
|
|
35
|
+
} | {
|
|
36
|
+
type: 'frac';
|
|
37
|
+
num: TexNode;
|
|
38
|
+
den: TexNode;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'sqrt';
|
|
41
|
+
body: TexNode;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'accent';
|
|
44
|
+
accent: 'vec' | 'hat' | 'bar';
|
|
45
|
+
body: TexNode;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'bigop';
|
|
48
|
+
text: string;
|
|
49
|
+
limits: boolean;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'opname';
|
|
52
|
+
text: string;
|
|
53
|
+
limits: boolean;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'matrix';
|
|
56
|
+
delimiters: 'pmatrix' | 'bmatrix' | 'vmatrix' | 'matrix';
|
|
57
|
+
rows: TexNode[][];
|
|
58
|
+
} | {
|
|
59
|
+
type: 'text';
|
|
60
|
+
text: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'color';
|
|
63
|
+
color: string;
|
|
64
|
+
body: TexNode;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'id';
|
|
67
|
+
id: string;
|
|
68
|
+
body: TexNode;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'value';
|
|
71
|
+
name: string;
|
|
72
|
+
digits: number;
|
|
73
|
+
} | {
|
|
74
|
+
type: 'space';
|
|
75
|
+
width: number;
|
|
76
|
+
};
|
|
77
|
+
/** Symbol commands: the glyph and its spacing class. */
|
|
78
|
+
export declare const SYMBOLS: Record<string, [string, TexClass]>;
|
|
79
|
+
export declare class TexError extends Error {
|
|
80
|
+
readonly source: string;
|
|
81
|
+
/** 0-based index into the source */
|
|
82
|
+
readonly position: number;
|
|
83
|
+
constructor(message: string, source: string, position: number);
|
|
84
|
+
}
|
|
85
|
+
/** Every command the parser knows, for "did you mean" messages and discovery. */
|
|
86
|
+
export declare const TEX_COMMANDS: string[];
|
|
87
|
+
/** Parse a TeX string into a group node. */
|
|
88
|
+
export declare function parseTex(source: string): TexNode;
|
|
@@ -247,6 +247,12 @@ export declare class TinyflyPlayer {
|
|
|
247
247
|
* Get current playback time.
|
|
248
248
|
*/
|
|
249
249
|
get currentTime(): number;
|
|
250
|
+
/**
|
|
251
|
+
* The animated values at the playhead, for renderers that draw from values
|
|
252
|
+
* rather than DOM elements (a canvas, or an SVG rebuilt each frame). Read it
|
|
253
|
+
* from a `subscribe` listener. Undefined before a timeline loads.
|
|
254
|
+
*/
|
|
255
|
+
get state(): AnimationState | undefined;
|
|
250
256
|
/**
|
|
251
257
|
* Get total duration.
|
|
252
258
|
*/
|
package/llms-full.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Key facts:
|
|
6
6
|
|
|
7
|
-
- Package: `@algorisys/tinyfly` on npm (`npm install @algorisys/tinyfly`). Entry points: `@algorisys/tinyfly` (engine), `/player`, `/export` (CSS, Lottie, GIF, video exporters), `/adapters` (DOM, Canvas, SVG, WebGL), `/gsap-compat` (GSAP-style API), `/drivers` (scroll, visibility, smooth scroll), `/interaction` (Observer, Draggable), `/teach` (lesson steps and diagram primitives), `/embed` (teaching embeds), `/characters` (poseable stick figure with facial expressions), `/headless` (render scenes to MP4 and PNG stills in Node), `/react`, `/vue`, `/svelte`, `/solid` (framework wrappers), and `/browser` (the GSAP-style runtime plus engine, player, drivers, interaction and the stick figure — no exporters — for script tags). A CLI: `npx @algorisys/tinyfly capabilities`, `check`, `validate`, `render` and `video`.
|
|
7
|
+
- Package: `@algorisys/tinyfly` on npm (`npm install @algorisys/tinyfly`). Entry points: `@algorisys/tinyfly` (engine), `/player`, `/export` (CSS, Lottie, GIF, video exporters), `/adapters` (DOM, Canvas, SVG, WebGL), `/gsap-compat` (GSAP-style API), `/drivers` (scroll, visibility, smooth scroll), `/interaction` (Observer, Draggable), `/teach` (lesson steps and diagram primitives), `/math` (maths figures, a TeX subset, equation steps, lesson embeds and explorables), `/embed` (teaching embeds), `/characters` (poseable stick figure with facial expressions), `/headless` (render scenes to MP4 and PNG stills in Node), `/react`, `/vue`, `/svelte`, `/solid` (framework wrappers), and `/browser` (the GSAP-style runtime plus engine, player, drivers, interaction and the stick figure — no exporters — for script tags). A CLI: `npx @algorisys/tinyfly capabilities`, `check`, `validate`, `render` and `video`.
|
|
8
8
|
- Script tag: `https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v{version}/cdn/tinyfly.iife.js` defines a global `tinyfly`, e.g. `tinyfly.to('.box', { x: 200, duration: 1 })`. Replace `{version}` with a release tag.
|
|
9
9
|
- The GSAP-style `live` API covers `scrollTrigger` (scrub, pin, toggleActions), `splitText` (chars, words, lines, masks), `drawSVG`, `spring`, `morphSVG`, `motionPath`, text/scramble, inertia and Draggable, Flip (including shared elements by `data-flip-id`), plain-object targets and `live.ticker`.
|
|
10
10
|
- Times in JSON timelines are milliseconds; durations in the GSAP-style API are seconds, as in GSAP.
|
|
@@ -591,7 +591,7 @@ with a GSAP-style call (durations are in seconds here):
|
|
|
591
591
|
```html
|
|
592
592
|
<div class="box" style="width:60px;height:60px;background:#4a9eff"></div>
|
|
593
593
|
|
|
594
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
594
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly.iife.js"></script>
|
|
595
595
|
<script>
|
|
596
596
|
tinyfly.to('.box', { x: 200, duration: 1 })
|
|
597
597
|
</script>
|
|
@@ -799,7 +799,7 @@ Without a build step, the all-in-one bundle exposes the same functions on a
|
|
|
799
799
|
global — `tinyfly.to()`, `tinyfly.timeline()` and so on:
|
|
800
800
|
|
|
801
801
|
```html
|
|
802
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
802
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly.iife.js"></script>
|
|
803
803
|
<script>
|
|
804
804
|
tinyfly.to('.box', { x: 200, duration: 1 })
|
|
805
805
|
</script>
|
|
@@ -2714,7 +2714,7 @@ For simple website embedding without a build system.
|
|
|
2714
2714
|
</html>
|
|
2715
2715
|
```
|
|
2716
2716
|
|
|
2717
|
-
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.
|
|
2717
|
+
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`.
|
|
2718
2718
|
|
|
2719
2719
|
---
|
|
2720
2720
|
|
|
@@ -2827,7 +2827,8 @@ Complete reference for the tinyfly animation engine, player, and adapters.
|
|
|
2827
2827
|
Entry points: `tinyfly` (engine), `@algorisys/tinyfly/export` (CSS, Lottie, GIF, WebP,
|
|
2828
2828
|
video and sprite-sheet exporters), `@algorisys/tinyfly/player`, `@algorisys/tinyfly/adapters` (DOM,
|
|
2829
2829
|
Canvas, SVG and WebGL adapters, Flip helpers), `@algorisys/tinyfly/drivers`,
|
|
2830
|
-
`@algorisys/tinyfly/interaction`, `@algorisys/tinyfly/gsap-compat`, `@algorisys/tinyfly/scene-3d` (3D scenes), `@algorisys/tinyfly/
|
|
2830
|
+
`@algorisys/tinyfly/interaction`, `@algorisys/tinyfly/gsap-compat`, `@algorisys/tinyfly/scene-3d` (3D scenes), `@algorisys/tinyfly/math`
|
|
2831
|
+
(maths figures, equations and lessons; see [Maths Animations](math.md)), `@algorisys/tinyfly/browser` (the live
|
|
2831
2832
|
runtime and everything except the exporters, for `<script>` tags), and `@algorisys/tinyfly/headless`
|
|
2832
2833
|
(video and stills rendering in Node).
|
|
2833
2834
|
|
|
@@ -7067,7 +7068,7 @@ The dialog shows the generated HTML/JavaScript code with a **Copy Code** button.
|
|
|
7067
7068
|
**Steps to embed:**
|
|
7068
7069
|
1. Build the player: `npm run build:player`
|
|
7069
7070
|
2. Copy `lib/player/tinyfly-player.iife.js` to your project (or load
|
|
7070
|
-
`https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
7071
|
+
`https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-player.iife.js`
|
|
7071
7072
|
instead; see [Deployment](DEPLOYMENT.md))
|
|
7072
7073
|
3. Copy the generated code into your HTML
|
|
7073
7074
|
4. Adjust the script `src` path if needed
|
|
@@ -8478,6 +8479,24 @@ are declared up front, each with an id the places use. The catalog lists each
|
|
|
8478
8479
|
surface's places and edits. See "A whole scene as data", "Whiteboards" and
|
|
8479
8480
|
"Charts" in `docs/acting.md`.
|
|
8480
8481
|
|
|
8482
|
+
## Maths
|
|
8483
|
+
|
|
8484
|
+
Maths lessons use `@algorisys/tinyfly/math`: write the figure as JSON (`width`,
|
|
8485
|
+
`height`, `values`, `items`: grid, axes, vector, basis, point, function,
|
|
8486
|
+
parametric, polygon, line, label, equation), check it with `mathFigure(spec)`,
|
|
8487
|
+
and write steps with `mathSteps(lesson, 'fig', figure)` (`applyMatrix`,
|
|
8488
|
+
`drawOn`, `showStep`). Matrices are `[a, b, c, d]` row by row; columns are where
|
|
8489
|
+
î and ĵ land. Functions are expression strings (`'sin(k x)'`, never JS), and
|
|
8490
|
+
equations are TeX in the built-in subset (`\frac`, `\sqrt`, `^`, `_`, matrices,
|
|
8491
|
+
`\val{M.det}` for live values). Do not name a value `x`, `y`, `t`, `opacity`
|
|
8492
|
+
or `scale`: those belong to the figure's target. The same figure plays in a
|
|
8493
|
+
lesson page (`<figure data-tinyfly-math>`), an explorable and a video
|
|
8494
|
+
(`mathTarget`). Calculus items (`tangent`, `riemann`, `area`, `taylor`, a
|
|
8495
|
+
`point` with `on` and `x`) take numbers or number-value names for `at`, `n`,
|
|
8496
|
+
`to`, `order`, and publish `\\val{ID.slope}`, `ID.sum`, `ID.value` for TeX. Probability items
|
|
8497
|
+
(`histogram`, `distribution`, `galton`, `scatter`, `bayes`) take a distribution as data
|
|
8498
|
+
(`{ kind: 'normal', mean: 'mu', sd: 1 }`) and draw seeded samples, never `Math.random`. See `docs/math.md`.
|
|
8499
|
+
|
|
8481
8500
|
## Your own behaviours
|
|
8482
8501
|
|
|
8483
8502
|
Write new actions with `defineAction()` (from beats, or as timed pose steps),
|
|
@@ -8663,7 +8682,7 @@ path for all of that:
|
|
|
8663
8682
|
</figure>
|
|
8664
8683
|
|
|
8665
8684
|
<!-- once, anywhere on the page (a site-wide footer is fine) -->
|
|
8666
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
8685
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
|
|
8667
8686
|
```
|
|
8668
8687
|
|
|
8669
8688
|
Every `[data-tinyfly-embed]` mounts when the page is ready, with no per-post
|
|
@@ -8987,6 +9006,324 @@ refuses to play it, with an error saying to update, rather than playing it wrong
|
|
|
8987
9006
|
|
|
8988
9007
|
---
|
|
8989
9008
|
|
|
9009
|
+
<!-- docs/math.md -->
|
|
9010
|
+
|
|
9011
|
+
# Maths Animations
|
|
9012
|
+
|
|
9013
|
+
`@algorisys/tinyfly/math` draws maths the way teaching videos and explorable
|
|
9014
|
+
lessons show it: a coordinate plane whose grid a matrix warps, vectors, function
|
|
9015
|
+
plots, shaded areas, and equations typeset from TeX that rewrite themselves one
|
|
9016
|
+
step at a time.
|
|
9017
|
+
|
|
9018
|
+
The same figure plays in three places:
|
|
9019
|
+
|
|
9020
|
+
| Where | How |
|
|
9021
|
+
|---|---|
|
|
9022
|
+
| **Lesson pages** | A `<figure data-tinyfly-math>` with the figure and a timeline as JSON, stepped with the embed controls (next, back, captions, questions) |
|
|
9023
|
+
| **Short videos** | A scene for `tinyfly video`, any size: 1080×1920 for 9:16, 1920×1080 for 16:9 |
|
|
9024
|
+
| **Explorables** | `mathExplorable()`: the reader drags vectors or matrix columns and moves sliders |
|
|
9025
|
+
|
|
9026
|
+
All three run the same layout: one pure function turns the figure and its
|
|
9027
|
+
current values into shapes, which are drawn on a canvas or written as SVG. The
|
|
9028
|
+
same values always give the same picture, in a browser, a Web Worker or Node.
|
|
9029
|
+
|
|
9030
|
+
## A figure is JSON
|
|
9031
|
+
|
|
9032
|
+
```js
|
|
9033
|
+
import { mathFigure } from '@algorisys/tinyfly/math'
|
|
9034
|
+
|
|
9035
|
+
const figure = mathFigure({
|
|
9036
|
+
width: 600, height: 600, // px
|
|
9037
|
+
x: [-5, 5], // world units across (y follows, square)
|
|
9038
|
+
theme: 'dark', // dark (default) | light | chalk
|
|
9039
|
+
values: { M: [1, 0, 0, 1], k: 1 },
|
|
9040
|
+
items: [
|
|
9041
|
+
{ id: 'grid', kind: 'grid', transform: 'M', ghost: true },
|
|
9042
|
+
{ id: 'basis', kind: 'basis', transform: 'M' },
|
|
9043
|
+
{ id: 'wave', kind: 'function', expr: 'sin(k x)', color: 'blue' },
|
|
9044
|
+
{ id: 'eq', kind: 'label', tex: '\\begin{bmatrix} \\val{M.a} & \\val{M.b} \\\\ \\val{M.c} & \\val{M.d} \\end{bmatrix}', at: [30, 60], screen: true, align: 'left' },
|
|
9045
|
+
],
|
|
9046
|
+
})
|
|
9047
|
+
```
|
|
9048
|
+
|
|
9049
|
+
`mathFigure()` checks the figure and throws a message that says how to fix it:
|
|
9050
|
+
unknown kinds and themes with the name probably meant, duplicate ids, values of
|
|
9051
|
+
the wrong shape, expressions that do not parse or read a missing parameter, TeX
|
|
9052
|
+
mistakes with their position.
|
|
9053
|
+
|
|
9054
|
+
### Values
|
|
9055
|
+
|
|
9056
|
+
Everything that moves is a **value**: a number (`k`), a vector `[x, y]` or a
|
|
9057
|
+
matrix `[a, b, c, d]`, written row by row:
|
|
9058
|
+
|
|
9059
|
+
| a b |
|
|
9060
|
+
| c d |
|
|
9061
|
+
|
|
9062
|
+
The first column `[a, c]` is where î lands and the second `[b, d]` is where ĵ
|
|
9063
|
+
lands. Items name the values they use (`transform: 'M'`, `to: 'v'`), and number
|
|
9064
|
+
values are the parameters of functions (`sin(k x)`). TeX shows values live with
|
|
9065
|
+
`\val{name}` (`\val{name:1}` for one decimal). Matrices also give
|
|
9066
|
+
`M.a M.b M.c M.d M.det`, and vectors give `v.x v.y v.length`.
|
|
9067
|
+
|
|
9068
|
+
Some names are reserved, because a track on them would move the whole figure:
|
|
9069
|
+
`x`, `y`, `opacity`, `scale`, `rotate` and the other canvas properties, and `t`.
|
|
9070
|
+
|
|
9071
|
+
### Items
|
|
9072
|
+
|
|
9073
|
+
| Kind | Options |
|
|
9074
|
+
|---|---|
|
|
9075
|
+
| `grid` | `step?`, `transform?` (a matrix value), `ghost?` (the original grid, faintly underneath) |
|
|
9076
|
+
| `axes` | `ticks?` (0 for none), `labels?` |
|
|
9077
|
+
| `vector` | `to`, `from?`, `transform?`, `label?` (TeX), `labelAt?: 'tip' \| 'middle'`, `width?` |
|
|
9078
|
+
| `basis` | `transform?`, `labels?`: î and ĵ |
|
|
9079
|
+
| `point` | `at`, `transform?`, `label?`, `radius?` |
|
|
9080
|
+
| `function` | `expr` in `x`, `domain?`, `width?` |
|
|
9081
|
+
| `parametric` | `x` and `y` in `t`, `t?` range, `transform?` |
|
|
9082
|
+
| `polygon` | `points?` (default the unit square), `transform?`, `fillOpacity?`, `label?` |
|
|
9083
|
+
| `line` | `along` (a span) or `eigen` (a matrix value: one line per real eigenvector), `dashed?` |
|
|
9084
|
+
| `label` | `tex`, `at`, `screen?` (px instead of world units), `size?`, `align?`, `backdrop?` |
|
|
9085
|
+
| `equation` | `steps` (TeX, one per step), `at`, `screen?`, `size?`, `align?`, `backdrop?` |
|
|
9086
|
+
| `tangent` | `expr`, `at`, `h?` (a secant through `at` and `at + h`), `length?`, `points?`, `label?` |
|
|
9087
|
+
| `riemann` | `expr`, `from`, `to`, `n` (pieces), `rule?: 'left' \| 'right' \| 'midpoint' \| 'trapezoid'`, `fillOpacity?` |
|
|
9088
|
+
| `area` | `expr`, `from`, `to`, `lower?` (another function), `negativeColor?`, `fillOpacity?` |
|
|
9089
|
+
| `taylor` | `expr`, `at`, `order` (0–20; a fractional order grows the next term in), `domain?` |
|
|
9090
|
+
|
|
9091
|
+
| `histogram` | `distribution`, `count` (samples so far), `bins?: [from, to, n]`, `scale?: 'density' \| 'count'`, `curve?`, `seed?` |
|
|
9092
|
+
| `distribution` | `distribution`, `shade?: [a, b]` (P(a ≤ X ≤ b)), `domain?` |
|
|
9093
|
+
| `galton` | `rows?`, `balls` (fractional: the next ball on its way), `spacing?`, `top?`, `seed?` |
|
|
9094
|
+
| `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?` |
|
|
9095
|
+
| `bayes` | `prior`, `truePositive`, `falsePositive`, `at?`, `size?`, `labels?` |
|
|
9096
|
+
|
|
9097
|
+
`point` also rides a curve: `{ on: 'sin(x)', x: 'p' }` is the point (p, sin p), and
|
|
9098
|
+
`hollow: true` draws an open circle for a hole or a limit. `function` takes
|
|
9099
|
+
`derivative: n` to plot f′, f″ … and `dashed: true`.
|
|
9100
|
+
|
|
9101
|
+
Fields such as `at`, `from`, `to`, `n`, `h` and `order` take a number or the
|
|
9102
|
+
name of a number value, so a timeline can slide the point, shrink the secant,
|
|
9103
|
+
add rectangles or Taylor terms.
|
|
9104
|
+
|
|
9105
|
+
### Derived numbers
|
|
9106
|
+
|
|
9107
|
+
Items work out numbers that TeX can show with `\val{…}`:
|
|
9108
|
+
|
|
9109
|
+
| Item | Numbers |
|
|
9110
|
+
|---|---|
|
|
9111
|
+
| `tangent` | `ID.slope` (exact, or rise over run for a secant), `ID.x`, `ID.y` |
|
|
9112
|
+
| `riemann` | `ID.sum`, `ID.exact` (the integral), `ID.n` |
|
|
9113
|
+
| `area` | `ID.value` (the signed integral) |
|
|
9114
|
+
| `point` on a curve | `ID.x`, `ID.y` |
|
|
9115
|
+
| `taylor` | `ID.order`, `ID.degree` (its whole part) |
|
|
9116
|
+
| `histogram` | `ID.count`, `ID.mean`, `ID.sd` (of the samples so far) |
|
|
9117
|
+
| `distribution` | `ID.p` (the shaded probability), `ID.mean`, `ID.sd` |
|
|
9118
|
+
| `galton` | `ID.landed` |
|
|
9119
|
+
| `scatter` | `ID.count`, `ID.inside`, `ID.ratio`, `ID.slope`, `ID.intercept`, `ID.r` |
|
|
9120
|
+
| `bayes` | `ID.prior`, `ID.posterior`, `ID.positive`, `ID.truePositive`, `ID.falsePositive` |
|
|
9121
|
+
|
|
9122
|
+
### Distributions and randomness
|
|
9123
|
+
|
|
9124
|
+
A distribution is data: `{ kind: 'normal', mean, sd }`, `uniform` (`min`,
|
|
9125
|
+
`max`), `exponential` (`rate`), `binomial` (`n`, `p`), `poisson` (`rate`),
|
|
9126
|
+
`dice` (`count`, `sides`), or `{ kind: 'mean', of, count }`, the average of
|
|
9127
|
+
`count` draws (what the central limit theorem is about). Any of its numbers
|
|
9128
|
+
may be a value name, so a slider moves the mean or n. `density`, `meanOf`,
|
|
9129
|
+
`sdOf`, `sample` and `samples` work on them directly.
|
|
9130
|
+
|
|
9131
|
+
Every sample comes from a seed (the item id unless `seed` is given), through
|
|
9132
|
+
the engine's `createRandom`, `randomNormal` and `shuffled`. A histogram that
|
|
9133
|
+
grows from 10 to 1000 samples keeps its first 10, and every render, video and
|
|
9134
|
+
reader sees the same draws.
|
|
9135
|
+
|
|
9136
|
+
Slopes, derivative plots and Taylor coefficients come from symbolic
|
|
9137
|
+
differentiation of the expression (`differentiate`, `compileDerivative`), so
|
|
9138
|
+
they are exact, not finite differences. Integrals use Simpson's rule
|
|
9139
|
+
(`integrate`). Calculus items need functions with derivatives; `floor`,
|
|
9140
|
+
`ceil` and `round` have none and are refused with a message.
|
|
9141
|
+
|
|
9142
|
+
Every item has an `id` and may set `color` (a theme colour: `blue`, `green`,
|
|
9143
|
+
`red`, `yellow`, `purple`, `orange`, `teal`, `pink`, `ink`, `grey`; or any CSS
|
|
9144
|
+
colour), `draw` and `opacity`. Items draw in order, later ones on top.
|
|
9145
|
+
|
|
9146
|
+
Function plots break at gaps and asymptotes (`tan(x)`, `1/x`, `sqrt(x)` below
|
|
9147
|
+
0) instead of joining across them.
|
|
9148
|
+
|
|
9149
|
+
### Expressions
|
|
9150
|
+
|
|
9151
|
+
Functions and curves are written as text, parsed by a small safe parser (never
|
|
9152
|
+
`eval`): `+ - * / ^`, brackets, implicit multiplication (`2x`, `3(x + 1)`),
|
|
9153
|
+
`pi`, `e`, `tau`, and these functions: `sin cos tan asin acos atan atan2 sinh
|
|
9154
|
+
cosh tanh exp ln log log2 sqrt abs floor ceil round sign min max sigmoid relu`.
|
|
9155
|
+
|
|
9156
|
+
## What a timeline animates
|
|
9157
|
+
|
|
9158
|
+
A figure's target takes ordinary tracks:
|
|
9159
|
+
|
|
9160
|
+
| Property | Animates |
|
|
9161
|
+
|---|---|
|
|
9162
|
+
| a value's name (`M`, `k`, `v`) | the value; a matrix keyed from `[1, 0, 0, 1]` to `[1, 1, 0, 1]` shears the plane, every point moving in a straight line |
|
|
9163
|
+
| `ITEM.draw` | 0..1, draws the item on like a pen |
|
|
9164
|
+
| `ITEM.opacity` | 0..1 |
|
|
9165
|
+
| `ITEM.step` | an equation's step; in between, terms glide |
|
|
9166
|
+
|
|
9167
|
+
`mathSteps()` writes these as lesson steps on a `lesson()` builder from
|
|
9168
|
+
`@algorisys/tinyfly/teach`:
|
|
9169
|
+
|
|
9170
|
+
```js
|
|
9171
|
+
import { lesson } from '@algorisys/tinyfly/teach'
|
|
9172
|
+
import { determinantFigure, mathSteps } from '@algorisys/tinyfly/math'
|
|
9173
|
+
|
|
9174
|
+
const figure = determinantFigure({ theme: 'light' })
|
|
9175
|
+
const l = lesson({ id: 'determinant' })
|
|
9176
|
+
const m = mathSteps(l, 'fig', figure, { hidden: ['square'] })
|
|
9177
|
+
l.marker('start', { label: 'î and ĵ span the unit square' })
|
|
9178
|
+
m.drawOn('square')
|
|
9179
|
+
l.marker('square', { label: 'Its area is 1', pause: true })
|
|
9180
|
+
m.applyMatrix([2, 0, 0, 1])
|
|
9181
|
+
l.marker('stretch', { label: 'Stretch î by 2: the area doubles', pause: true })
|
|
9182
|
+
m.applyMatrix([2, 1, 2, 1])
|
|
9183
|
+
l.marker('flat', { label: 'ĵ lies on î’s line', pause: true, question: 'What is the area now?' })
|
|
9184
|
+
const timeline = l.definition() // plain JSON
|
|
9185
|
+
```
|
|
9186
|
+
|
|
9187
|
+
`mathSteps` helpers: `toValue(name, value)`, `applyMatrix(m, { name? })`,
|
|
9188
|
+
`drawOn(id)`, `fadeIn(id)`, `fadeOut(id)`, `showStep(id, step)`. Each takes the
|
|
9189
|
+
lesson's step options (`duration`, `easing`, `delay`).
|
|
9190
|
+
|
|
9191
|
+
## In a lesson page
|
|
9192
|
+
|
|
9193
|
+
```html
|
|
9194
|
+
<figure data-tinyfly-math data-options='{"stepMode": true}'>
|
|
9195
|
+
<script type="application/json" data-tinyfly-figure>{ …the figure… }</script>
|
|
9196
|
+
<script type="application/json" data-tinyfly-timeline>{ …the timeline… }</script>
|
|
9197
|
+
<figcaption>The determinant is the area of the unit square after the map.</figcaption>
|
|
9198
|
+
</figure>
|
|
9199
|
+
|
|
9200
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-math.iife.js" data-tinyfly-auto></script>
|
|
9201
|
+
```
|
|
9202
|
+
|
|
9203
|
+
The figure draws itself into an SVG and redraws from the timeline whenever the
|
|
9204
|
+
player moves: playing, stepping, seeking, or showing the last frame under
|
|
9205
|
+
reduced motion. Everything else is the ordinary embed (see
|
|
9206
|
+
[Teaching Animations](teaching.md)): markers, captions in several languages,
|
|
9207
|
+
questions, scenarios, pausing off screen. Tracks target `fig` unless the figure
|
|
9208
|
+
says `data-target="…"`.
|
|
9209
|
+
|
|
9210
|
+
`tinyfly-math.iife.js` (about 40 KB gzipped) works on its own: it carries the
|
|
9211
|
+
embed player and controls, `lesson()` and everything in the maths module. A figure
|
|
9212
|
+
with no timeline is drawn as a still. Without `data-tinyfly-auto`, call
|
|
9213
|
+
`tinyfly.mountAllMath()`.
|
|
9214
|
+
|
|
9215
|
+
`mathFigureToSvg(figure, values, { title })` writes a standalone SVG of a figure
|
|
9216
|
+
at some values, for static pages, RSS, email and print.
|
|
9217
|
+
|
|
9218
|
+
## Explorables
|
|
9219
|
+
|
|
9220
|
+
```js
|
|
9221
|
+
import { linearMapFigure, mathExplorable } from '@algorisys/tinyfly/math'
|
|
9222
|
+
|
|
9223
|
+
const explorable = mathExplorable(element, linearMapFigure(), {
|
|
9224
|
+
drag: [{ matrix: 'M', column: 0 }, { matrix: 'M', column: 1 }], // drag î and ĵ
|
|
9225
|
+
sliders: [], // { value, min, max, step?, label? }
|
|
9226
|
+
snap: 0.1, // world units (0 for none)
|
|
9227
|
+
onChange: (values) => console.log(values.M),
|
|
9228
|
+
})
|
|
9229
|
+
explorable.set('M', [0, -1, 1, 0])
|
|
9230
|
+
```
|
|
9231
|
+
|
|
9232
|
+
Drag handles take a vector value (`{ vector: 'v' }`) or a matrix column. Sliders
|
|
9233
|
+
take number values. Every change re-lays the figure out from its values, so the
|
|
9234
|
+
reader sees exactly what the same values give in a video.
|
|
9235
|
+
|
|
9236
|
+
## In a video
|
|
9237
|
+
|
|
9238
|
+
```js
|
|
9239
|
+
// examples/headless-video/linear-map-short.mjs (abridged)
|
|
9240
|
+
import { linearMapFigure, mathTarget, mathSteps } from '@algorisys/tinyfly/math'
|
|
9241
|
+
import { lesson } from '@algorisys/tinyfly/teach'
|
|
9242
|
+
|
|
9243
|
+
const figure = linearMapFigure({ width: 1080, height: 1920, x: [-4, 4] })
|
|
9244
|
+
const l = lesson({ id: 'short' })
|
|
9245
|
+
mathSteps(l, 'fig', figure).applyMatrix([1, 1, 0, 1])
|
|
9246
|
+
export default { width: 1080, height: 1920, fps: 30, targets: { fig: mathTarget(figure) }, timeline: l.definition() }
|
|
9247
|
+
```
|
|
9248
|
+
|
|
9249
|
+
```bash
|
|
9250
|
+
npx tinyfly video examples/headless-video/linear-map-short.mjs
|
|
9251
|
+
```
|
|
9252
|
+
|
|
9253
|
+
Line widths and text sizes are given for a 600 px figure and scale with the
|
|
9254
|
+
figure's smaller side, so a figure reads the same as a 600 px card and as a
|
|
9255
|
+
1080×1920 short. `mathTarget()` is a canvas custom target: register it on any
|
|
9256
|
+
`CanvasAdapter` too, and `describeTarget` / `checkTracks` know its props.
|
|
9257
|
+
|
|
9258
|
+
## Equations
|
|
9259
|
+
|
|
9260
|
+
Equations are typeset by a built-in TeX subset, with no KaTeX or MathJax:
|
|
9261
|
+
|
|
9262
|
+
- `^` and `_`, `\frac`, `\sqrt`, `\vec`, `\hat`, `\bar`
|
|
9263
|
+
- `\sum`, `\prod` and `\int`, with limits above and below in display style
|
|
9264
|
+
- Named operators: `\sin \cos \tan \log \ln \exp \det \lim \max \min` …
|
|
9265
|
+
- Greek letters
|
|
9266
|
+
- Symbols: `\cdot \times \pm \le \ge \ne \approx \to \infty \partial \nabla \in` …
|
|
9267
|
+
- Matrices: `\begin{pmatrix|bmatrix|vmatrix|matrix} … \end{…}`
|
|
9268
|
+
- `\text{…}`, `\color{name}{…}`, and spacing `\, \; \quad`
|
|
9269
|
+
- `\left( … \right)`, with delimiters at their natural size
|
|
9270
|
+
- `\id{name}{…}`, which names a term
|
|
9271
|
+
- `\val{name}` and `\val{name:digits}` for live values
|
|
9272
|
+
|
|
9273
|
+
Layout uses fixed glyph metrics, never a font's measurements, so an equation
|
|
9274
|
+
lands in the same place everywhere. The glyphs are drawn in a serif maths face
|
|
9275
|
+
(`MATH_FONT`: Latin Modern Math, STIX Two Math, Cambria Math, then Times-like
|
|
9276
|
+
fallbacks).
|
|
9277
|
+
|
|
9278
|
+
An `equation` item steps between lines of TeX. Terms pair up by their text and
|
|
9279
|
+
order (`x#1`, `=#1`, `2#2`), so `2x + 3 = 7` → `2x = 4` keeps `2`, `x` and `=`,
|
|
9280
|
+
fades `+ 3` and `7`, and fades in `4`. Name a term with `\id{lhs}{…}` to carry it
|
|
9281
|
+
when its text changes. `layoutTex()` and `morphEquation()` are available on
|
|
9282
|
+
their own.
|
|
9283
|
+
|
|
9284
|
+
## Ready figures
|
|
9285
|
+
|
|
9286
|
+
| Preset | Shows |
|
|
9287
|
+
|---|---|
|
|
9288
|
+
| `linearMapFigure()` | The grid, î, ĵ and the unit square carried by `M`, with the matrix in TeX |
|
|
9289
|
+
| `determinantFigure()` | The same, with the square's area labelled `det = …` |
|
|
9290
|
+
| `eigenFigure({ matrix })` | The eigenlines of `matrix` (value `A`) while `M` animates toward it |
|
|
9291
|
+
| `vectorSumFigure({ u, v })` | u + v tip to tail |
|
|
9292
|
+
| `spanFigure({ u, v? })` | Vectors and the lines they span |
|
|
9293
|
+
| `tangentFigure({ expr, at })` | The tangent at `a`, with its slope |
|
|
9294
|
+
| `secantFigure({ expr, at, h })` | The secant through `a` and `a + h`; key `h` to 0 |
|
|
9295
|
+
| `riemannFigure({ expr, from, to, n, rule })` | `n` rectangles, the sum and the exact integral |
|
|
9296
|
+
| `areaFigure({ expr, from, to })` | The area up to `b`, its value shown |
|
|
9297
|
+
| `taylorFigure({ expr, at, order })` | Taylor polynomials of degree `order` |
|
|
9298
|
+
| `limitFigure({ expr, at, limit })` | A point `p` sliding toward a hole |
|
|
9299
|
+
| `normalFigure({ mean, sd, shade })` | The normal curve with P(a ≤ X ≤ b) shaded (`mu`, `sigma`, `a`, `b`) |
|
|
9300
|
+
| `binomialFigure({ n, p })` | Binomial bars |
|
|
9301
|
+
| `cltFigure({ of, k, samples })` | Means of `k` draws piling into a normal curve |
|
|
9302
|
+
| `galtonFigure({ rows, balls })` | A Galton board |
|
|
9303
|
+
| `monteCarloPiFigure({ count })` | Points in a square; the share inside the circle ≈ π/4 |
|
|
9304
|
+
| `regressionFigure({ slope, intercept, noise, count })` | Noisy points and the least-squares line |
|
|
9305
|
+
| `bayesFigure({ prior, sensitivity, falsePositive })` | A medical test as areas: P(condition given a positive) |
|
|
9306
|
+
|
|
9307
|
+
Each returns a plain figure to change or extend. In each, `M` starts at the
|
|
9308
|
+
identity unless `matrix` is given.
|
|
9309
|
+
|
|
9310
|
+
## Examples
|
|
9311
|
+
|
|
9312
|
+
- Gallery: **Linear Map**, **Eigenvectors**, **Equation Steps**, **Matrix Lesson**,
|
|
9313
|
+
**Derivative**, **Riemann Sums**, **Taylor Series**, **Galton Board**, **Central Limit
|
|
9314
|
+
Theorem**, **Monte Carlo π** and **Bayes: a Positive Test**.
|
|
9315
|
+
- Videos: `linear-map-short.mjs`, `riemann-short.mjs` and `galton-short.mjs` (9:16);
|
|
9316
|
+
`eigen-explainer.mjs`, `taylor-explainer.mjs` and `clt-explainer.mjs` (16:9), in
|
|
9317
|
+
`examples/headless-video/`.
|
|
9318
|
+
|
|
9319
|
+
## Next
|
|
9320
|
+
|
|
9321
|
+
Discrete maths (graphs, trees, sets) and AI/ML (networks, gradient descent on
|
|
9322
|
+
a loss surface) build on the same figure model.
|
|
9323
|
+
See `todo.md` for their status.
|
|
9324
|
+
|
|
9325
|
+
---
|
|
9326
|
+
|
|
8990
9327
|
<!-- docs/video-rendering.md -->
|
|
8991
9328
|
|
|
8992
9329
|
# Rendering Video from Code
|
|
@@ -9935,8 +10272,8 @@ On a page with no build step, load the maps add-on after the browser bundle; it
|
|
|
9935
10272
|
adds to the same `tinyfly` global:
|
|
9936
10273
|
|
|
9937
10274
|
```html
|
|
9938
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
9939
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
10275
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly.iife.js"></script>
|
|
10276
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.117.0/cdn/tinyfly-maps.iife.js"></script>
|
|
9940
10277
|
```
|
|
9941
10278
|
|
|
9942
10279
|
It is a separate script because the offline world map it carries adds about
|
|
@@ -15165,7 +15502,7 @@ magnet.addEventListener('pointerleave', () => {
|
|
|
15165
15502
|
|
|
15166
15503
|
<!-- capabilities: generated from the library -->
|
|
15167
15504
|
|
|
15168
|
-
# tinyfly capabilities (v0.
|
|
15505
|
+
# tinyfly capabilities (v0.117.0)
|
|
15169
15506
|
|
|
15170
15507
|
Generated from the library itself: every name below is accepted, and names not listed are rejected (beat scripts, code panels and `checkTracks` say which name was probably meant).
|
|
15171
15508
|
|
|
@@ -15638,6 +15975,59 @@ Decision review cameras: front-foot, striker-crease, bowler-crease. cricketCamer
|
|
|
15638
15975
|
- `cells, pointer, stack, queue, table, pipeline`: diagram primitives (SVG markup + step helpers)
|
|
15639
15976
|
- `figure({ width, height, children })`: the SVG holding the pieces
|
|
15640
15977
|
|
|
15978
|
+
## Maths (`@algorisys/tinyfly/math`)
|
|
15979
|
+
|
|
15980
|
+
A figure is JSON: a plane and items. Tracks on its target animate values by name and item props. One layout feeds a canvas (videos) and SVG (lesson embeds), so they match.
|
|
15981
|
+
|
|
15982
|
+
- `mathFigure(spec)`: checks a figure (JSON: width, height, x?, y?, theme?: dark | light | chalk, values, items) and says how to fix it
|
|
15983
|
+
- `layoutFigure(spec, props)`: the figure at some values as shapes; drawDisplayList(ctx, list) or displayListToSvg(list) draws them
|
|
15984
|
+
- `mathTarget(spec, { x, y })`: a canvas target for videos and canvas pages; tracks animate its values and item props
|
|
15985
|
+
- `mathSteps(lesson, target, spec, { hidden })`: lesson steps: toValue, applyMatrix, drawOn, fadeIn, fadeOut, showStep (equations)
|
|
15986
|
+
- `mountMath(element) / mountAllMath()`: lesson-page embeds: <figure data-tinyfly-math> with data-tinyfly-figure and data-tinyfly-timeline JSON scripts, stepped like any embed
|
|
15987
|
+
- `mathExplorable(element, spec, { sliders, drag })`: reader-driven figures: sliders on number values, drag vector tips or matrix columns
|
|
15988
|
+
- `mathFigureToSvg(spec, props)`: a standalone SVG of a figure at some values
|
|
15989
|
+
- `linearMapFigure, determinantFigure, eigenFigure, vectorSumFigure, spanFigure`: ready linear algebra figures; the matrix is the value M
|
|
15990
|
+
- `tangentFigure, secantFigure, riemannFigure, areaFigure, taylorFigure, limitFigure`: ready calculus figures; their moving parts are number values (a, h, n, b, order, p)
|
|
15991
|
+
- `differentiate / compileDerivative / integrate`: exact symbolic derivatives of expressions; Simpson integration
|
|
15992
|
+
- `normalFigure, binomialFigure, cltFigure, galtonFigure, monteCarloPiFigure, regressionFigure, bayesFigure`: ready probability and statistics figures
|
|
15993
|
+
- `distributions`: { kind: normal | uniform | exponential | binomial | poisson | dice | mean, …numbers or value names }; density, meanOf, sdOf, samples (seeded)
|
|
15994
|
+
- `layoutTex(tex) / morphEquation(a, b, t)`: the built-in TeX subset, and term-by-term transitions
|
|
15995
|
+
- `vec2, mat2`: 2D vectors and 2×2 matrices (apply, multiply, determinant, inverse, eigen)
|
|
15996
|
+
|
|
15997
|
+
Items (each has `id`, `kind`, and optional `color`, `draw`, `opacity`):
|
|
15998
|
+
|
|
15999
|
+
- `grid` { step?, transform?: matrix value, ghost? }: lines of the plane, warped by a matrix
|
|
16000
|
+
- `axes` { ticks?, labels? }
|
|
16001
|
+
- `vector` { to, from?, transform?, label? (TeX), labelAt?: tip | middle }
|
|
16002
|
+
- `basis` { transform? }: î and ĵ
|
|
16003
|
+
- `point` { at, transform?, label?, hollow? } or { on: expr, x } (a point riding a curve)
|
|
16004
|
+
- `function` { expr: "sin(k x)", domain?, derivative?, dashed? }: y = f(x); number values are its parameters
|
|
16005
|
+
- `parametric` { x, y (expressions in t), t?, transform? }
|
|
16006
|
+
- `polygon` { points? (default the unit square), transform?, label? }: \val{M.det} shows the determinant
|
|
16007
|
+
- `line` { along } or { eigen: matrix value }: a span, or eigenlines
|
|
16008
|
+
- `label` { tex, at, screen?, size?, align?, backdrop? }
|
|
16009
|
+
- `equation` { steps: [TeX…], at, screen? }: ITEM.step moves between steps, terms gliding
|
|
16010
|
+
- `tangent` { expr, at, h? (secant), label? }: \val{ID.slope} is the exact slope
|
|
16011
|
+
- `riemann` { expr, from, to, n, rule?: left | right | midpoint | trapezoid }: \val{ID.sum}, \val{ID.exact}
|
|
16012
|
+
- `area` { expr, from, to, lower? }: signed, coloured by sign; \val{ID.value}
|
|
16013
|
+
- `taylor` { expr, at, order }: exact Taylor polynomials; a fractional order grows the next term in
|
|
16014
|
+
- `histogram` { distribution, count, bins?, scale?, curve?, seed? }: seeded samples, binned; fills as count grows
|
|
16015
|
+
- `distribution` { distribution, shade?: [a, b] }: a density curve (bars when discrete); \val{ID.p}
|
|
16016
|
+
- `galton` { rows?, balls, spacing?, top?, seed? }: a Galton board; fractional balls = the next one falling
|
|
16017
|
+
- `scatter` { points: uniform | linear, count, inside?, fit?, seed? }: Monte Carlo and regression; \val{ID.ratio}, \val{ID.r}
|
|
16018
|
+
- `bayes` { prior, truePositive, falsePositive }: Bayes as areas; \val{ID.posterior}
|
|
16019
|
+
|
|
16020
|
+
Props a timeline animates:
|
|
16021
|
+
|
|
16022
|
+
- `NAME`: a value: a number, [x, y] vector or [a, b, c, d] matrix (row by row; columns are where î and ĵ land)
|
|
16023
|
+
- `ITEM.draw`: 0..1, draws an item on
|
|
16024
|
+
- `ITEM.opacity`: 0..1
|
|
16025
|
+
- `ITEM.step`: an equation's step; fractional values are part way
|
|
16026
|
+
|
|
16027
|
+
Expression functions: `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `sinh`, `cosh`, `tanh`, `exp`, `ln`, `log`, `log2`, `sqrt`, `abs`, `floor`, `ceil`, `round`, `sign`, `min`, `max`, `sigmoid`, `relu`; constants `pi`, `e`, `tau`.
|
|
16028
|
+
|
|
16029
|
+
TeX subset: ^ _ \frac \sqrt \vec \hat \bar, \sum \prod \int with limits, \sin \lim … , Greek, \cdot \times \le \to \infty …, pmatrix / bmatrix / vmatrix, \text, \color{c}{…}, \id{name}{…} (names a term for transitions), \val{name:digits} (a live value)
|
|
16030
|
+
|
|
15641
16031
|
## Command line
|
|
15642
16032
|
|
|
15643
16033
|
- `tinyfly capabilities [--json]`: this catalog
|