pixi-effects 0.10.0 → 0.11.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +6 -6
  3. package/ai/SKILL.md +3 -3
  4. package/ai/reference/cheatsheet.md +5 -2
  5. package/ai/reference/pitfalls.md +2 -2
  6. package/ai/reference/recipes.md +19 -10
  7. package/ai/template.html +11 -8
  8. package/ai/tools/render.mjs +14 -5
  9. package/dist/Composition-7TEKHZNQ.cjs +14 -0
  10. package/dist/{Composition-EKVTUYCI.cjs.map → Composition-7TEKHZNQ.cjs.map} +1 -1
  11. package/dist/Composition-HIISJAX2.js +5 -0
  12. package/dist/{Composition-NJCOMGD7.js.map → Composition-HIISJAX2.js.map} +1 -1
  13. package/dist/Controller.d.cts +1 -1
  14. package/dist/Controller.d.ts +1 -1
  15. package/dist/{Movie-w3GliuP3.d.cts → Movie-DSSNOF3T.d.cts} +60 -1
  16. package/dist/{Movie-puD9oZPg.d.ts → Movie-nzmWsxWX.d.ts} +60 -1
  17. package/dist/{chunk-WDGAVOMS.js → chunk-3IPDNC3E.js} +8 -5
  18. package/dist/chunk-3IPDNC3E.js.map +1 -0
  19. package/dist/{chunk-S3ZI4MKS.cjs → chunk-6NWJLVCA.cjs} +3 -3
  20. package/dist/{chunk-S3ZI4MKS.cjs.map → chunk-6NWJLVCA.cjs.map} +1 -1
  21. package/dist/{chunk-JAMNDBXW.js → chunk-C6QHKYC5.js} +3 -3
  22. package/dist/{chunk-JAMNDBXW.js.map → chunk-C6QHKYC5.js.map} +1 -1
  23. package/dist/{chunk-4WJUSDJJ.cjs → chunk-F7NCHS6Q.cjs} +31 -28
  24. package/dist/chunk-F7NCHS6Q.cjs.map +1 -0
  25. package/dist/index.cjs +259 -42
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +74 -2
  28. package/dist/index.d.ts +74 -2
  29. package/dist/index.js +237 -24
  30. package/dist/index.js.map +1 -1
  31. package/dist/loader.css +110 -0
  32. package/dist/three.cjs +5 -5
  33. package/dist/three.js +1 -1
  34. package/docs/api.md +15 -1
  35. package/docs/dsl.md +29 -0
  36. package/llms-full.txt +73 -18
  37. package/package.json +5 -2
  38. package/dist/Composition-EKVTUYCI.cjs +0 -14
  39. package/dist/Composition-NJCOMGD7.js +0 -5
  40. package/dist/chunk-4WJUSDJJ.cjs.map +0 -1
  41. package/dist/chunk-WDGAVOMS.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ **Performance**
6
+
7
+ - **A piece with many layers builds in a fraction of the time.** Every layer now builds its animation in a small timeline of its own, which is added to its parent once finished. Adding thousands of tweens one by one to a single GSAP timeline made GSAP re-measure the whole timeline at every add, so the cost grew with the square of the count: the 700-layer `hanabi-night` took 3.2 s to build with two 1.3–1.6 s freezes of the page, and now takes 0.5 s with none above 170 ms. Positions stay absolute, so every frame is the same.
8
+ - **A shared loader.** `pixi-effects/loader.css` (shipped as `dist/loader.css`) and one line of HTML, `<div class="pe-loader" data-label="LOADING"></div>` next to the canvas: a ring, `--pulse` (a breathing dot) or `--bar` (a sweeping line), or `--custom` for a drawing of your own, restyled with `--pe-loader-color` / `-bg` / `-track` / `-size`. It is HTML and CSS, so it is on screen before any script runs, and it animates only `transform` and `opacity`, which the browser runs off the main thread, so it keeps moving while the page builds the piece. `movie.init()` finds it, fades it out when the movie is ready and, if init fails, stops it and says so (`init({ loader })` names another element or turns it off). Every gallery piece has one (`hanabi-night` has a rocket of its own on the shared frame), `ai/template.html` has one, and the guide's player page says how to use it.
9
+
10
+ **Changed**
11
+
12
+ - The gallery pieces `orbit-rig` and `shape-shift` were redesigned as pieces first and feature showcases second: an orrery plate in ivory and brass ("Orrery") and a Bauhaus poster in motion ("Form Follows"). Same ids, so existing links keep working.
13
+
14
+ **Added**
15
+
16
+ - A gallery piece that uses particles and motion blur (`hanabi-night`: a fireworks festival title card, 36 pieces now), with its demo in the guide.
17
+ - **Motion blur.** `movie.init({ motionBlur: true })` (or a sample count, or `{ samples, shutter }`, or the same option on one `render()`, `snapshot()` or `contactSheet()`) exposes every frame over a shutter interval: the frame is drawn several times at moments around its time and averaged, so fast motion smears like on film. It applies to what is made (the export, snapshots, contact sheets, so `pixi-effects-check` shows what the file will have), not to live playback. `pixi-effects-render --motion-blur 8 --shutter 0.5` sets it for one file.
18
+ - **`particles()`**: bursts, fountains, snow, confetti and sparks as plain layers. Every particle has its own seeded start, launch angle and speed, size, colour and life, and a path baked into keyframes (gravity, wind, drag, sway), so playback, seeking and export agree. `emit` spreads births over time, `fade` / `scale` shape the life, `shape` is `circle` / `rect` / `star` or any `template` layer, `blendMode: 'add'` makes overlaps glow.
19
+
20
+ **Fixed**
21
+
22
+ - **The last frame of an export was empty.** The final frame sits at the exact end of the movie, where every layer's lifespan has just closed, so a layer that lasts to the end vanished in it (the exported video, and the last cell of a contact sheet, ended on a blank frame). That frame is now drawn a hair before the end, so the final composition stays on screen.
23
+
3
24
  ## 0.10.0
4
25
 
5
26
  **Added**
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # pixi-effects
2
2
 
