@algorisys/tinyfly 0.127.1 → 0.129.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 +14 -6
- package/bin/tinyfly.mjs +47 -1
- package/docs/character-appearance.md +8 -3
- 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 +6 -2
- package/docs/maps.md +2 -2
- package/docs/math.md +1 -1
- package/docs/presenting.md +258 -0
- package/docs/props.md +2 -0
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +736 -735
- package/lib/addons/{cricket-play-a5jHHZVh.js → cricket-play-qqm3aXd-.js} +2132 -2112
- package/lib/addons/present.js +586 -0
- package/lib/addons/sports.js +1 -1
- package/lib/browser/tinyfly.iife.js +65 -15
- package/lib/browser/tinyfly.js +6784 -6260
- package/lib/browser/tinyfly.umd.js +65 -15
- package/lib/types/browser/index.d.ts +4 -0
- package/lib/types/characters/body/bean-figure.d.ts +3 -0
- package/lib/types/characters/character.d.ts +2 -2
- package/lib/types/characters/head/face.d.ts +9 -2
- package/lib/types/characters/scenery.d.ts +3 -0
- package/lib/types/present/deck-labels.d.ts +46 -0
- package/lib/types/present/deck-state.d.ts +128 -0
- package/lib/types/present/deck-styles.d.ts +16 -0
- package/lib/types/present/deck.d.ts +104 -0
- package/lib/types/present/index.d.ts +20 -0
- package/lib/types/present/inline-deck.d.ts +30 -0
- package/lib/types/present/presenter-view.d.ts +29 -0
- package/llms-full.txt +293 -18
- package/llms.txt +35 -34
- package/package.json +7 -3
- package/skills/tinyfly/SKILL.md +5 -1
package/README.md
CHANGED
|
@@ -34,6 +34,13 @@ A lightweight, API-driven animation engine and visual editor for creating high-p
|
|
|
34
34
|
- **Track queries** - `getTracks(filter)`, `removeTracks(filter)`, and `findConflicts()` to surface overlapping writes
|
|
35
35
|
- **Compile-time values** - `"+=100"` and `"random(-50, 50)"` resolve at authoring time from a recorded seed, so the JSON holds plain numbers and replays identically
|
|
36
36
|
|
|
37
|
+
### Presentations
|
|
38
|
+
- **Decks from markup** - `@algorisys/tinyfly/present`: `createDeck('#deck', { scenes })` turns `[data-slide]` sections into a talk stepped with a clicker or the keyboard, on a fixed 1920 × 1080 stage scaled to any screen; `[data-step]` fragments appear on the click they name
|
|
39
|
+
- **A scene per slide** - `{ marks, draw(ctx, frame) }`: one scene time per click, and the deck plays the clock from mark to mark, so stick figures act out each point as the presenter clicks. A second press while a step plays shows its end and never skips a step
|
|
40
|
+
- **Presenter window** - Notes, elapsed time, time left of the slot, and what the next press will do, in a second window that works from `file://`
|
|
41
|
+
- **Countdowns** - `<button data-timer="30">` for polls and QR codes; scenes get the countdown each frame, so a figure can dance while the room votes
|
|
42
|
+
- **One offline file** - `npx @algorisys/tinyfly present index.html -o Talk.html` inlines scripts, styles, images and fonts, and fails when anything would still need the network. `DeckState` is the same deck with no page, driven by explicit times ([guide](docs/presenting.md))
|
|
43
|
+
|
|
37
44
|
### Scroll & Interaction
|
|
38
45
|
- **Scroll-driven playback** - `ScrollDriver` scrubs a timeline against scroll position with GSAP-style trigger strings (`'top bottom'`, `'top top+=500'`); the geometry is a pure, unit-tested function
|
|
39
46
|
- **Play when visible** - `VisibilityDriver` plays on appearance (`once` / `repeat` / `reset`) via IntersectionObserver
|
|
@@ -157,8 +164,8 @@ use `character(castMember('animeYoungWoman', 300))` in code.
|
|
|
157
164
|
|
|
158
165
|
**Bean figures**: `figure: 'bean'` draws the white outlined stick-figure style natively:
|
|
159
166
|
smooth outlined noodle limbs with no seams at the elbows, knees, shoulders, neck or hips (or
|
|
160
|
-
bare line limbs with `bean: { limbs: 'line' }`), a shaped body, big oval eyes (`face.style: 'oval'`),
|
|
161
|
-
mittens and cartoon shoes, plus detective gear (`coat`, `fedora`, aviator `shades`), on the same rig, so every pose, gait, dance and expression works.
|
|
167
|
+
bare line limbs with `bean: { limbs: 'line' }`), a shaped body, big oval eyes (`face.style: 'oval'`, sized with `eyeScale`/`eyeAspect`),
|
|
168
|
+
mittens and cartoon shoes, a `tie`, plus detective gear (`coat`, `fedora`, aviator `shades`), on the same rig, so every pose, gait, dance and expression works.
|
|
162
169
|
Try `character(castMember('beanMan', 400))` or the other `BEAN_CAST` presets; see
|
|
163
170
|
[the appearance guide](docs/character-appearance.md#bean-figures-white-outlined-stick-figures).
|
|
164
171
|
Household clothes dress them too: a `skirt` (a sari, or a kurta's hem with `length`) that
|
|
@@ -220,6 +227,7 @@ filling the page. [Open the manga example full page](https://tinyfly.app/example
|
|
|
220
227
|
- [GSAP Compatibility](docs/gsap-compat.md) — The GSAP-flavoured API, the mapping table, and what we deliberately don't do
|
|
221
228
|
- [Rendering Video from Code](docs/video-rendering.md) — `tinyfly video`, custom code-drawn targets, narration timing, captions and stills, without a browser
|
|
222
229
|
- [Teaching Animations](docs/teaching.md) — Step-through figures: markers, captions, the stepping player, controls, declarative embeds, scenarios the reader chooses, `tinyfly/teach`, validate and render
|
|
230
|
+
- [Presentations](docs/presenting.md) — `tinyfly/present`: decks from markup, a scene per slide, the presenter window, countdowns, and one offline HTML file
|
|
223
231
|
- [Maths Animations](docs/math.md) — `tinyfly/math`: figures, the TeX subset, equation steps, lesson embeds, explorables and videos
|
|
224
232
|
- [Extending tinyfly](docs/extending.md) — Writing adapters, custom eases and stagger offsets, adding a track kind, contributing examples
|
|
225
233
|
- [Deployment](docs/DEPLOYMENT.md) — Hosting, Docker, and CDN configuration
|
|
@@ -311,7 +319,7 @@ GSAP-shaped functions at the top level. Teaching embeds are included: add
|
|
|
311
319
|
itself.
|
|
312
320
|
|
|
313
321
|
```html
|
|
314
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
322
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.0/cdn/tinyfly.iife.js"></script>
|
|
315
323
|
<script>
|
|
316
324
|
tinyfly.to('.box', { x: 200, rotate: 90, duration: 1, ease: 'power2.out' })
|
|
317
325
|
|
|
@@ -348,7 +356,7 @@ A teaching figure needs no code at all:
|
|
|
348
356
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON with markers… }</script>
|
|
349
357
|
<figcaption>Appending to a full slice</figcaption>
|
|
350
358
|
</figure>
|
|
351
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
359
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.0/cdn/tinyfly.iife.js" data-tinyfly-auto></script>
|
|
352
360
|
```
|
|
353
361
|
|
|
354
362
|
See [Teaching Animations](docs/teaching.md).
|
|
@@ -447,7 +455,7 @@ Without a build step, the player bundle puts the same functions on a `tinyfly` g
|
|
|
447
455
|
<div data-tinyfly="box" style="width: 60px; height: 60px; background: #4a9eff;"></div>
|
|
448
456
|
</div>
|
|
449
457
|
|
|
450
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
458
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.0/cdn/tinyfly-player.iife.js"></script>
|
|
451
459
|
<script>
|
|
452
460
|
tinyfly.play('#animation', './animation.json', { loop: -1 })
|
|
453
461
|
</script>
|
|
@@ -556,7 +564,7 @@ Or skip the code entirely with declarative embeds (see [Teaching Animations](doc
|
|
|
556
564
|
<svg viewBox="0 0 720 200">…</svg>
|
|
557
565
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON… }</script>
|
|
558
566
|
</figure>
|
|
559
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
567
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
|
|
560
568
|
```
|
|
561
569
|
|
|
562
570
|
### Audio / Video Sync
|
package/bin/tinyfly.mjs
CHANGED
|
@@ -36,6 +36,14 @@
|
|
|
36
36
|
* says whether the video loops (exit 1 when it does not). Needs ffmpeg on
|
|
37
37
|
* the PATH (not for stills or --loop-check) and the optional package
|
|
38
38
|
* @napi-rs/canvas.
|
|
39
|
+
*
|
|
40
|
+
* tinyfly present <deck.html> [-o <out.html>] [--allow-remote]
|
|
41
|
+
* Build a presentation into one HTML file that works offline from
|
|
42
|
+
* file://: scripts and stylesheets inlined, images, fonts and media as
|
|
43
|
+
* data URIs. Exit 1 when a local file is missing, when something cannot
|
|
44
|
+
* be inlined, or when the page still loads anything from the network
|
|
45
|
+
* (--allow-remote keeps network URLs and only warns). Default output:
|
|
46
|
+
* <deck>.offline.html beside the page.
|
|
39
47
|
*/
|
|
40
48
|
import { readFileSync, writeFileSync } from 'node:fs'
|
|
41
49
|
import { basename, dirname, extname, join, resolve } from 'node:path'
|
|
@@ -86,7 +94,8 @@ const usage = () => {
|
|
|
86
94
|
' tinyfly validate <timeline.json> [<timeline.json> …] [--markup <file>]\n' +
|
|
87
95
|
' tinyfly render <timeline.json> <markup file> [--at start|end|<ms>|<marker id>]\n' +
|
|
88
96
|
' tinyfly video <scene.mjs> [-o <out.mp4>] [--stills <dir>] [--frames <i,j,…> | --times <ms,…>] [--loop-check]\n' +
|
|
89
|
-
' [--scale <n>] [--fps <n>] [--crf <n>] [--codec h264|prores] [--no-audio] [--srt <file>] [--vtt <file>]'
|
|
97
|
+
' [--scale <n>] [--fps <n>] [--crf <n>] [--codec h264|prores] [--no-audio] [--srt <file>] [--vtt <file>]\n' +
|
|
98
|
+
' tinyfly present <deck.html> [-o <out.html>] [--allow-remote]'
|
|
90
99
|
)
|
|
91
100
|
process.exit(2)
|
|
92
101
|
}
|
|
@@ -150,6 +159,8 @@ if (command === 'capabilities') {
|
|
|
150
159
|
process.stdout.write(renderFrame(readFileSync(markupFile, 'utf8'), readJson(timelineFile), frame))
|
|
151
160
|
} else if (command === 'video') {
|
|
152
161
|
await video()
|
|
162
|
+
} else if (command === 'present') {
|
|
163
|
+
await present()
|
|
153
164
|
} else {
|
|
154
165
|
usage()
|
|
155
166
|
}
|
|
@@ -245,3 +256,38 @@ async function video() {
|
|
|
245
256
|
process.exit(1)
|
|
246
257
|
}
|
|
247
258
|
}
|
|
259
|
+
|
|
260
|
+
async function present() {
|
|
261
|
+
const output = flag('-o') ?? flag('--output')
|
|
262
|
+
const allowRemote = has('--allow-remote')
|
|
263
|
+
const [pageFile] = rest
|
|
264
|
+
if (!pageFile || rest.length > 1) usage()
|
|
265
|
+
const dir = dirname(resolve(pageFile))
|
|
266
|
+
const read = (encoding) => (path) => {
|
|
267
|
+
try {
|
|
268
|
+
return readFileSync(join(dir, path), encoding)
|
|
269
|
+
} catch {
|
|
270
|
+
return null
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
let html
|
|
274
|
+
try {
|
|
275
|
+
html = readFileSync(pageFile, 'utf8')
|
|
276
|
+
} catch (error) {
|
|
277
|
+
console.error(`tinyfly: cannot read ${pageFile}: ${error.message}`)
|
|
278
|
+
process.exit(2)
|
|
279
|
+
}
|
|
280
|
+
const { inlineDeck } = await import('../lib/addons/present.js')
|
|
281
|
+
const result = inlineDeck(html, { readText: read('utf8'), readBase64: read('base64') })
|
|
282
|
+
for (const path of result.missing) console.error(`error: missing file: ${path}`)
|
|
283
|
+
for (const item of result.unsupported) console.error(`error: cannot inline: ${item}`)
|
|
284
|
+
for (const url of result.remote) console.error(`${allowRemote ? 'warning' : 'error'}: loads from the network: ${url}`)
|
|
285
|
+
const errors = result.missing.length + result.unsupported.length + (allowRemote ? 0 : result.remote.length)
|
|
286
|
+
if (errors > 0) {
|
|
287
|
+
console.error(`${pageFile}: ${errors} error(s); nothing written`)
|
|
288
|
+
process.exit(1)
|
|
289
|
+
}
|
|
290
|
+
const out = output ?? join(dir, `${basename(pageFile, extname(pageFile))}.offline.html`)
|
|
291
|
+
writeFileSync(out, result.html)
|
|
292
|
+
console.error(`${out}: ${result.inlined.length} file(s) inlined, ${(Buffer.byteLength(result.html) / 1024).toFixed(0)} KB`)
|
|
293
|
+
}
|
|
@@ -567,7 +567,7 @@ const stick = character(castMember('beanStick', 400)) // bare line limbs
|
|
|
567
567
|
skirt over both), the neck, the body (with its drape, and coat), the near
|
|
568
568
|
arm and the head (and fedora). A limb reaching toward the viewer
|
|
569
569
|
(hands on the knees, seated thighs) draws over the body.
|
|
570
|
-
- `bean: { limbs, torso, limbWidth, lineWidth, outlineWidth, fill, shirt, sleeves, trousers, shoes }`:
|
|
570
|
+
- `bean: { limbs, torso, limbWidth, lineWidth, outlineWidth, fill, shirt, sleeves, trousers, shoes, tie }`:
|
|
571
571
|
`limbs: 'tube'` (default, outlined noodles) or `'line'` (bare round-capped
|
|
572
572
|
ink lines for the arms, legs and neck; the body, eyes, mittens and shoes
|
|
573
573
|
stay; `halo: '#f5f5f4'` adds a pale edge so they read on a dark set); the
|
|
@@ -575,9 +575,14 @@ const stick = character(castMember('beanStick', 400)) // bare line limbs
|
|
|
575
575
|
(1; 1.3 chubby, 0.85 thin); widths as fractions of the height (0.024 tube,
|
|
576
576
|
0.017 line, 0.0105 outline; `lineWidth` on the character also sets the
|
|
577
577
|
outline); `fill` (white); a `shirt` colour with `sleeves: 'short' | 'long' | 'none'`;
|
|
578
|
-
`trousers`; `shoes` (the fill; a dark shoe gets a shine and a dark sole)
|
|
579
|
-
|
|
578
|
+
`trousers`; `shoes` (the fill; a dark shoe gets a shine and a dark sole);
|
|
579
|
+
`tie` (a necktie down the chest: a knot at the collar and a pointed blade,
|
|
580
|
+
sliding toward the side the body turns to and hidden from behind; under a coat).
|
|
581
|
+
An `outfit`'s `shirt`, `trousers`, `sleeves` and `tie` colour the bean too (its
|
|
580
582
|
layers are not used).
|
|
583
|
+
- Bigger comedy eyes: `face: { eyeScale: 1.2, eyeAspect: 0.8 }` makes the oval
|
|
584
|
+
eyes larger and rounder (scale 0.5–1.2, aspect 0.45–1.2); they move apart as
|
|
585
|
+
they grow, so they still nearly touch, and glasses grow round them.
|
|
581
586
|
- Detective gear: `coat` (a trench coat in that colour: lapels, a belt and
|
|
582
587
|
buckle, double-breasted buttons, a hem at the knee and sleeves to the
|
|
583
588
|
wrist), `fedora` (a brim, a pinched crown and a band) and `shades: true`
|
package/docs/editor-guide.md
CHANGED
|
@@ -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.
|
|
1146
|
+
`https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.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
|
@@ -754,7 +754,7 @@ For simple website embedding without a build system.
|
|
|
754
754
|
</html>
|
|
755
755
|
```
|
|
756
756
|
|
|
757
|
-
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.
|
|
757
|
+
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.129.0/cdn/tinyfly-player.iife.js`.
|
|
758
758
|
|
|
759
759
|
---
|
|
760
760
|
|
package/docs/getting-started.md
CHANGED
|
@@ -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.
|
|
188
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.0/cdn/tinyfly.iife.js"></script>
|
|
189
189
|
<script>
|
|
190
190
|
tinyfly.to('.box', { x: 200, duration: 1 })
|
|
191
191
|
</script>
|
package/docs/gsap-compat.md
CHANGED
|
@@ -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.
|
|
77
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.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
|
@@ -220,8 +220,9 @@ not a `look` value. It uses the same expressions, blink, gaze and turn fields.
|
|
|
220
220
|
White outlined stick figures are `figure: 'bean'` (presets `beanMan`, `beanWoman`,
|
|
221
221
|
`beanKid`, `beanBoss`, `beanDetective`, `beanStick` in `BEAN_CAST`): seamless outlined noodle limbs or bare
|
|
222
222
|
lines (`bean: { limbs: 'tube' | 'line' }`), a shaped body (`bean.torso` fullness), big oval eyes
|
|
223
|
-
(`face.style: 'oval'`, usable on any figure
|
|
224
|
-
|
|
223
|
+
(`face.style: 'oval'`, usable on any figure; `face: { eyeScale: 1.2, eyeAspect: 0.8 }` makes them bigger
|
|
224
|
+
and rounder), `hands: 'mitten'` and cartoon shoes; colours from
|
|
225
|
+
`bean: { shirt, sleeves, trousers, shoes, tie }` or an `outfit` (its tie too); detective gear `bean: { coat, fedora, shades: true }`
|
|
225
226
|
(aviators replace the eyes, brows still show); `halo` gives line limbs a pale edge. A bean is always drawn clean.
|
|
226
227
|
Household clothes on a bean: `bean: { skirt: '#c2410c' }` (a sari to the ankle) or
|
|
227
228
|
`skirt: { color, length: 0.45 }` (a kurta hem; pair it with `trousers`), `drape` (a pallu or dupatta sash)
|
|
@@ -364,6 +365,9 @@ scriptTracks: 2 problem(s) in the beats:
|
|
|
364
365
|
- **Code panels** reject unknown languages and remove styles. `token()` throws
|
|
365
366
|
when a line doesn't have the word.
|
|
366
367
|
- **Teaching timelines**: `npx @algorisys/tinyfly validate timeline.json --markup figure.svg`.
|
|
368
|
+
- **Presentations** ([presenting.md](presenting.md)): `npx @algorisys/tinyfly present index.html -o Talk.html`
|
|
369
|
+
fails when the page would still load a file or the network. Check moments
|
|
370
|
+
with `deck.seek(slide, step, ms)`.
|
|
367
371
|
|
|
368
372
|
## 4. Look at it
|
|
369
373
|
|
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.
|
|
18
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
17
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.0/cdn/tinyfly.iife.js"></script>
|
|
18
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.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
|
@@ -258,7 +258,7 @@ lesson's step options (`duration`, `easing`, `delay`).
|
|
|
258
258
|
<figcaption>The determinant is the area of the unit square after the map.</figcaption>
|
|
259
259
|
</figure>
|
|
260
260
|
|
|
261
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
261
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.0/cdn/tinyfly-math.iife.js" data-tinyfly-auto></script>
|
|
262
262
|
```
|
|
263
263
|
|
|
264
264
|
The figure draws itself into an SVG and redraws from the timeline whenever the
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Presentations
|
|
2
|
+
|
|
3
|
+
A talk given from a tinyfly page instead of a slide deck: the presenter steps
|
|
4
|
+
through with a clicker, and on each click a scene plays to its next beat while the
|
|
5
|
+
slide's text appears. `@algorisys/tinyfly/present` is the part that makes a page a
|
|
6
|
+
deck:
|
|
7
|
+
|
|
8
|
+
| Piece | What it gives you |
|
|
9
|
+
|---|---|
|
|
10
|
+
| **`createDeck()`** | Slides from plain markup, steps, a scene per slide, keys and clicker, a stage that scales to any screen |
|
|
11
|
+
| **Scenes** | `{ marks, draw }`: one scene time per click; the deck plays the clock from mark to mark |
|
|
12
|
+
| **Presenter window** | Notes, the clock, time left of the slot, and what the next press will do |
|
|
13
|
+
| **Countdowns** | `<button data-timer="30">` for polls and QR codes; scenes are told while one runs |
|
|
14
|
+
| **`DeckState`** | The same deck with no page: plain state driven by explicit times |
|
|
15
|
+
| **`tinyfly present`** | One HTML file that works offline from `file://` |
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<main id="deck">
|
|
21
|
+
<section data-slide="hello" data-title="Hello">
|
|
22
|
+
<h1>A deck made with tinyfly</h1>
|
|
23
|
+
<aside data-notes>Welcome everyone. Wait for the wave.</aside>
|
|
24
|
+
</section>
|
|
25
|
+
|
|
26
|
+
<section data-slide="points" data-title="Three points">
|
|
27
|
+
<ul>
|
|
28
|
+
<li data-step="1">Shown on the first click</li>
|
|
29
|
+
<li data-step="2">Shown on the second</li>
|
|
30
|
+
<li data-step="3" data-reveal="pop">Shown on the third</li>
|
|
31
|
+
</ul>
|
|
32
|
+
</section>
|
|
33
|
+
</main>
|
|
34
|
+
|
|
35
|
+
<script src="vendor/tinyfly.iife.js"></script>
|
|
36
|
+
<script src="scenes.js"></script>
|
|
37
|
+
<script>
|
|
38
|
+
tinyfly.createDeck('#deck', { scenes: window.SCENES, slotMinutes: 30 })
|
|
39
|
+
</script>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
With a bundler: `import { createDeck } from '@algorisys/tinyfly/present'`. The
|
|
43
|
+
entry imports nothing else from tinyfly, so it adds only itself.
|
|
44
|
+
|
|
45
|
+
A complete deck with stick figures is in
|
|
46
|
+
[`examples/present-deck`](../examples/present-deck).
|
|
47
|
+
|
|
48
|
+
## Markup
|
|
49
|
+
|
|
50
|
+
| Markup | What it is |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `[data-slide="id"]` | A slide. `data-title` names it in the presenter window |
|
|
53
|
+
| `[data-step="k"]` | Appears on click `k` and stays. `data-reveal` is `pop`, `fade` or `none` (default: it rises into place) |
|
|
54
|
+
| `[data-notes]` | Speaker notes. Never shown on the slide; several are joined |
|
|
55
|
+
| `<button data-timer="30">` | A countdown of 30 seconds on the step of the `[data-step]` around it |
|
|
56
|
+
| `canvas[data-scene]` | Where the slide's scene draws. Added for you when the slide has none |
|
|
57
|
+
|
|
58
|
+
The deck is a fixed stage, 1920 × 1080 unless you pass `width` and `height`, scaled
|
|
59
|
+
to fit the window. Lay slides out in those pixels with your own CSS; the same
|
|
60
|
+
layout then holds on a laptop and a projector.
|
|
61
|
+
|
|
62
|
+
The deck adds classes you can style: `tf-current` on the slide being shown,
|
|
63
|
+
`tf-on` on a fragment from its step on, `tf-now` on the fragment of the current
|
|
64
|
+
step, and `data-current-step` on the slide. Its own look comes from custom
|
|
65
|
+
properties on the deck element: `--tf-deck-bg`, `--tf-deck-accent`,
|
|
66
|
+
`--tf-deck-panel`, `--tf-deck-done`, `--tf-deck-font`.
|
|
67
|
+
|
|
68
|
+
## Scenes
|
|
69
|
+
|
|
70
|
+
`scenes` maps a slide id to a factory. It is called once, the first time the
|
|
71
|
+
slide (or the one before it) is shown, and returns the scene:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
window.SCENES = {
|
|
75
|
+
points({ width, height, el }) {
|
|
76
|
+
return {
|
|
77
|
+
// marks[0]: where the entrance ends. marks[k]: where click k ends.
|
|
78
|
+
marks: [1200, 2600, 4100, 5800],
|
|
79
|
+
draw(ctx, frame) {
|
|
80
|
+
// frame.time plays up to the current mark and waits there.
|
|
81
|
+
drawEverythingAt(ctx, frame.time)
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
| `frame` field | Meaning |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `time` | The slide's scene clock in ms. It plays to the current step's mark and stops |
|
|
91
|
+
| `clock` | A clock in ms that never stops, for motion that loops while the scene waits |
|
|
92
|
+
| `step` | The current step, 0 until the first click |
|
|
93
|
+
| `timer` | `{ state, elapsed, seconds, sinceEnd }` while a countdown runs and after it ends, else `null` |
|
|
94
|
+
| `width`, `height` | The stage size |
|
|
95
|
+
|
|
96
|
+
- **`draw(ctx, frame)`** paints the slide's canvas, which is cleared first.
|
|
97
|
+
- **`update(frame)`** is for everything else: an SVG, DOM elements, or a tinyfly
|
|
98
|
+
timeline you seek to `frame.time`. A scene may have both.
|
|
99
|
+
- **Steps** are the larger of the scene's marks and the highest `data-step` on
|
|
100
|
+
the slide. A slide with no scene steps through its fragments alone.
|
|
101
|
+
- **Back** shows a step as it ends; it does not play backwards.
|
|
102
|
+
- A scene that throws is logged and stopped. The deck carries on.
|
|
103
|
+
|
|
104
|
+
### Marks from a beat script
|
|
105
|
+
|
|
106
|
+
A stick figure's script compiles to tracks with a `duration`. The mark for a
|
|
107
|
+
click is the duration of the script up to the last beat that click plays:
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
const beats = [
|
|
111
|
+
{ do: 'walk', to: 1380, mood: 'happy' }, // entrance
|
|
112
|
+
{ do: 'point', toward: 800, for: 900 }, // click 1
|
|
113
|
+
{ do: 'cheer', mood: 'joyful', for: 1200 }, // click 2
|
|
114
|
+
]
|
|
115
|
+
const options = { from: 2050, ground: 900, height: 300 }
|
|
116
|
+
const marks = [1, 2, 3].map((count) => tinyfly.scriptTracks('guide', beats.slice(0, count), options).duration)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Keys
|
|
120
|
+
|
|
121
|
+
| Key | Does |
|
|
122
|
+
|---|---|
|
|
123
|
+
| `→` `↓` `PageDown` `Space` `Enter` `N`, or a click | Next step |
|
|
124
|
+
| `←` `↑` `PageUp` `Backspace`, or a right click | Back |
|
|
125
|
+
| digits then `Enter` | Go to that slide |
|
|
126
|
+
| `Home` / `End` | First slide / last slide at its last step |
|
|
127
|
+
| `B` or `.` / `W` or `,` | Black / white screen |
|
|
128
|
+
| `F` | Full screen |
|
|
129
|
+
| `R` | Play the current step again |
|
|
130
|
+
| `T` | Start or end the countdown |
|
|
131
|
+
| `P` | Presenter window |
|
|
132
|
+
| `?` or `H` | The key list |
|
|
133
|
+
|
|
134
|
+
Clickers send `PageDown` and `PageUp` (some send the arrows), and `B` or `.` for
|
|
135
|
+
their blank button.
|
|
136
|
+
|
|
137
|
+
**A second press never skips a step.** If Next arrives while a step is still
|
|
138
|
+
playing, the scene jumps to that step's end and stays. A nervous double press
|
|
139
|
+
shows the point at once; it does not move on to the next one.
|
|
140
|
+
|
|
141
|
+
## Countdowns
|
|
142
|
+
|
|
143
|
+
```html
|
|
144
|
+
<div data-step="2">
|
|
145
|
+
<img src="assets/poll-qr.png" alt="">
|
|
146
|
+
<button data-timer="30"></button>
|
|
147
|
+
</div>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
On that step, Next (or the button, or `T`) starts the countdown. Next while it
|
|
151
|
+
runs ends it early. Next after it ends moves on; the deck never moves on by
|
|
152
|
+
itself. Going back or jumping resets it. The button gets `data-state`
|
|
153
|
+
(`idle`, `running`, `done`) and the fragment around it gets `data-timer-state`,
|
|
154
|
+
for your CSS.
|
|
155
|
+
|
|
156
|
+
Scenes see the countdown as `frame.timer`, so a figure can act while the room
|
|
157
|
+
votes:
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
const dancing = frame.timer?.state === 'running'
|
|
161
|
+
const pose = dancing ? tinyfly.danceFrame('bhangra', (frame.timer.elapsed / 60000) * 120).pose : undefined
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Presenter window
|
|
165
|
+
|
|
166
|
+
`P` opens a second window with the elapsed time, the time left of `slotMinutes`,
|
|
167
|
+
the wall clock, the slide's title, its clicks, its notes, and what the next press
|
|
168
|
+
will do ("Next: start the 30s timer"). Its buttons and keys drive the deck. It is
|
|
169
|
+
written into a blank window, so it works from `file://` and needs no second file;
|
|
170
|
+
the browser must allow pop-ups for the page.
|
|
171
|
+
|
|
172
|
+
## Options
|
|
173
|
+
|
|
174
|
+
| Option | Default | |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| `scenes` | `{}` | Scene factories by slide id |
|
|
177
|
+
| `width`, `height` | `1920`, `1080` | Stage size in px |
|
|
178
|
+
| `slotMinutes` | none | The talk's length, for the presenter's countdown |
|
|
179
|
+
| `title` | page title | Names the presenter window |
|
|
180
|
+
| `labels` | English | Every visible word; see `DEFAULT_DECK_LABELS` |
|
|
181
|
+
| `hash` | `true` | Keep the place in the URL (`#5.2`) and start from it |
|
|
182
|
+
| `keyboard` | `true` | Listen for keys on the window |
|
|
183
|
+
| `fit` | `true` | Scale the stage to its container, or to the window when that is `<body>` |
|
|
184
|
+
| `autoStart` | `true` | Run the frame loop. With `false`, call `deck.render(now)` |
|
|
185
|
+
| `onChange` | none | Called after every change of slide, step or countdown |
|
|
186
|
+
|
|
187
|
+
## The deck object
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
const deck = tinyfly.createDeck('#deck', options)
|
|
191
|
+
deck.next() // as the clicker does
|
|
192
|
+
deck.prev()
|
|
193
|
+
deck.goTo(5) // slide 5 (the first is 1), playing its entrance
|
|
194
|
+
deck.goTo(5, 2) // playing into its second click
|
|
195
|
+
deck.seek(5, 2) // exactly as click 2 ends
|
|
196
|
+
deck.seek(5, 2, 3400) // at scene time 3400 ms
|
|
197
|
+
deck.replay()
|
|
198
|
+
deck.toggleTimer()
|
|
199
|
+
deck.blank('black')
|
|
200
|
+
deck.openPresenter()
|
|
201
|
+
deck.state // the DeckState
|
|
202
|
+
deck.destroy()
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`seek` is for rehearsal and for checking a moment: set it, take a screenshot, and
|
|
206
|
+
see that every speech bubble and label sits inside its box.
|
|
207
|
+
|
|
208
|
+
## DeckState: the deck without a page
|
|
209
|
+
|
|
210
|
+
`DeckState` holds the slides, steps, scene clocks and countdowns, and reads no
|
|
211
|
+
clock itself. Every call that depends on time takes `now`, so the same calls give
|
|
212
|
+
the same state. Use it to test a deck's flow, or to drive a deck on something
|
|
213
|
+
other than a web page.
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
import { DeckState } from '@algorisys/tinyfly/present'
|
|
217
|
+
|
|
218
|
+
const state = new DeckState([
|
|
219
|
+
{ id: 'hello', marks: [1000] },
|
|
220
|
+
{ id: 'poll', marks: [500, 2000], timers: [{ step: 1, seconds: 30 }] },
|
|
221
|
+
])
|
|
222
|
+
state.next(0) // 'slide'
|
|
223
|
+
state.advance(16, 16) // move the scene clock on by 16 ms
|
|
224
|
+
state.next(600) // 'snap' while the entrance plays, then 'step', 'timer-start', …
|
|
225
|
+
state.hint() // { kind: 'timer-start', seconds: 30 }
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## One file for the venue
|
|
229
|
+
|
|
230
|
+
```sh
|
|
231
|
+
npx @algorisys/tinyfly present player/index.html -o Talk.html
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
This writes one HTML file with every script and stylesheet inlined and every
|
|
235
|
+
image, font and media file as a data URI. It opens from `file://` with no network,
|
|
236
|
+
so venue Wi-Fi cannot break the talk.
|
|
237
|
+
|
|
238
|
+
The command exits 1 and writes nothing when the page would still need something:
|
|
239
|
+
|
|
240
|
+
- a local file that is missing;
|
|
241
|
+
- a script, stylesheet, image or font loaded from the network (`--allow-remote`
|
|
242
|
+
keeps these and only warns);
|
|
243
|
+
- something it cannot inline: `srcset`, `@import`, a module script that imports
|
|
244
|
+
other files (bundle it first), or a file type it does not know.
|
|
245
|
+
|
|
246
|
+
Links (`<a href>`) are left alone. Load tinyfly from a copy beside the deck
|
|
247
|
+
(`vendor/tinyfly.iife.js`), not from a CDN, so the build is the version you
|
|
248
|
+
rehearsed with.
|
|
249
|
+
|
|
250
|
+
`inlineDeck(html, { readText, readBase64 })` is the same step as a function. It
|
|
251
|
+
reads no files itself, so it runs in any build script.
|
|
252
|
+
|
|
253
|
+
## Before the day
|
|
254
|
+
|
|
255
|
+
- Walk the built file with the keyboard: every step in order, back, a jump to a
|
|
256
|
+
slide number, and the presenter window.
|
|
257
|
+
- Check each slide with `deck.seek()` at the size of the room's screen.
|
|
258
|
+
- Keep a copy of the talk in another format in case the laptop is not yours.
|
package/docs/props.md
CHANGED
|
@@ -246,6 +246,8 @@ scenery and where the props stand) and `buildScene` builds it into targets:
|
|
|
246
246
|
of the afternoon against the city: houses, a car, a tree), `office` (a room
|
|
247
247
|
with a desk, a chair and a door) and `home` (a room at night with a bed, a
|
|
248
248
|
chair and a door). The Park Day card plays a day over the park.
|
|
249
|
+
`buildScene(name, { width, height, ink: '#111', lineWidth: 5 })` outlines
|
|
250
|
+
every prop in that ink and width, so the set matches heavily inked characters.
|
|
249
251
|
|
|
250
252
|
## In 3D scenes
|
|
251
253
|
|
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.
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.129.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
|