3
- > **Status**: experimental — current release `0.10.0`. The API may still change between minor versions (see [CHANGELOG](./CHANGELOG.md): `0.10.0` adds seeded randomness, `wiggle` and `stagger`, null layers with `parent`, `animateText`, `followPath` and path morphing, and click-to-play in the player, `0.9.0` adds a poster time (`movie.init({ poster })`) and a guide site, `0.8.0` adds events and a theme for building your own player, `0.7.0` adds filters by name, the `pixi-effects-render` and `pixi-effects-view` commands and the timeline chart, `0.6.0` adds draw-on strokes (`trimEnd`) and text that changes over time, `0.5.0` adds synthesised sound effects (`sfx`, no files) and the `check` tool, `0.4.0` makes a mask share its layer's lifetime, `0.3.0` made keyframe `at` relative to the layer).
3
+ > **Status**: experimental — current release `0.11.0`. The API may still change between minor versions (see [CHANGELOG](./CHANGELOG.md): `0.11.0` adds particles, motion blur, a shared loader and a much faster build for pieces with many layers, `0.10.0` adds seeded randomness, `wiggle` and `stagger`, null layers with `parent`, `animateText`, `followPath` and path morphing, and click-to-play in the player, `0.9.0` adds a poster time (`movie.init({ poster })`) and a guide site, `0.8.0` adds events and a theme for building your own player, `0.7.0` adds filters by name, the `pixi-effects-render` and `pixi-effects-view` commands and the timeline chart, `0.6.0` adds draw-on strokes (`trimEnd`) and text that changes over time, `0.5.0` adds synthesised sound effects (`sfx`, no files) and the `check` tool, `0.4.0` makes a mask share its layer's lifetime, `0.3.0` made keyframe `at` relative to the layer).
4
4
 
5
- **[Guide →](https://yjmtmtk.github.io/pixi-effects/guide/)** · **[Gallery →](https://yjmtmtk.github.io/pixi-effects/examples/gallery/)** · 35 portfolio pieces written as plain data by AI models · **[Live demos →](https://yjmtmtk.github.io/pixi-effects/)** · 12 numbered examples + an in-browser playground.
5
+ **[Guide →](https://yjmtmtk.github.io/pixi-effects/guide/)** · **[Gallery →](https://yjmtmtk.github.io/pixi-effects/examples/gallery/)** · 36 portfolio pieces written as plain data by AI models · **[Live demos →](https://yjmtmtk.github.io/pixi-effects/)** · 12 numbered examples + an in-browser playground.
6
6
 
7
7
  Declarative composition and video rendering for the web. After Effects-style timelines on top of [PixiJS v8](https://pixijs.com/) and [GSAP](https://gsap.com/), with strict TypeScript types. Render to MP4 / WebM / MOV via [mediabunny](https://mediabunny.dev/).
8
8
 
@@ -40,8 +40,8 @@ Drop the imports into an [importmap](https://developer.mozilla.org/docs/Web/HTML
40
40
  "gsap": "https://esm.sh/gsap@3.12.5",
41
41
  "gsap/PixiPlugin": "https://esm.sh/gsap@3.12.5/PixiPlugin",
42
42
  "mediabunny": "https://esm.sh/mediabunny",
43
- "pixi-effects": "https://cdn.jsdelivr.net/npm/pixi-effects@0.10.0/dist/index.js",
44
- "pixi-effects/controller": "https://cdn.jsdelivr.net/npm/pixi-effects@0.10.0/dist/Controller.js"
43
+ "pixi-effects": "https://cdn.jsdelivr.net/npm/pixi-effects@0.11.0/dist/index.js",
44
+ "pixi-effects/controller": "https://cdn.jsdelivr.net/npm/pixi-effects@0.11.0/dist/Controller.js"
45
45
  }
46
46
  }
47
47
  </script>
@@ -52,7 +52,7 @@ Drop the imports into an [importmap](https://developer.mozilla.org/docs/Web/HTML
52
52
  </script>
53
53
  ```
54
54
 
55
- Load the `dist/` files **as they are** (jsDelivr's `/npm/…/dist/…`, or unpkg's `https://unpkg.com/pixi-effects@0.10.0/dist/index.js`) rather than a CDN-rebundled build such as `esm.sh/pixi-effects` or jsDelivr's `+esm`: the entries (`pixi-effects`, `…/controller`, `…/three`) share internal chunks, which only works when each file is served untouched.
55
+ Load the `dist/` files **as they are** (jsDelivr's `/npm/…/dist/…`, or unpkg's `https://unpkg.com/pixi-effects@0.11.0/dist/index.js`) rather than a CDN-rebundled build such as `esm.sh/pixi-effects` or jsDelivr's `+esm`: the entries (`pixi-effects`, `…/controller`, `…/three`) share internal chunks, which only works when each file is served untouched.
56
56
 
57
57
  > **Using three.js?** Add two more entries (`three` and `pixi-effects/three`) to this importmap — see [Adding three.js](#adding-threejs-optional) below.
58
58
  >
@@ -68,7 +68,7 @@ Add two more entries to the importmap above: three.js itself, and the `pixi-effe
68
68
  "imports": {
69
69
  "...": "(everything from the importmap above)",
70
70
  "three": "https://esm.sh/three@0.178.0",
71
- "pixi-effects/three": "https://cdn.jsdelivr.net/npm/pixi-effects@0.10.0/dist/three.js"
71
+ "pixi-effects/three": "https://cdn.jsdelivr.net/npm/pixi-effects@0.11.0/dist/three.js"
72
72
  }
73
73
  }
74
74
  </script>
package/ai/SKILL.md CHANGED
@@ -9,7 +9,7 @@ You describe a video as a tree of plain objects; the library plays it in a canva
9
9
 
10
10
  ## Workflow
11
11
 
12
- 1. **Start from `template.html`** (copy it; it loads the library from a CDN, collects every console warning into `window.__logs`, and exposes `window.movie`). One HTML file, plain JS. Default canvas 1280×720 @ 30 fps.
12
+ 1. **Start from `template.html`** (copy it; it also has the shared loader (`<div class="pe-loader" data-label="LOADING">` + `pixi-effects/loader.css`: HTML and CSS only, animating just `transform` / `opacity`, so it keeps moving while the page builds the video; `movie.init()` fades it out). Keep it; a loader of your own is fine (`pe-loader--custom`) as long as it only animates `transform` / `opacity`, never with JavaScript or `requestAnimationFrame`; it loads the library from a CDN, collects every console warning into `window.__logs`, and exposes `window.movie`). One HTML file, plain JS. Default canvas 1280×720 @ 30 fps.
13
13
  2. **Give the movie a poster time.** In `movie.init` add `poster: <seconds>`: the most striking moment (a title fully on screen, not the first frame, which is often black). The canvas shows that picture before play (the playhead stays at 0 and play starts from 0), and the check writes it as `poster.jpg`.
14
14
  3. **Write the composition as data.** Anything repeated (letters, bars, particles, scenes) is a JS function or loop that returns specs — never copy-paste objects. Derive coordinates and times from constants/data, not magic numbers.
15
15
  4. **Show the human:** `node ai/tools/view.mjs my-video.html` opens their browser on the page with a scrubbable, zoomable timeline under it (click / drag to seek, + / − or Ctrl/⌘ + wheel to zoom) (`npx pixi-effects-view …` in an installed package); it keeps running until Ctrl-C. **Deliver the file:** `node ai/tools/render.mjs my-video.html -o my-video.mp4` (`npx pixi-effects-render …` in an installed package) renders the page headless to mp4 / webm / mov / mkv and exits 0 only when the file is written; run it AFTER the check below passes. **Run the check — one command does steps 3, 4 and the export:** `node ai/tools/check.mjs my-video.html` (Node ≥ 22 and Chrome installed; no npm install; in an installed package it is `npx pixi-effects-check my-video.html`). It starts its own private Chrome (nothing is shared with other sessions), waits for `window.__ready`, and writes `timeline.html` (every layer as a bar on a time axis: ◆ keyframes, shaded transitions; hand it to the human to open) and prints: console warnings, `movie.inspect` over the WHOLE timeline (grouped), `movie.inspectAudio()`, then exports an mp4 and decodes it again (video size and length, audio length, loudness per second, silence). It writes `check-out/<name>/sheet.png` — **open that picture and look at it** — plus the mp4 and `report.json`. Exit 0 = nothing to fix; exit 1 = a list of problems; fix them and run it again. Text that overlaps text is listed under `review` (not a failure: ghost layers, glow copies and per-letter boxes are often intentional; look at the sheet; `--strict` makes them fail). The manual steps below are for looking at one frame closely.
@@ -20,7 +20,7 @@ You describe a video as a tree of plain objects; the library plays it in a canva
20
20
  - `await movie.snapshot(frame, { as: 'dataURL' })` → one frame, canvas only (no player bar).
21
21
  - `movie.inspectAudio()` → **hear with numbers**: for every sound its `start`, `sound.length`, `sound.peakDb`, `sound.loudestAt` (line this up with the picture) and `sound.brightnessHz` (< 500 dark, > 8000 airy), plus `issues` (limited mix, inaudible or cut-off sounds). Check it whenever the movie has audio; `render()` encodes this same mix.
22
22
  From a browser tool the result is a `data:` URL string: `agent-browser eval "movie.contactSheet({ count: 6, as: 'dataURL' })" | python3 ai/tools/save-image.py /absolute/sheet.png`, then open the PNG. Sheet tiles are small (~480 px): use `snapshot` for detail. `inspect` output is long on busy scenes: pass `{ layers: 'none' }` and read `issues` first. Give layers a `name` so inspect paths are readable. A moving ticker is not flagged as cut off.
23
- 6. **Iterate** on what you saw (clipped text, collisions, wrong timing). Then export: `const blob = await movie.render({ format: 'mp4' })` (about real time; `movie.on('progress', …)` reports 0–100).
23
+ 6. **Iterate** on what you saw (clipped text, collisions, wrong timing). Fast motion looks choppy: add `motionBlur: true` to `movie.init` (render, snapshot and contact sheet then show a film-style blur; renders take ~8× longer). Then export: `const blob = await movie.render({ format: 'mp4' })` (about real time; `movie.on('progress', …)` reports 0–100).
24
24
 
25
25
  ## The rules that cause most failures
26
26
 
@@ -32,7 +32,7 @@ You describe a video as a tree of plain objects; the library plays it in a canva
32
32
  - **Masks live in the parent's coordinates and don't follow the masked layer.** **`filterArea` is in the layer's own coordinates.**
33
33
  - **2.5D needs `threeD: true`** on each layer plus a `{ type: 'camera' }` layer; camera props go in `initial`/keyframes; keep every `z` below the camera distance (≈ 989 at 720p, fov 40); under a dolly zoom only `z = 0` stays fixed.
34
34
  - **Group / parent layers = `{ type: 'null', name: 'rig' }`** (draws nothing, only moves) + `parent: 'rig'` on the layers that should follow it: their `x`/`y` are then measured from the null's origin, and the null's position / rotation / scale / alpha carry them (orbits, clock hands, grouped fades). Nulls chain. Only `null` layers can be parents; not for `threeD` layers.
35
- - **Built in:** `animateText()` (per-letter / per-word / per-line entrances and exits in one call: `...animateText('Title', style, { x, y, align: 'center', at: 0.5, duration: 5, in: 'rise', out: 'fade', stagger: { each: 0.05 } })`), `splitText()` / `measureText()` (per-letter / per-word layers, exact positions, by hand), `shape: 'arc'` (progress rings, pie / donut slices: animate `endAngle`), `fillGradient` (linear/radial, alpha stops → vignettes), `{value}` counters, `repeat`/`yoyo`, `orbit()`, seeded randomness (`rand(seed)` / `noise(x, seed)` in expressions, `random(seed)` in JS, never `Math.random()`) `wiggle()` (a seeded shake as keyframes) `followPath()` (a layer along an SVG path: `keyframes: followPath({ d, duration, orient: true })`), path morphing (`{ shape: 'path', d, morphTo, initial/keyframes: morph 0 → 1 }`) and `stagger()` (delays for a wave of layers: `stagger(letters, { each: 0.05, from: 'center' })`, or `stagger(n, …)` for numbers; GSAP-style `each` / `amount` / `from` / `grid` / `ease`). **Not in the DSL (hand-roll, recipes exist or loops are easy):** stroke draw-on (trim path), text that changes over time (other than `{value}`), other per-frame curves, particle emitters.
35
+ - **Built in:** `animateText()` (per-letter / per-word / per-line entrances and exits in one call: `...animateText('Title', style, { x, y, align: 'center', at: 0.5, duration: 5, in: 'rise', out: 'fade', stagger: { each: 0.05 } })`), `splitText()` / `measureText()` (per-letter / per-word layers, exact positions, by hand), `shape: 'arc'` (progress rings, pie / donut slices: animate `endAngle`), `fillGradient` (linear/radial, alpha stops → vignettes), `{value}` counters, `repeat`/`yoyo`, `orbit()`, seeded randomness (`rand(seed)` / `noise(x, seed)` in expressions, `random(seed)` in JS, never `Math.random()`) `wiggle()` (a seeded shake as keyframes) `particles()` (bursts, snow, confetti, sparks as seeded layers: `...particles({ count: 90, at: 2, life: [1, 1.8], area: { x: 640, y: 330 }, speed: [120, 420], gravity: 240, fade: { out: 0.6 } })`), `followPath()` (a layer along an SVG path: `keyframes: followPath({ d, duration, orient: true })`), path morphing (`{ shape: 'path', d, morphTo, initial/keyframes: morph 0 → 1 }`) and `stagger()` (delays for a wave of layers: `stagger(letters, { each: 0.05, from: 'center' })`, or `stagger(n, …)` for numbers; GSAP-style `each` / `amount` / `from` / `grid` / `ease`). **Not in the DSL (hand-roll with a JS loop):** other per-frame curves (waves, spirals: sample them into short linear keyframes), shared masks. (Draw-on strokes `trimEnd`, text that changes over time `set: { text }` / `visibleChars`, shake `wiggle()` and particles are built in.)
36
36
  - **Blend modes:** `blendMode: 'add' | 'screen' | 'multiply'` on any layer (glows, light leaks).
37
37
  - **One `Movie` per page.** A sound effect needs no `duration` (it lasts as long as its clip). Seeking is safe: counters, colours and growing shapes are right after any jump.
38
38
 
@@ -110,7 +110,7 @@ transitions: [{ kind: 'crossfade' | 'wipe' | 'iris' | 'slide' | 'dip' | 'zoom' |
110
110
  ## Presets
111
111
 
112
112
  ```js
113
- import { kenBurns, withFade, wiggle, stagger, followPath, random } from 'pixi-effects';
113
+ import { kenBurns, withFade, wiggle, stagger, followPath, particles, random } from 'pixi-effects';
114
114
  kenBurns({ asset, name, at, duration, motion: 'still'|'scale'|'rotation'|'position',
115
115
  fit: 'cover'|'contain', ease, /* scale */ origin, zoom, direction, /* rotation */ angle, /* position */ from, to })
116
116
  withFade(spec, { in: 0.5, out: 0.5 }) // alpha fade; `out` needs spec.duration
@@ -120,6 +120,9 @@ keyframes: [...wiggle({ duration: 6, freq: 4, seed: 3, props: { x: { around: 'GW
120
120
  stagger(8, { each: 0.08 /* or amount: total s */, from: 'start'|'end'|'center'|'edges'|'random'|index, grid: [cols, rows], ease, seed }) // → delays [0, 0.08, …]: `at: 1 + d[i]`
121
121
  stagger(layers, { each: 0.05, from: 'center' }) // → the same layers with `at` pushed back (originals untouched)
122
122
  keyframes: followPath({ d: 'M 120 560 C 360 120 920 120 1160 560', duration: 4, ease, orient: true /* faces the way it goes; rotate: -90 for an up-pointing image */, from: 0, to: 1, frameRate: 30 /* = the movie's */ }) // x / y (and rotation) along an SVG path; give the layer its own `at`
123
+ ...particles({ count: 90, at: 2, emit: 0 /* 0 = burst; or seconds to spread births */, life: [1, 1.8], area: { x: 640, y: 330 /*, width, height */ }, angle: [0, 360] /* 0 right, 90 down, −90 up */,
124
+ speed: [120, 420], gravity: 240, wind: 0, drag: 1.2, sway: { amp: 30, freq: 0.6 }, size: [2, 4.5], scale: [1, 0], fade: { in: 0.2, out: 0.6 },
125
+ colors: ['#ffd166', '#ff6b9d'], shape: 'circle'|'rect'|'star', spin: [-200, 200], blendMode: 'add', seed: 1, name: 'burst', template: { type: 'image', asset } }) // seeded layers, paths baked into keyframes
123
126
  const r = random(7); r(); r(); // a repeatable stream in 0…1 for JS loops (never Math.random())
124
127
  ```
125
128
  `kenBurns` covers the canvas, so source images should be at least canvas-sized (1920×1080 for 1280×720).
@@ -143,7 +146,7 @@ const movie = new Movie();
143
146
  await movie.init({ canvas, width, height, duration, frameRate, background, assets, composition });
144
147
  movie.play(); movie.pause();
145
148
  await movie.gotoFrame(n, true); // seek (frames; 30 fps => t = n/30)
146
- const blob = await movie.render({ format: 'mp4' }); // 'mp4' | 'webm' | 'mov' | 'mkv'; ~real-time
149
+ const blob = await movie.render({ format: 'mp4' }); // 'mp4' | 'webm' | 'mov' | 'mkv'; ~real-time. Fast motion: `movie.init({ motionBlur: true })` (8 samples, 180° shutter; or a number / { samples: 2–64, shutter: 0–1 }) blurs render / snapshot / contactSheet, not live playback; a render takes `samples`× as long
147
150
  movie.on('progress', e => e.progress /* 0–100 */);
148
151
  movie.audioBuffer // mixed audio (after init), if any audio layers
149
152
  await movie.contactSheet({ count: 6, as: 'dataURL' }) // ONE image of several labelled frames — look at it. Options: frames | times | count, columns, cellWidth, as
@@ -33,7 +33,7 @@ A good habit that catches most of these: after `init`, read `window.__logs` (see
33
33
  18. **Counters**: `text: '{value}'` + animate `value` (with `format`). Other text content cannot change over time. Earlier sessions generated one text layer per number (40+ per bar). *(fixed)*
34
34
  19. **Loops**: `repeat` (finite) / `yoyo` / `repeatDelay` on any keyframe; infinite repeats are rejected with a warning. *(fixed)*
35
35
  20. **No per-frame expression time.** Expressions are evaluated once at build. A camera orbit is `orbit()`; a shake or drift is `wiggle()`, travel along a path is `followPath()`, and any other curve (waves, spirals) must be sampled into short linear keyframes (~0.1 s) in a JS loop. **Randomness must be seeded** (`rand(seed)` / `noise(x, seed)` in expressions, `random(seed)` in JS): `Math.random()` makes playback and the exported file disagree. *(partly fixed)*
36
- 21. **Per-letter / per-word text is `animateText()` (one call: a layer per piece, a wave in and out) or `splitText()` by hand (one layer per piece, positions measured for you); a group / parent is a `{ type: 'null' }` layer + `parent: 'name'`, no particle emitter, no caption-linked-to-slide.** One layer per letter; many layers; seeded random loops (`random(seed)`). *(hand-roll)*
36
+ 21. **Per-letter / per-word text is `animateText()` (one call: a layer per piece, a wave in and out) or `splitText()` by hand (one layer per piece, positions measured for you); a group / parent is a `{ type: 'null' }` layer + `parent: 'name'`, no caption-linked-to-slide.** One layer per letter; many layers; seeded random loops (`random(seed)`). *(hand-roll)*
37
37
  22. **Colour tweens look muddy in RGB** (red→green passes through brown). Use `colorSpace: 'oklab'` or `'oklch'` on the layer. In `oklch`, a nearly grey end (chroma < ~0.08, e.g. `#9a9ab4`) borrows the other end's hue, so grey → yellow no longer flashes through pink. *(docs / fixed)*
38
38
  23. **Generated images**: `canvas.toDataURL()` as an asset `src` works. Make them ≥ canvas size or `kenBurns` zooms look soft. *(docs)*
39
39
 
@@ -69,7 +69,7 @@ A good habit that catches most of these: after `init`, read `window.__logs` (see
69
69
  43. **Layers built in a loop need their z-order planned**: anything pushed to the array after the loop is drawn over what the loop made (rings crossed over a header). Keyframes on different properties of one layer may overlap in time. Keep a subject in the upper ~60 % of a source image if a caption will sit under it (`inspect` does not look at picture content). *(docs)*
70
70
  44. **Zero-pad a counter with `format: { pad: 2 }`** (`18:42:{value}` shows `18:42:05`). A `{value}` placeholder that nothing sets or animates prints 0 and now warns: `{value}` is reserved, there is no way to print it literally. *(fixed)*
71
71
  45. **The same mistake in a loop warns once**: the warning "keyframe starts after the layer ends" is summarised after three layers. The usual cause is an off-by-one (`f <= frames` instead of `f < frames`) that puts the last sample exactly at the layer's end. *(fixed)*
72
- 46. **Still not in the DSL (hand-roll; round-two notes have workarounds):** stroke draw-on / trim path on a line, polygon or path (use a growing rect mask for a one-direction reveal; a circular progress ring is `shape: 'arc'`), text content that changes over time (only `{value}`), per-frame jitter (film grain = seeded `set` keyframes on an oversized image), particle emitters, shared masks, `zIndex`.
72
+ 46. **Still not in the DSL (hand-roll):** shared masks (one mask for several layers), `zIndex` (stack order is list order). *(Earlier round-two notes listed draw-on strokes, changing text, jitter and particle emitters here: they are built in now: `trimEnd`, `set: { text }` / `visibleChars`, `wiggle()`, `particles()`.)*
73
73
  46b. **Blend modes exist now** (`blendMode: 'add' | 'screen' | 'multiply'` on any layer, threeD layers and compositions included; a composition's children inherit it). Additive white cores no longer read grey on a coloured background. It also works on a layer with `filters` (a blurred glow with `add` / `multiply`): the mode is applied by the last filter, because a container's blend inside a filter pass multiplied against nothing and rendered black. With `add`, use dim saturated colours: overlaps sum, and near-white sums to pure white. *(fixed)*
74
74
  47. **Browser tooling: prefer `node ai/tools/check.mjs page.html`** — it runs its own private Chrome, so none of the following can bite. If you drive a browser by hand instead: the `agent-browser` daemon is shared, so a `contactSheet` can come back from another session: after saving an image, look at it and confirm it is YOUR piece. In zsh a variable holding `agent-browser --session x` is not split into words (use a small wrapper script). `inspect` now clips overlaps to the visible area, ignores the two scenes of a running transition, treats text inside a moving (panned) composition as moving, and does not report text scaled to 0 as "no size"; it still does not compare text with picture content or shapes.
75
75
  48. **A composition's `alpha` is applied to each child separately, not to the flattened group** (measured: two overlapping opaque circles in a composition at `alpha: 0.5` show the lower one through the upper one in the overlap). Fading a group that has overlapping children therefore shows the overlap; fade the children themselves, or keep overlapping parts out of the group. Expressions have no way to read a sibling's size: measure text with `canvas.measureText` (the font string Pixi uses) and compute pill widths in JS. *(docs)*
@@ -522,19 +522,28 @@ return [{
522
522
 
523
523
  ---
524
524
 
525
- ## Particles (seeded, so every run and export is identical)
525
+ ## Particles (`particles()`: seeded, so every run and export is identical)
526
+
527
+ `particles()` returns one layer per particle: seeded start, launch angle and speed, size, colour and life, with gravity / wind / drag / sway baked into the keyframes. `count` and `life` are required, and so is the emitter `area` (its centre; add `width` / `height` to spread over a box). `emit: 0` is a burst, `emit: 3` spreads the births over 3 s. `angle`: 0 right, 90 down, −90 up. `blendMode: 'add'` makes overlaps glow. It throws (with the fix) if it would bake too many keyframes: lower `count`, `life` or `sampleRate`.
526
528
 
527
529
  ```js
528
530
  // @recipe particles
529
- const rnd = random(7); // seeded: the same stream every run (never Math.random())
530
- return Array.from({ length: 40 }, () => {
531
- const x = rnd() * 1280, y = 100 + rnd() * 620;
532
- return {
533
- type: 'shape', shape: 'circle', radius: 2 + rnd() * 4, duration: 6,
534
- initial: { x, y, fillColor: '#ffffff', fillAlpha: 0.3 + rnd() * 0.5 },
535
- keyframes: [{ at: 0, to: { y: y - 80 }, duration: 6, ease: 'none' }],
536
- };
537
- });
531
+ const colors = ['#ffd166', '#ff6b9d', '#4cc9f0', '#ffffff'];
532
+ const burst = (at, x, y, seed) => particles({ count: 240, at, life: [1.2, 2], area: { x, y }, speed: [40, 520], gravity: 220, drag: 1.1,
533
+ size: [4, 8], scale: [1, 0.3], colors, fade: { out: 0.7 }, blendMode: 'add', seed, name: 'burst' + seed }); // bursts of sparks
534
+ return [
535
+ { type: 'shape', shape: 'rect', width: 'GW', height: 'GH', initial: { x: 'GW/2', y: 'GH/2', fillColor: '#0a0f1f' } },
536
+ ...burst(0.5, 400, 260, 1), ...burst(1.6, 880, 200, 2), ...burst(2.8, 640, 330, 3),
537
+ ];
538
+ ```
539
+
540
+ ```js
541
+ // @recipe particles-snow
542
+ return { duration: 10, sequences: [
543
+ { type: 'shape', shape: 'rect', width: 'GW', height: 'GH', initial: { x: 'GW/2', y: 'GH/2', fillColor: '#16203d' } },
544
+ ...particles({ count: 120, emit: 4, life: [4, 6], area: { x: 640, y: -20, width: 1400 }, angle: 90, speed: [40, 90],
545
+ size: [2, 5], sway: { amp: 30, freq: 0.6 }, fade: { in: 0.5, out: 0.5 }, name: 'snow', seed: 4 }), // drifting down, swaying
546
+ ] };
538
547
  ```
539
548
 
540
549
  ---
package/ai/template.html CHANGED
@@ -4,18 +4,21 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>pixi-effects video</title>
7
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pixi-effects@0.11.0/dist/loader.css" /> <!-- the loader: HTML + CSS only, so it is on screen at once and keeps moving while the page builds the video -->
7
8
  <style>
8
9
  body { background: #0d1220; margin: 0; padding: 16px; }
9
- canvas { width: min(960px, 100%); border-radius: 8px; }
10
- /* the player wraps the canvas: size the wrapper, so the bar is as wide as the picture */
11
- .movie-controller-wrap { width: min(960px, 100%); }
12
- .movie-controller-wrap canvas { width: 100%; height: auto; }
10
+ .stage { position: relative; width: min(960px, 100%); } /* the player and the loader both sit inside this box */
11
+ .stage canvas { display: block; width: 100%; height: auto; border-radius: 8px; }
12
+ /* the loader (pixi-effects/loader.css, linked above): movie.init() fades it out when the movie is ready */
13
13
  /* Screenshots: the player bar overlays the bottom ~60px of the canvas (it is NOT part of the exported video).
14
14
  Uncomment to hide it while you check the layout: .movie-controller { display: none !important; } */
15
15
  </style>
16
16
  </head>
17
17
  <body>
18
- <canvas id="stage" width="1280" height="720"></canvas>
18
+ <div class="stage">
19
+ <canvas id="stage" width="1280" height="720"></canvas>
20
+ <div class="pe-loader" data-label="LOADING"></div> <!-- shared loader: .pe-loader--pulse / --bar for other looks, --custom for your own -->
21
+ </div>
19
22
 
20
23
  <script>
21
24
  // Harness: every console warning/error is collected. pixi-effects warnings are INSTRUCTIONS — read them.
@@ -36,9 +39,9 @@
36
39
  "gsap": "https://esm.sh/gsap@3.12.5",
37
40
  "gsap/PixiPlugin": "https://esm.sh/gsap@3.12.5/PixiPlugin",
38
41
  "mediabunny": "https://esm.sh/mediabunny",
39
- "pixi-effects": "https://cdn.jsdelivr.net/npm/pixi-effects@0.10.0/dist/index.js",
40
- "pixi-effects/controller": "https://cdn.jsdelivr.net/npm/pixi-effects@0.10.0/dist/Controller.js",
41
- "pixi-effects/three": "https://cdn.jsdelivr.net/npm/pixi-effects@0.10.0/dist/three.js",
42
+ "pixi-effects": "https://cdn.jsdelivr.net/npm/pixi-effects@0.11.0/dist/index.js",
43
+ "pixi-effects/controller": "https://cdn.jsdelivr.net/npm/pixi-effects@0.11.0/dist/Controller.js",
44
+ "pixi-effects/three": "https://cdn.jsdelivr.net/npm/pixi-effects@0.11.0/dist/three.js",
42
45
  "pixi-filters": "https://esm.sh/pixi-filters@6.1.5?external=pixi.js",
43
46
  "three": "https://esm.sh/three@0.178.0"
44
47
  }
@@ -13,6 +13,8 @@
13
13
  *
14
14
  * Options: -o, --out FILE (default ./<page name>.<format>; the container follows the extension: mp4 webm mov mkv) ·
15
15
  * --format mp4|webm|mov|mkv · --quality very-low|low|medium|high|very-high (video and audio bitrate, default high) ·
16
+ * --motion-blur SAMPLES (2-64: each frame is drawn that many times over the shutter and averaged; overrides the page's own motionBlur) ·
17
+ * --shutter FRACTION (with --motion-blur: how long the shutter is open, 0-1 of a frame, default 0.5) ·
16
18
  * --video-codec C · --audio-codec C · --query "a=1&b=2" (added to the page URL) · --fail-on-warn (exit 1 when the page
17
19
  * logged a warning; the file is still written) · --quiet (no progress line) · --timeout SECONDS (default 900) ·
18
20
  * --root DIR (static server root; default: the nearest folder above the page with dist/) · --chrome PATH
@@ -39,7 +41,7 @@ export function defaultOutput(page, format) {
39
41
  }
40
42
 
41
43
  export function parseRenderArgs(argv) {
42
- const o = { page: null, out: null, format: null, quality: 'high', videoCodec: null, audioCodec: null, query: null, failOnWarn: false, quiet: false, timeout: 900, root: null, chrome: null };
44
+ const o = { page: null, out: null, format: null, quality: 'high', videoCodec: null, audioCodec: null, motionBlur: null, shutter: null, query: null, failOnWarn: false, quiet: false, timeout: 900, root: null, chrome: null };
43
45
  const need = (i, name) => { if (i + 1 >= argv.length) throw new Error(`${name} needs a value`); return argv[i + 1]; };
44
46
  for (let i = 0; i < argv.length; i++) {
45
47
  const a = argv[i];
@@ -52,7 +54,13 @@ export function parseRenderArgs(argv) {
52
54
  if (!QUALITIES.includes(o.quality)) throw new Error(`--quality must be very-low, low, medium, high or very-high (got "${o.quality}")`);
53
55
  } else if (a === '--video-codec') o.videoCodec = need(i++, a);
54
56
  else if (a === '--audio-codec') o.audioCodec = need(i++, a);
55
- else if (a === '--query') o.query = need(i++, a).replace(/^\?/, '');
57
+ else if (a === '--motion-blur') {
58
+ o.motionBlur = Number(need(i++, a));
59
+ if (!(Number.isInteger(o.motionBlur) && o.motionBlur >= 2 && o.motionBlur <= 64)) throw new Error(`--motion-blur must be a whole number of samples from 2 to 64 (got "${argv[i]}")`);
60
+ } else if (a === '--shutter') {
61
+ o.shutter = Number(need(i++, a));
62
+ if (!(o.shutter > 0 && o.shutter <= 1)) throw new Error(`--shutter must be above 0 and at most 1 (0.5 is a 180° shutter), got "${argv[i]}"`);
63
+ } else if (a === '--query') o.query = need(i++, a).replace(/^\?/, '');
56
64
  else if (a === '--fail-on-warn') o.failOnWarn = true;
57
65
  else if (a === '--quiet') o.quiet = true;
58
66
  else if (a === '--timeout') o.timeout = Math.max(10, Number(need(i++, a)) || 900);
@@ -62,6 +70,7 @@ export function parseRenderArgs(argv) {
62
70
  else if (!o.page) o.page = a;
63
71
  else throw new Error(`unexpected argument ${a}`);
64
72
  }
73
+ if (o.shutter !== null && o.motionBlur === null) throw new Error('--shutter goes with --motion-blur SAMPLES');
65
74
  o.format ??= (o.out ? formatFromPath(o.out) : null) ?? 'mp4';
66
75
  return o;
67
76
  }
@@ -70,14 +79,14 @@ const UPLOAD = '/__pixi_effects_out';
70
79
  const kb = n => (n >= 1048576 ? `${(n / 1048576).toFixed(2)} MB` : `${Math.max(1, Math.round(n / 1024))} KB`);
71
80
 
72
81
  /** The page's side: render, and PUT the Blob to our server (so a long video never goes through base64). */
73
- const renderScript = (format, quality, videoCodec, audioCodec) => `(() => {
82
+ const renderScript = (format, quality, videoCodec, audioCodec, motionBlur, shutter) => `(() => {
74
83
  window.__r = { state: 'running', progress: 0 };
75
84
  movie.on('progress', e => { window.__r.progress = e.progress; });
76
85
  (async () => {
77
86
  try {
78
87
  const video = { bitrate: ${JSON.stringify(quality)}${videoCodec ? `, codec: ${JSON.stringify(videoCodec)}` : ''} };
79
88
  const audio = { bitrate: ${JSON.stringify(quality)}${audioCodec ? `, codec: ${JSON.stringify(audioCodec)}` : ''} };
80
- const blob = await movie.render({ format: ${JSON.stringify(format)}, video, audio });
89
+ const blob = await movie.render({ format: ${JSON.stringify(format)}, video, audio${motionBlur ? `, motionBlur: { samples: ${motionBlur}${shutter ? `, shutter: ${shutter}` : ''} }` : ''} });
81
90
  const res = await fetch(${JSON.stringify(UPLOAD)}, { method: 'PUT', body: blob });
82
91
  if (!res.ok) throw new Error('could not hand the file to the command (' + res.status + ')');
83
92
  window.__r = { state: 'done', bytes: blob.size, type: blob.type };
@@ -143,7 +152,7 @@ export async function runRender(opts, log = console.log, progress = () => {}) {
143
152
  }
144
153
  Object.assign(result, { duration: info.duration, frames: info.totalFrames, width: info.width, height: info.height, frameRate: info.frameRate });
145
154
 
146
- await cdp.eval(renderScript(opts.format, opts.quality, opts.videoCodec, opts.audioCodec));
155
+ await cdp.eval(renderScript(opts.format, opts.quality, opts.videoCodec, opts.audioCodec, opts.motionBlur, opts.shutter));
147
156
  let state;
148
157
  for (;;) {
149
158
  left();
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var chunkF7NCHS6Q_cjs = require('./chunk-F7NCHS6Q.cjs');
4
+ require('./chunk-6NWJLVCA.cjs');
5
+ require('./chunk-UQBGW5DO.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "CompositionSequence", {
10
+ enumerable: true,
11
+ get: function () { return chunkF7NCHS6Q_cjs.CompositionSequence; }
12
+ });
13
+ //# sourceMappingURL=Composition-7TEKHZNQ.cjs.map
14
+ //# sourceMappingURL=Composition-7TEKHZNQ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"Composition-EKVTUYCI.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"Composition-7TEKHZNQ.cjs"}
@@ -0,0 +1,5 @@
1
+ export { CompositionSequence } from './chunk-3IPDNC3E.js';
2
+ import './chunk-C6QHKYC5.js';
3
+ import './chunk-DKGG7WD4.js';
4
+ //# sourceMappingURL=Composition-HIISJAX2.js.map
5
+ //# sourceMappingURL=Composition-HIISJAX2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"Composition-NJCOMGD7.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"Composition-HIISJAX2.js"}
@@ -1,4 +1,4 @@
1
- import { M as Movie } from './Movie-w3GliuP3.cjs';
1
+ import { f as Movie } from './Movie-DSSNOF3T.cjs';
2
2
  import 'pixi.js';
3
3
  import 'gsap';
4
4
  import './types-BXu28nJj.cjs';
@@ -1,4 +1,4 @@
1
- import { M as Movie } from './Movie-puD9oZPg.js';
1
+ import { f as Movie } from './Movie-nzmWsxWX.js';
2
2
  import 'pixi.js';
3
3
  import 'gsap';
4
4
  import './types-BXu28nJj.js';
@@ -131,6 +131,31 @@ interface TimelineSvgOptions {
131
131
  labels?: boolean;
132
132
  }
133
133
 
134
+ /**
135
+ * The page's loader (see `src/loader.css`): a `.pe-loader` element that is on screen before any script runs. `movie.init()` finds it,
136
+ * fades it out when the movie is ready and, if init fails, stops it and says so.
137
+ */
138
+ type LoaderOption = HTMLElement | string | false;
139
+ /** The loader element for a canvas: the one named (element or selector), none (`false`), or a `.pe-loader` near the canvas (its box or a few levels up). */
140
+ declare function resolveLoader(option: LoaderOption | undefined, canvas: HTMLCanvasElement | null): HTMLElement | null;
141
+ /** Fade the loader out (a class, so the CSS transition runs) and take it away. Safe to call twice, or with null. */
142
+ declare function dismissLoader(loader: HTMLElement | null): void;
143
+ /** init failed: stop the animation and say so, and leave the box on screen so the page does not look merely stuck. */
144
+ declare function failLoader(loader: HTMLElement | null, message: string): void;
145
+
146
+ interface MotionBlurOptions {
147
+ /** How many moments one frame is drawn at before they are averaged (2–64). More is smoother and slower. Default 8. */
148
+ samples?: number;
149
+ /** How long the shutter is open, as a fraction of the frame time (0–1]. `0.5` is a 180° shutter (the film look). Default 0.5. */
150
+ shutter?: number;
151
+ }
152
+ /** `true` (8 samples, 180° shutter), a sample count, or `{ samples, shutter }`; `false` is off. */
153
+ type MotionBlurSpec = boolean | number | MotionBlurOptions;
154
+ interface ResolvedMotionBlur {
155
+ samples: number;
156
+ shutter: number;
157
+ }
158
+
134
159
  interface MovieOptions {
135
160
  width?: number;
136
161
  height?: number;
@@ -146,8 +171,22 @@ interface MovieOptions {
146
171
  * value counts back from the end. Default: none (the first frame).
147
172
  */
148
173
  poster?: number;
174
+ /**
175
+ * Motion blur for everything that is *made* (not for live playback): `render()`, `snapshot()` and `contactSheet()` expose each frame
176
+ * over a shutter interval and average `samples` renders of it, so fast motion smears like on film. `true` is 8 samples at a 180° shutter,
177
+ * a number is the sample count, `{ samples, shutter }` sets both. Default: off. Each of those calls can override it (`false` turns it off).
178
+ */
179
+ motionBlur?: MotionBlurSpec;
180
+ /**
181
+ * The page's loader (see `pixi-effects/loader.css`): an element, a selector, or `false` for none. By default a `.pe-loader` next to
182
+ * the canvas is used. It is faded out once the movie is ready (the poster is on the canvas) and, if `init()` fails, it stops and says so.
183
+ */
184
+ loader?: LoaderOption;
149
185
  }
186
+
150
187
  interface RenderOptions {
188
+ /** Motion blur for this export (see `MovieOptions.motionBlur`); overrides the movie's own setting, `false` turns it off. */
189
+ motionBlur?: MotionBlurSpec;
151
190
  format?: 'mp4' | 'mov' | 'webm' | 'mkv';
152
191
  video?: {
153
192
  codec?: string;
@@ -159,6 +198,8 @@ interface RenderOptions {
159
198
  };
160
199
  }
161
200
  interface SnapshotOptions {
201
+ /** Motion blur for this picture (see `MovieOptions.motionBlur`); overrides the movie's own setting, `false` turns it off. */
202
+ motionBlur?: MotionBlurSpec;
162
203
  /** Output size relative to the canvas (default 1). */
163
204
  scale?: number;
164
205
  /** `'image/png'` (default) or `'image/jpeg'`. */
@@ -167,6 +208,8 @@ interface SnapshotOptions {
167
208
  as?: 'blob' | 'dataURL';
168
209
  }
169
210
  interface ContactSheetOptions {
211
+ /** Motion blur for these pictures (see `MovieOptions.motionBlur`); overrides the movie's own setting, `false` turns it off. */
212
+ motionBlur?: MotionBlurSpec;
170
213
  /** Frames to show. Default: `count` frames spread evenly over the movie. */
171
214
  frames?: number[];
172
215
  /** Times in seconds to show (used when `frames` is not given). */
@@ -211,6 +254,8 @@ declare class Movie {
211
254
  private _cancelAudioStart;
212
255
  /** The poster time in seconds (`movie.init({ poster })`), or null. */
213
256
  poster: number | null;
257
+ /** The motion blur `render()`, `snapshot()` and `contactSheet()` apply unless told otherwise (`movie.init({ motionBlur })`), or null. */
258
+ motionBlur: ResolvedMotionBlur | null;
214
259
  private _posterFrame;
215
260
  /** The canvas shows the poster picture while the playhead is still at frame 0 (like `<video poster>`): the first seek or play replaces it. */
216
261
  private _atPoster;
@@ -268,6 +313,12 @@ declare class Movie {
268
313
  private _quietly;
269
314
  private _emitError;
270
315
  private _goto;
316
+ /**
317
+ * The moment frame `frame` shows. The very last frame (`totalFrames`) is at the end of the movie, where every layer's lifespan
318
+ * has just closed: it is drawn a hair before, so a layer that lasts to the end is still on screen in the final frame
319
+ * (it used to be an empty one, the last frame of every export).
320
+ */
321
+ private _timeOf;
271
322
  private _awaitVideoFrames;
272
323
  /**
273
324
  * A picture of one frame (the canvas only: the player bar is not included). Seeks there first and
@@ -319,6 +370,14 @@ declare class Movie {
319
370
  private _requireReady;
320
371
  /** Projects every `threeD` layer for the current frame (see src/space). */
321
372
  private _updateSpace;
373
+ /** The motion blur an operation uses: its own option when given (`false` is off), otherwise the movie's. */
374
+ private _blurFor;
375
+ /**
376
+ * @internal Draw `frame` with motion blur into `target` (a canvas the size of the stage): the average of `mb.samples` renders at moments
377
+ * spread over the shutter interval around the frame time. With `settle` the playhead and the stage are left exactly on the frame.
378
+ */
379
+ _exposeFrame(frame: number, mb: ResolvedMotionBlur, target: HTMLCanvasElement, settle: boolean): Promise<void>;
380
+ private _blurCanvas;
322
381
  play(): void;
323
382
  pause(): void;
324
383
  set volume(v: number);
@@ -330,4 +389,4 @@ declare class Movie {
330
389
  destroy(): Promise<void>;
331
390
  }
332
391
 
333
- export { type AudioInspectOptions as A, type ContactSheetOptions as C, type FrameEvent as F, type InspectOptions as I, type LayerInfo as L, Movie as M, type ProgressEvent as P, type RenderOptions as R, type SnapshotOptions as S, type TimelineData as T, type VolumeEvent as V, type AudioReport as a, type AudioSourceReport as b, type InspectReport as c, type MovieErrorEvent as d, type MovieOptions as e, type SoundMeasure as f, type TimelineHtmlOptions as g, type TimelineRow as h, type TimelineSvgOptions as i, type TimelineTransition as j };
392
+ export { type AudioInspectOptions as A, type ContactSheetOptions as C, type FrameEvent as F, type InspectOptions as I, type LayerInfo as L, type MotionBlurOptions as M, type ProgressEvent as P, type RenderOptions as R, type SnapshotOptions as S, type TimelineData as T, type VolumeEvent as V, type AudioReport as a, type AudioSourceReport as b, type InspectReport as c, type LoaderOption as d, type MotionBlurSpec as e, Movie as f, type MovieErrorEvent as g, type MovieOptions as h, type SoundMeasure as i, type TimelineHtmlOptions as j, type TimelineRow as k, type TimelineSvgOptions as l, type TimelineTransition as m, dismissLoader as n, failLoader as o, resolveLoader as r };
@@ -131,6 +131,31 @@ interface TimelineSvgOptions {
131
131
  labels?: boolean;
132
132
  }
133
133
 
134
+ /**
135
+ * The page's loader (see `src/loader.css`): a `.pe-loader` element that is on screen before any script runs. `movie.init()` finds it,
136
+ * fades it out when the movie is ready and, if init fails, stops it and says so.
137
+ */
138
+ type LoaderOption = HTMLElement | string | false;
139
+ /** The loader element for a canvas: the one named (element or selector), none (`false`), or a `.pe-loader` near the canvas (its box or a few levels up). */
140
+ declare function resolveLoader(option: LoaderOption | undefined, canvas: HTMLCanvasElement | null): HTMLElement | null;
141
+ /** Fade the loader out (a class, so the CSS transition runs) and take it away. Safe to call twice, or with null. */
142
+ declare function dismissLoader(loader: HTMLElement | null): void;
143
+ /** init failed: stop the animation and say so, and leave the box on screen so the page does not look merely stuck. */
144
+ declare function failLoader(loader: HTMLElement | null, message: string): void;
145
+
146
+ interface MotionBlurOptions {
147
+ /** How many moments one frame is drawn at before they are averaged (2–64). More is smoother and slower. Default 8. */
148
+ samples?: number;
149
+ /** How long the shutter is open, as a fraction of the frame time (0–1]. `0.5` is a 180° shutter (the film look). Default 0.5. */
150
+ shutter?: number;
151
+ }
152
+ /** `true` (8 samples, 180° shutter), a sample count, or `{ samples, shutter }`; `false` is off. */
153
+ type MotionBlurSpec = boolean | number | MotionBlurOptions;
154
+ interface ResolvedMotionBlur {
155
+ samples: number;
156
+ shutter: number;
157
+ }
158
+
134
159
  interface MovieOptions {
135
160
  width?: number;
136
161
  height?: number;
@@ -146,8 +171,22 @@ interface MovieOptions {
146
171
  * value counts back from the end. Default: none (the first frame).
147
172
  */
148
173
  poster?: number;
174
+ /**
175
+ * Motion blur for everything that is *made* (not for live playback): `render()`, `snapshot()` and `contactSheet()` expose each frame
176
+ * over a shutter interval and average `samples` renders of it, so fast motion smears like on film. `true` is 8 samples at a 180° shutter,
177
+ * a number is the sample count, `{ samples, shutter }` sets both. Default: off. Each of those calls can override it (`false` turns it off).
178
+ */
179
+ motionBlur?: MotionBlurSpec;
180
+ /**
181
+ * The page's loader (see `pixi-effects/loader.css`): an element, a selector, or `false` for none. By default a `.pe-loader` next to
182
+ * the canvas is used. It is faded out once the movie is ready (the poster is on the canvas) and, if `init()` fails, it stops and says so.
183
+ */
184
+ loader?: LoaderOption;
149
185
  }
186
+
150
187
  interface RenderOptions {
188
+ /** Motion blur for this export (see `MovieOptions.motionBlur`); overrides the movie's own setting, `false` turns it off. */
189
+ motionBlur?: MotionBlurSpec;
151
190
  format?: 'mp4' | 'mov' | 'webm' | 'mkv';
152
191
  video?: {
153
192
  codec?: string;
@@ -159,6 +198,8 @@ interface RenderOptions {
159
198
  };
160
199
  }
161
200
  interface SnapshotOptions {
201
+ /** Motion blur for this picture (see `MovieOptions.motionBlur`); overrides the movie's own setting, `false` turns it off. */
202
+ motionBlur?: MotionBlurSpec;
162
203
  /** Output size relative to the canvas (default 1). */
163
204
  scale?: number;
164
205
  /** `'image/png'` (default) or `'image/jpeg'`. */
@@ -167,6 +208,8 @@ interface SnapshotOptions {
167
208
  as?: 'blob' | 'dataURL';
168
209
  }
169
210
  interface ContactSheetOptions {
211
+ /** Motion blur for these pictures (see `MovieOptions.motionBlur`); overrides the movie's own setting, `false` turns it off. */
212
+ motionBlur?: MotionBlurSpec;
170
213
  /** Frames to show. Default: `count` frames spread evenly over the movie. */
171
214
  frames?: number[];
172
215
  /** Times in seconds to show (used when `frames` is not given). */
@@ -211,6 +254,8 @@ declare class Movie {
211
254
  private _cancelAudioStart;
212
255
  /** The poster time in seconds (`movie.init({ poster })`), or null. */
213
256
  poster: number | null;
257
+ /** The motion blur `render()`, `snapshot()` and `contactSheet()` apply unless told otherwise (`movie.init({ motionBlur })`), or null. */
258
+ motionBlur: ResolvedMotionBlur | null;
214
259
  private _posterFrame;
215
260
  /** The canvas shows the poster picture while the playhead is still at frame 0 (like `<video poster>`): the first seek or play replaces it. */
216
261
  private _atPoster;
@@ -268,6 +313,12 @@ declare class Movie {
268
313
  private _quietly;
269
314
  private _emitError;
270
315
  private _goto;
316
+ /**
317
+ * The moment frame `frame` shows. The very last frame (`totalFrames`) is at the end of the movie, where every layer's lifespan
318
+ * has just closed: it is drawn a hair before, so a layer that lasts to the end is still on screen in the final frame
319
+ * (it used to be an empty one, the last frame of every export).
320
+ */
321
+ private _timeOf;
271
322
  private _awaitVideoFrames;
272
323
  /**
273
324
  * A picture of one frame (the canvas only: the player bar is not included). Seeks there first and
@@ -319,6 +370,14 @@ declare class Movie {
319
370
  private _requireReady;
320
371
  /** Projects every `threeD` layer for the current frame (see src/space). */
321
372
  private _updateSpace;
373
+ /** The motion blur an operation uses: its own option when given (`false` is off), otherwise the movie's. */
374
+ private _blurFor;
375
+ /**
376
+ * @internal Draw `frame` with motion blur into `target` (a canvas the size of the stage): the average of `mb.samples` renders at moments
377
+ * spread over the shutter interval around the frame time. With `settle` the playhead and the stage are left exactly on the frame.
378
+ */
379
+ _exposeFrame(frame: number, mb: ResolvedMotionBlur, target: HTMLCanvasElement, settle: boolean): Promise<void>;
380
+ private _blurCanvas;
322
381
  play(): void;
323
382
  pause(): void;
324
383
  set volume(v: number);
@@ -330,4 +389,4 @@ declare class Movie {
330
389
  destroy(): Promise<void>;
331
390
  }
332
391
 
333
- export { type AudioInspectOptions as A, type ContactSheetOptions as C, type FrameEvent as F, type InspectOptions as I, type LayerInfo as L, Movie as M, type ProgressEvent as P, type RenderOptions as R, type SnapshotOptions as S, type TimelineData as T, type VolumeEvent as V, type AudioReport as a, type AudioSourceReport as b, type InspectReport as c, type MovieErrorEvent as d, type MovieOptions as e, type SoundMeasure as f, type TimelineHtmlOptions as g, type TimelineRow as h, type TimelineSvgOptions as i, type TimelineTransition as j };
392
+ export { type AudioInspectOptions as A, type ContactSheetOptions as C, type FrameEvent as F, type InspectOptions as I, type LayerInfo as L, type MotionBlurOptions as M, type ProgressEvent as P, type RenderOptions as R, type SnapshotOptions as S, type TimelineData as T, type VolumeEvent as V, type AudioReport as a, type AudioSourceReport as b, type InspectReport as c, type LoaderOption as d, type MotionBlurSpec as e, Movie as f, type MovieErrorEvent as g, type MovieOptions as h, type SoundMeasure as i, type TimelineHtmlOptions as j, type TimelineRow as k, type TimelineSvgOptions as l, type TimelineTransition as m, dismissLoader as n, failLoader as o, resolveLoader as r };