A toolbox of film styles made in code for Claude Code: 66 ready to use, and your own. Each style is a style prompt plus a demo film made entirely in code by Claude Opus 5.5, with no video model. By Lemomo. · 一套用代码做片的风格工具箱:66 种现成风格,也能做出你自己的
JavaScript agent-skillsai-agentsai-short-filmai-videoanimationcanvasclaudeclaude-codeclaude-code-pluginclaude-code-skillcreative-codingffmpegfilmmakingmotion-graphicsopus-5-5prompt-librarytext-to-speechthreejsvideo-productionwebgl
Silkscreen Travel Poster: a new demo, "The Long Way Home", one full-frame poster per city
lemomo-ai2870991e008d
diff --git a/styles/silkscreen-poster/DEMO.md b/styles/silkscreen-poster/DEMO.mdindex 9af3e25..2ab9f31 100644--- a/styles/silkscreen-poster/DEMO.md+++ b/styles/silkscreen-poster/DEMO.md@@ -2,101 +2,96 @@One example among many. Don't reuse its story, arc, shots, props or timings.-Demo: *Three Trails* (38.4 s) · `silkscreen-poster.mp4` · source in [`demo/`](demo/)-+Demo: *The Long Way Home 绕远路回家* (50 s) · `silkscreen-poster.mp4` · subtitles `silkscreen-poster.srt` · source in [`demo/`](demo/)## Story & structure-A trail guide for a fictional park: three trail posters are printed, one faster than the last, the third is climbed in one long take, and all three end up on a visitor-center wall. No narration.+A traveller wants to get "as far from home as the world allows". Every city is one full-bleed screen print with its landmark as the hero, and a ticket stub on the right counts the distance from home: Beijing 0, Istanbul 7,060, Paris 8,220, Buenos Aires 19,270 km. No point on Earth is more than about 20,015 km from Beijing, so Buenos Aires is almost the far side of the world. The turn: on a round world, past that point every road leads home. The ending: the same Temple of Heaven print is pulled again in dusk inks, its loose layers snap into register, and the stub reads FROM HOME 0 KM · TRAVELLED 39,630 KM, almost once around the Earth. Narrated in English (Kokoro `bf_emma`), Chinese and English subtitles.-This is the first use case of STYLE.md §11 (trail / attraction guide). Shot structure: title banner pull → poster 1 printed layer by layer → poster 2 printed on eighth notes → last poster climbed in one take → pull back to the wall. Information order: park title → scene → trail name → difficulty → distance → time → climb → footer. Holds: title 3.2 s; name ≥ chars/12+1 s; stat row ≥ 2.2–3.0 s after its last item; 30–40 s for 3 trails.+- **Hook (0–10 s)**: the first pull prints a lone vermilion sun on bare paper; the dawn sky, the woods, the blue roofs and the cypresses arrive one ink per beat while the camera steps back; the stub lands DAY 1 · 0 KM on "Day one. Beijing. Zero kilometres."+- **Rise (10–21.9 s)**: Istanbul, Paris, Buenos Aires. The number grows; the layers get looser city by city.+- **Turn (21.9–27.8 s)**: the camera pushes into "19,270 KM" on the stub until the mesh weave shows; the music leaves part by part, then a second of wind only; the first sound after it is the clamp.+- **Return (27.8–36.7 s)**: a night sea in one long truck while FROM HOME counts down and TRAVELLED counts up; a sweep prints Beijing at dusk, its layers still floating.+- **Landing (36.7–50 s)**: the snap (the loudest downbeat), a night re-ink where the hall turns gold, the end card printed as a wider ticket.-The other use cases in STYLE.md §11 use the same engine: a scene is just a list of planes, the band template takes any 1–4 facts, and `swap` re-inks a whole poster in another palette.+The signature moves, each pushed further than the time before:-**How the native moves serve information** (not story):-- *One ink, one beat*: each pull is one musical hit, so the eye is led through the layers in order and the facts are printed last, which is exactly when they are read.-- *Split fountain*: several inks in one pull. It opens the film, because one stroke fills the frame with colour.-- *Palette re-ink*: the whole poster pulled again in the next time-of-day palette. In the demo this is the data point "7 h": the day passes while the camera climbs.-- *Registration slip → snap*: during the climb the layers hang loose (white gaps, paper-thickness shadows), then clamp into register with one hit. This is the only time the film pauses before the most important facts.-- *Paper as a colour*: the waterfall is simply unprinted paper, the brightest thing on the sheet.-- *The trail as a printed layer*: the route is a dashed line in the sun ink, stamped segment by segment as the camera follows it.+| | Beijing | Istanbul / Paris | Buenos Aires | Beijing again |+|---|---|---|---|---|+| **Layout** | full-bleed print, city name in the sky, ticket stub printed last | same stub template, bigger number | the stub's number fills the screen until the weave shows | the stub gains TRAVELLED; the end card is a wider ticket |+| **Colour** | accent first, one ink per pull, bare paper as marble | a diagonal sweep prints the next city behind the blade | La Boca's houses in one split-fountain pull | the same geometry re-inked for dusk, then night |+| **Registration** | normal 2 px | Paris: layers loosen along a crane up the tower | layers drift tens of units, paper gaps show | one snap to zero, the only perfect register in the film |## Shots-| Move | Use | Demo |-|---|---|---|-| Truck with the squeegee, slight roll (−1.7°), frame edge and handle ends in view | hook: the squeegee holds its place in frame while the bands stream past | 0–1.0 s |-| Fast pull-back (ease-out 0.65 s) | reveal the whole print as the screen lifts | 1.0–1.65 s |-| Tilt across the print table | from one sheet to the next | 4.8 s |-| Locked top-down full shot | watching layers stack | 5.4–7.8 s |-| Push + tilt to the info band | reading | 7.8–9.0 s |-| Truck through a foreground tree (screen-space silhouette in the previous poster's `near` ink, covers the frame for about 1 frame) | poster-to-poster transition | 13.2 s, 19.2 s |-| Pull-back from a detail to the whole sheet | "the white is the waterfall" | 14.4 s |-| **Crane up the trail, multi-plane parallax** (signature) | the hardest trail, one take | 19.2–23.4 s |-| Tilt down from summit to band | the climb ends in the data | 24.0 s |-| Log-zoom pull-back to the wall | final lockup, hold ≥ 3 s | 29.4–30.6 s |+24 fps, 108 BPM waltz (beat 0.556 s, bar 1.667 s, 30 bars). The camera never leaves the print: z ≥ 1, the view clamped inside the art.-Unified transition grammar: layers change by squeegee; posters change through foreground trees; the film ends with a squeegee pulling the end-card ink. No dissolves and no bare cuts.+| # | Time (s) | Move | Picture | Why |+|---|---|---|---|---|+| 1 | 0–3.33 | close-up inside the print, stepping back one level per pull (log zoom) | sun alone, then gold sky with paper rings, then stepped rose bands | the hook: colour arrives in the first second |+| 2 | 3.33–5.56 | to the full frame; the screen lifts at 4.44 (the frame's bottom bar sweeps up through the picture) | woods, three blue roofs, marble terraces (paper), cypresses; red drums and gold finial last | a picture built from layers |+| 3 | 5.56–10 | slow push toward the stub | BEIJING 北京 in the sky; DAY 1 · FROM HOME 0 KM · TEMPLE OF HEAVEN BUILT 1420 | the words and the narration land together |+| 4 | 10–14.17 | a cypress silhouette crosses the screen (full cover for about one frame), then Istanbul prints on sixteenth notes | Hagia Sophia across the water, a ferry; 7,060 KM · BUILT 537 | faster by subdividing the beat, same tempo |+| 5 | 14.17–17.78 | diagonal sweep prints Paris behind the blade; crane up the tower on a 1920×1620 print | Eiffel Tower, mansard roofs; layers loosen with parallax; 8,220 KM · BUILT 1889 | a city change is a colour change |+| 6 | 17.78–21.94 | split-fountain sweep (six inks in one bead); lateral truck over a 2600-wide print | La Boca houses, the Obelisco as bare paper; 19,270 KM · BUILT 1936 | the far side, everything loose |+| 7 | 21.94–27.78 | screen-space push into the stub's number (×5.9); the screen comes down, mesh visible | music thins out; 26.86–27.78 wind only | the turn needs silence |+| 8 | 27.78–33.33 | clamp jolt; night inks swept on while still close; pull out; long truck over a 5200-wide night sea | moon, stars as bare paper; counters running | the way home in one breath |+| 9 | 33.33–36.67 | sweep to the Temple of Heaven at dusk; layers float with paper gaps | counters land: 0 KM · 39,630 KM | back where it began |+| 10 | 36.67–42.22 | snap to register on the downbeat; slow push | "Beijing again. Zero kilometres." | the only perfect register |+| 11 | 42.22–50 | night re-ink sweep; the end card prints at 46.2 (panel) and 46.6 (type) | gold hall, moon; THE LONG WAY HOME 绕远路回家 | the ending echoes the opening |-Demo motion numbers: info band items 0.18 s each on eighth notes; accent inks `sub: 1` (half a beat late); screen lift 0.4 s; palette swap blade at −12° over 0.35 s; climb parallax `(camTopY − camY) × (depth − 1) × 0.42`, each spur slides sideways (Gaussian bump, 190 u × depth); paper gaps 3 u and thickness shadows 9 u at 28 %, scaled by "looseness", zero on the registration snap. Hook truck roll −1.7°.+Transitions are made in the medium: a squeegee pull, the screen lifting and coming down, a foreground silhouette, a diagonal sweep that prints the next poster, the clamp. No fades, no bare cuts.## Score structure-- **Music**: American outdoor folk, 100 BPM, D major, open-D guitar strums (physical model), slide guitar (numpy), VCSL harmonica, cajon kick, brushes, upright bass. **Each pull is one strum**, and the chords climb D – D/F# – G – A as the layers come nearer. Poster 2 doubles to eighth notes (acceleration). The climb builds instrument by instrument. The registration snap is the loudest downbeat in the film.-- **Foley by material**: squeegee on mesh (band-passed noise with a 220–280 Hz amplitude grain from the mesh; faster pull = brighter), wet ink "squelch" (falling sine plus sticky noise), aluminium screen clack plus hinge creak, paper stamps for stats, 16th-note ticks for trail dashes, a paper hiss for sliding layers, and a wood-and-metal registration clamp.-- **Ambience**: studio room tone; the lake inside poster 1 fades in when the screen lifts (the print "wakes up"); waterfall (J-cut 0.9 s early); mountain wind (J-cut into the silence, L-cut out onto the wall); visitor-center murmur, a door, footsteps.-- **Silences**: 18.0–19.2 s (music off; the waterfall tail fades to about −59 dBFS; the first sound after it is a long slide up) and 23.4–24.0 s (wind only; the first sound after it is the clamp plus the full band).-- Music ducks 2.5 dB under foley. Master: −14 LUFS.+- Original waltz in F major, 3/4, 108 BPM: nylon guitar (bass note plus two chord beats), jazz double bass, brushes and shaker; the glockenspiel answers only the accent ink (the sun, the gold finials, the key number).+- A colour per city: darbuka in Istanbul, an accordion musette tune in Paris, the bass leaning on the "and" of two in Buenos Aires.+- Bars 13–15: parts leave one at a time; from 25.0 s nothing, 26.86–27.78 wind only. The clamp brings bass, guitar and cajón back on beat 3 of bar 16.+- Bars 17–21: the guitar in eighth notes (acceleration by subdivision), harmonica enters. Bar 22 (36.67 s): the snap, the loudest downbeat (cajón, suspended cymbal, glockenspiel). Bars 22–29: the harmonica tune; the last F chord rings out.+- Foley by material: squeegee over mesh (band-passed noise with a 230–280 Hz grain), wet ink, screen clack and hinge, paper stamps for the stub, ticks while the counters run, a wood-and-metal clamp. Each city wakes up inside its print (park birds, the strait with gulls and a ferry horn, a Paris street with a bicycle bell, harbour wind, the night sea, evening crickets), J-cut in and handed over to the next.+- Voice compressed and set about 10 dB (RMS) above the music; the music dips 300 Hz–4 kHz and ducks under speech. Master −14 LUFS, true peak ≤ −1 dB.## Palette & props-- **Palette discipline**: one palette per poster, 6 inks: `sky1` (light sky), `sky2` (deep sky / bands), `far`, `mid`, `near` (darkest, also the info band), `sun` (the one bright accent: sun, trail, difficulty, climb). An optional `glow` is the lit face of mountains. A given poster should use ≤ 6 of these. The demo palettes are:- - dawn `#F6CD98 #EE9A73 #9A7FA8 #3E7079 #1E3B3F #FBE6B4`- - noon `#E4EEDC #86BCD0 #C2AE92 #4C8753 #1D4331 #F2C14A`- - golden `#F7D787 #E9A94F #A57C68 #5E7A45 #2B3A28 #FFF1C4`- - dusk `#F4B461 #D8613F #7C3E5F #43325A #1B1B2F #FBE3A6`- - Paper `#F2E8D2`. Title banner `#F7C66B #E4683F #2F6F73 #1C2A33`.-- **Contrast is automatic**: text inks are picked by WCAG contrast against the ink underneath (`pickInk`). A night palette will not make the header vanish.-- **Shapes**: mountains are midpoint-displaced ridges with a jagged lit facet; pines are one outline of drooping tiers plus a short trunk; water is a flat body with horizontal glint bars; forests are rows of pines on a solid base. Everything is drawn with hard edges.-- **Poster template** (units 1000×1500): paper border 26 u; art area to y = 1140; the scene is shifted up 50 u, so a little sky is cropped to make room for the info band. The band (y 1148–1474, `near` ink) holds the trail name (Big Shoulders Display 900, up to 122 u, auto-fit), the number `01`–`04` in `sun`, a 6 u `sun` rule, and a row of stats: labels 34–38 u (Outfit 600, letter-spaced), values 48–68 u (Big Shoulders 800). Columns are sized by content. On a wall at 0.49 scale, labels are about 18 px and values about 31 px.-- **Header**: park name tracked out at 62 u, printed in the sky.-- **Texture budget**: paper tile at 0.6 u per texel, mottle multiply at 55 %, pinholes at 75 %, then ffmpeg grain 3. More than this starts to read as risograph.+One palette per print, ≤ 6 inks plus a lit-face ink; paper `#F3EAD8`. The ticket stub is always the print's `near` ink; its text inks are picked by contrast (`pickInk`).++| Print | sky1 | sky2 | far | mid | near | accent | lit face |+|---|---|---|---|---|---|---|---|+| Beijing dawn | `#F5C978` | `#E8866A` | `#9A88AE` | `#22447C` | `#1B1F34` | `#D8432B` | `#5D86C4` |+| Istanbul | `#F6DFB2` | `#E9A27A` | `#8DB9BE` | `#C9705A` | `#1F2D3A` | `#F2C14E` | `#6E8BA3` |+| Paris | `#F4E6CC` | `#A9C1DE` | `#C3B3D2` | `#5B6E9C` | `#252B42` | `#E4553F` | `#EDC77E` |+| Buenos Aires | `#F8E7B0` | `#82C7D8` | `#B9A9C6` | `#3B5B7A` | `#232B3A` | `#E2543D` | `#F7E2A6` |+| Night sea | `#2C3B69` | `#1C2650` | `#46598A` | `#203A63` | `#111A2F` | `#F2D28A` | `#3F6395` |+| Beijing dusk | `#F2A766` | `#A25A84` | `#6E5C8E` | `#26386E` | `#151A2C` | `#E4502F` | `#5578B4` |+| Beijing night | `#2A3762` | `#18204A` | `#3A4778` | `#1F2D5C` | `#0F1426` | `#F2BE4E` | `#3D5A97` |++La Boca's split-fountain bead: `#D9483B #F2B63D #2F86B5 #4E9C5E #E07B4A #8E5BA6`.++Landmarks are stylised silhouettes, built from paths in `engine/scenes.js`, not traced from photographs; no logos, no brands, no maps. Bare paper does the bright work: the marble terraces and the walkway in Beijing, the Obelisco, the stars.## Titles & text-No narration and no subtitles: the poster text *is* the information. The title card is a printed 4:1 banner (1800×440 u, title split into two balanced lines), framed to fill the width (≈5 % margins, ≈40 % of frame height), which becomes the header of the final wall (hung at 1150 px wide so the posters keep ≥30 px values). Reading rule used in the demo: each text stays ≥ chars/12 + 1 s (min 1.5 s) after its **last** item lands. The timeline computes this from `content.json` and rounds up to the beat.+- City names are printed into the sky (Big Shoulders Display 900, tracked) with a short Chinese name beside them (Noto Sans SC 600).+- The ticket stub (350×556 at 1478, 236; two half-round notches and a row of perforations knocked out to paper): DAY · FROM HOME n KM (accent ink) · landmark and year, or TRAVELLED on the way home. It is printed last, row by row, and stays at the same place on screen in every city.+- Subtitles: a dark ink strip at the bottom centre, Chinese line over English line, type knocked out to paper colour, pulled on in 0.12 s. Each cue holds ≥ 1.8 s and ≥ its line + 0.6 s.+- Reading times are checked by `core/render/readcheck.mjs` (`window.TEXTS`); city names and stub rows are separate texts, and running counters are only reported once they stop.## End card-The end card is printed as a last landscape mini-poster in two pulls: a split-fountain pull for the art (sky bands, sun ring, ridge, trail dashes, title), then a `near` pull for the info band (style name, `Lemo-Opuscar`, `LemoLab × Claude Opus 5.5`, font and sample credits). The "LemoLab × Claude Opus 5.5" sign-off belongs to this library's demo only; a user's film carries no LemoLab credit and no copy of this card.+At 46.2 s a wider ticket (560×600) is pulled over the right side of the night print, then its type: THE LONG WAY HOME / 绕远路回家, SILKSCREEN TRAVEL POSTER / 丝印旅行海报 and `LemoLab × Claude Opus 5.5`. It holds to the end (3 s). The sign-off belongs to this library's demo only; a user's film carries no LemoLab credit.-## Build notes+## Build-`sh styles/silkscreen-poster/demo/build.sh` rebuilds everything:-1. `tools/timeline.mjs` prints the timeline derived from `content.json`.-2. `core/render/events.mjs` → `events.json` (every pull, lift, band, name, item, wipe, swap, part, silence, clack).-3. `music/compose.py` reads `events.json` → `score.wav` plus stems.-4. `mix.py` → `mix.wav` (ambience, foley, ducking, silence windows).-5. `tools/cuecheck.py` checks the mix onsets against the events: median error 4 ms; 30/33 within 1 frame. The rest are overlapping events and slow harmonica attacks.-6. Render (`--workers 2`, through a render limiter if your machine has one) → `mux.sh … 24 3`.+`sh styles/silkscreen-poster/demo/build.sh` (or `LIB=<library> sh demo/build.sh`) rebuilds everything: fonts (`tools/fetch_fonts.sh`), narration if missing (`core/tts/tts.py` → `demo/out/voice/`) and the speech-to-text check, subtitles (`tools/cues.py` → `voice/cues.json` and `../silkscreen-poster.srt`), events, score (`music/compose.py`), mix (`mix.py`), picture (`--workers 2`), master (−14 LUFS), readcheck, `poster.jpg` and `demo/stills/styleframe.jpg`. `sh demo/build.sh 28 36` renders a span. About one minute on Apple silicon.-Files: `engine/silk.js` (print engine), `engine/scenes.js` (5 built-in scenes), `engine/poster.js` (template, banner, contrast), `film.js` (timeline and shots), `mix.py`, `music/compose.py`. Roughly 0.1 s per frame; a full render takes under a minute.+Facts on the stubs (distances by the haversine formula, landmark years) and their sources: [`demo/FACTS.md`](demo/FACTS.md). Third-party material: [`demo/CREDITS`](demo/CREDITS).-### Pitfalls we hit--- **Stroke-based edge effects draw internal lines on unioned paths.** A forest drawn as a union of pines showed every tree outline. Do sheen and trap with fills only: fill the shape, then fill it again shifted, inside a clip.-- **Screen shadow darkened the whole print.** The frame's drop shadow must be a ring (even-odd), not a full rectangle, or everything under the mesh looks muddy.-- **Blue shadow facets on granite read as water.** Keep shadow planes in `near` and put them on the inside faces next to the waterfall.-- **A thick squeegee across a close-up splits the frame into "two pictures".** Tilt the blade, hide most of the handle, and keep the geometry continuous across it.-- **Jagged-triangle ink beads read as paper edges.** The bead needs roundness: lit half, dark underside, highlight and strands.-- **Parallax alone reads as "the mountains are moving".** Show paper gaps and thickness shadows while layers are loose, and snap them to zero with a sound.-- **Night palettes hid the header and labels.** Choose text inks by contrast (`pickInk`), never by a fixed key.-- **Wet-sheen gradient stuck at the end of the pull** (condition `p < 1.02` stays true forever). Fade it out by time.-- **Tree-wipe covered the frame for 0.4 s** (a dark blank). Centre the silhouette on the switch time so full cover lasts about 1 frame.-- Four trails at these reading times run to about 45 s. See "Four trails in 40 s" below for how to compress.-- **A 7:1 title banner is a sliver in a 16:9 frame** (about 1/5 of the height, lots of empty table). Make the banner about 4:1 so it can fill the width and about 40 % of the height.-- **Random coloured dots on the table read as confetti or placeholders.** Build a real workbench: planks, grain, knots, a few large muted ink stains and torn tape.-- **Close-ups on an info band must keep the whole band in frame** with ≥5 % side margins (z ≤ 1.75 for a 1000 u poster). Close-ups on a sheet being printed must keep the sheet's edge in frame, or the viewer sees only a flat colour.+Rules the build follows:+- A knocked-out shape (`knock`) is filled even-odd together with its parent, so its sub-paths must not overlap; to cut one layer out of another use `cut`, which clips with the inverse.+- Every ellipse added to a `Path2D` starts with its own `moveTo` and ends with `closePath`, or the arcs join into stray wedges.+- Stub type, header type and end card type pick inks by contrast against `near` with a light fallback, so night palettes stay legible.+- The ticket stub and the push into it live in screen space (`OZ`), so a crane or a truck over a tall or wide print doesn't move them.+- Bars, beats and every hit come from one timeline in `film.js`; `events.json` drives the score and the foley.## Engine reference@@ -112,9 +107,11 @@ Files: `engine/silk.js` (print engine), `engine/scenes.js` (5 built-in scenes),| `screenFrame(ctx, box, o)` | hinged screen with mesh, emulsion and tape; `lift` 0–1 || `inkFinish(ctx, T, x, y, w, h)` | mottle and pinholes over the sheet || `bandSteps(x, w, y0, y1, n)` | stepped colour bands (the gradient substitute) |-| `ridgeLine`, `polyPath`, `circlePath`, `ringPath` | shape helpers |+| `ridgeLine`, `polyPath`, `circlePath`, `ringPath`, `rectPath`, `unionPath` | shape helpers |-`engine/poster.js`: `buildPoster(content, trail, i, n)`, `drawPoster(ctx, P, { pal, T, prog, off, reg, sep, swap, items, … })`, `drawBanner`, `pickInk`. `engine/scenes.js`: `buildScene('lake'|'waterfall'|'ridge'|'forest'|'coast')` returns planes you can reorder or extend.+`engine/scenes.js`: `temple`, `istanbul`, `paris`, `boca`, `sea` return `{ w, h, header, depth, parts: [{ pull, ink, path, knock?, cut?, lit? }] }` (a print of any size; `pull` names the squeegee pass, `depth` drives parallax and paper gaps).+`engine/poster.js`: `drawArt(ctx, scene, { pal, T, prog, off, sep, header })` prints a scene (partial pulls, loose layers, split fountain via `ink: 'fountain'`); `drawStub`, `drawEndCard`, `pickInk`; `drawPrint` is the opening's Beijing print with the stub in art units.+`film.js`: the timeline, cameras (`camS` art camera inside a screen-space zoom `OZ`), `sweep()` (a diagonal pull that prints the next print behind the blade), `treeWipe()`, subtitles, `window.TEXTS`.Minimal example: a warm-orange `#D97757` four-point spark with a cursor tail, printed in two inks and knocked out of a sky, then pulled in by the squeegee:```js@@ -132,45 +129,4 @@ const x = wipeFront([0, 0, 800, 600], 'right', p);squeegee(ctx, [x + 10, -20], [x + 10, 620], [1, 0], { color: '#D97757', roll: x / 30 });inkFinish(ctx, T, 0, 0, 800, 600);```-Single-colour posters: keep one palette key (usually `sun`) as the only colour and set the other inks to tints of one hue. `pickInk` keeps the text legible.--## content.json fields--All text, data and colour come from `demo/content.json`; `film.js` has no copy in it.--| Field | Type | Range | If out of range |-|---|---|---|---|-| `park` | string | ≤ 22 chars | header is letter-spaced at 62 u; longer names overflow the sky width (shorten or reduce tracking) |-| `title` | string | ≤ 34 chars | auto-fits 132 → 60 u on the banner; under 60 u it gets too small to read |-| `footer` | string | ≤ 45 chars | one line in the banner strip; the wall hold grows with its reading time |-| `trails[]` | array | **1–4** | 1 = press only (no climb); 2 = press + climb; 3 = press, quick, climb; 4 = press, quick, quick, climb (about 45 s, see below). Above 4, the wall posters become too small to read |-| `trails[].name` | string | ≤ 22 chars | auto-fits 122 → 60 u |-| `trails[].difficulty` | `easy` \| `moderate` \| `hard` \| `expert` | — | unknown values show 1 filled triangle |-| `trails[].distance` | number | any | printed as `3.2 KM` (unit from `units.distance`) |-| `trails[].time` | string | ≤ 7 chars (`1 h`, `45 min`) | the column widens and all values shrink together (min 48 u) |-| `trails[].elevation` | number \| null | null hides the CLIMB column | shown in `sun` ink as `↑1,100 M` |-| `trails[].scene` | `lake` \| `waterfall` \| `ridge` \| `forest` \| `coast` | built in | unknown → `lake` |-| `trails[].time_of_day` | key into `palette` | `dawn`, `noon`, `golden`, `dusk`, `night` | missing → `noon`. The climb re-inks from the previous trail's palette through `golden` to this one |-| `palette.<time>` | `{sky1, sky2, far, mid, near, sun, glow?}` | hex | text contrast is checked automatically |-| `palette.paper`, `palette.wall`, `banner_time` | hex / object / key | — | — |--**Steps**: edit `content.json` → `sh demo/build.sh`. There is no TTS; the music and mix re-time themselves from `events.json`. To preview another file without overwriting: `node core/render/still.mjs styles/silkscreen-poster/demo 30 --q content=content_alt.json`.--**Four trails in 40 s**: the reading rule makes each middle poster about 6 s long. Options, in order of preference:-1. Print the two middle posters **side by side on one table in the same pulls** (one quick section, two bands, read together).-2. Drop the per-item stamp spacing from an eighth note to a sixteenth for middle posters.-3. Skip the band close-up on middle posters and let them be read on the final wall (extend the wall hold by 2 s).--`content_alt.json` (4 walks, dawn/golden/noon/night, a new park, wall and banner palette) is the tested example. Its stills are in `demo/stills/alt_*.jpg`.--Minimal content:-```json-{ "park": "Pine Lake", "title": "One Walk at Pine Lake", "footer": "Open dawn to dusk",- "units": { "distance": "km", "elevation": "m" }, "banner_time": "dawn",- "trails": [ { "name": "Shore Path", "difficulty": "easy", "distance": 2, "time": "40 min",- "elevation": null, "scene": "lake", "time_of_day": "dawn" } ],- "palette": { "paper": "#F2E8D2",- "dawn": { "sky1": "#F6CD98", "sky2": "#EE9A73", "far": "#9A7FA8", "mid": "#3E7079", "near": "#1E3B3F", "sun": "#FBE6B4" } } }-```--Swapping this file and running `build.sh` checks that the engine re-flows; it is not how a user's film is made.+A new place is a new scene in `scenes.js` (its parts in print order, one palette in `film.js`); the story and timeline stay yours to write.diff --git a/styles/silkscreen-poster/STYLE.md b/styles/silkscreen-poster/STYLE.mdindex d743ffd..5de0c33 100644--- a/styles/silkscreen-poster/STYLE.md+++ b/styles/silkscreen-poster/STYLE.md@@ -29,7 +29,7 @@ Not risograph (translucent fluorescent overprint with halftone grain), not ukiyo- **Ink bead**: a round tube with lit half, dark underside, rolling glints and viscous strands; a split fountain puts several colours in one bead.- **Screen**: a hinged frame with mesh, emulsion and tape; its shadow is a ring (even-odd), never a full rectangle.- **Shapes**: ridges with a jagged lit facet, pines as one outline of drooping tiers, water as a flat body with glint bars. Hard edges everywhere.-- **Poster template** (1000×1500 u): paper border, art area, a dark **info band** at the foot holding a name, a number, a rule and a row of stats; columns sized by content.+- **Poster templates**: a portrait sheet (1000×1500 u: paper border, art area, a dark **info band** at the foot holding a name, a number, a rule and a row of stats; columns sized by content), or a **full-bleed print** (16:9, art to every edge, the name printed into the sky, a dark info panel such as a ticket stub printed last). In a full-bleed film the camera stays inside the print.- **Texture budget**: fine paper tile, mottle multiply ~55 %, pinholes ~75 %, light encode grain. More reads as risograph.## 3. Colour logic@@ -74,7 +74,7 @@ A vocabulary, not a route. Opening and ending come from the topic.| Push into the mesh until the weave shows | the craft, the grain of the medium | an intimate beat; a detail || Log-zoom pull-back to the wall or window | the poster in the world | a final lockup (hold ≥ 3 s) |-Close-ups on a sheet keep its edge in frame; a squeegee across a close-up is tilted with the handle hidden, so it doesn't split the frame. Layers change by squeegee, posters through foreground silhouettes or a table move. No dissolves, no bare cuts.+Close-ups on a portrait sheet keep its edge in frame (a full-bleed print has no edge to show); a squeegee across a close-up is tilted with the handle hidden, so it doesn't split the frame. Layers change by squeegee, posters through foreground silhouettes, a diagonal sweep that prints the next poster behind the blade, or a table move. No dissolves, no bare cuts.## 7. Sound palette@@ -111,7 +111,7 @@ Each serves information order. A menu: use the ones your film needs.## 10. Engine-`demo/engine/silk.js` prints **any shape** in this style from a `Path2D`: `makeTextures`, `paperSheet`, `ink(ctx, {path, knock, paint}, {color, reg, clip, sheen, trap})`, `wipeRegion`/`wipeFront` (ragged pull), `squeegee` (blade, beads, split fountain), `screenFrame`, `inkFinish`, `bandSteps` (the gradient substitute), shape helpers. `demo/engine/poster.js` (template, banner, `pickInk` contrast), `demo/engine/scenes.js` (planes you can reorder or extend), `demo/film.js` (timeline and shots). API table and a minimal example that prints a new shape: [DEMO.md](DEMO.md#engine-reference).+`demo/engine/silk.js` prints **any shape** in this style from a `Path2D`: `makeTextures`, `paperSheet`, `ink(ctx, {path, knock, paint}, {color, reg, clip, sheen, trap})`, `wipeRegion`/`wipeFront` (ragged pull), `squeegee` (blade, beads, split fountain), `screenFrame`, `inkFinish`, `bandSteps` (the gradient substitute), shape helpers. `demo/engine/poster.js` (full-bleed print with partial pulls and loose layers, ticket stub, end card, `pickInk` contrast), `demo/engine/scenes.js` (places as ink parts in print order, any print size), `demo/film.js` (timeline, cameras, sweeps). API table and a minimal example that prints a new shape: [DEMO.md](DEMO.md#engine-reference).## 11. Variation space@@ -131,8 +131,8 @@ All far from our demo:- Openings: **the empty screen** (light through a blank mesh, a stencil being exposed); **the accent first** (a lone product in the bright ink on bare paper); **the finished wall at night**, then back to the table.- Endings: **the drying rack** (prints clipped in a row, swaying); **the poster in use** (pasted on a bus shelter, rain starting); **the last pull is paper** (the squeegee runs dry, leaving a white silhouette).-Swapping `demo/content.json` and rebuilding is a technical check that the engine re-flows, not a way to make a film.+A new place is a new scene in `demo/engine/scenes.js`; reusing the demo's places or timeline is not a way to make a film.----How our demo was made (story, shots, score, end card, build, content fields): [DEMO.md](DEMO.md). Read it after your treatment exists.+How our demo was made (story, shots, score, end card, build): [DEMO.md](DEMO.md). Read it after your treatment exists.diff --git a/styles/silkscreen-poster/demo/CREDITS b/styles/silkscreen-poster/demo/CREDITSindex 3f11187..d1957c0 100644--- a/styles/silkscreen-poster/demo/CREDITS+++ b/styles/silkscreen-poster/demo/CREDITS@@ -1,17 +1,21 @@-Three Trails — Silkscreen Travel Poster demo · credits+The Long Way Home 绕远路回家 · Silkscreen Travel Poster demo+LemoLab × Claude Opus 5.5-All artwork, poster designs, the park, trails and data are fictional and drawn by code in this folder (engine/, film.js). No generated images.+Picture: drawn in code (Canvas 2D, engine/silk.js). Landmarks (Temple of Heaven, Hagia Sophia, Eiffel Tower, the Obelisco and+La Boca's houses) are stylised silhouettes drawn as paths from their general shape, not traced from photographs. No logos, no brands,+no maps. The traveller and the trip are fiction; the distances and years on the stubs are facts, with sources in FACTS.md.-Fonts (SIL Open Font License 1.1)-- Big Shoulders Display — Patric King / The Chicago Design Collective — fonts/BigShouldersDisplay.ttf, license fonts/OFL-BigShouldersDisplay.txt — https://github.com/google/fonts/tree/main/ofl/bigshouldersdisplay-- Outfit — Rodrigo Fuenzalida — fonts/Outfit.ttf, license fonts/OFL-Outfit.txt — https://github.com/google/fonts/tree/main/ofl/outfit-- League Gothic — The League of Moveable Type (bundled, not used in the final cut) — fonts/LeagueGothic.ttf, license fonts/OFL-LeagueGothic.txt+Fonts (SIL Open Font License 1.1; licences in fonts/, files fetched by tools/fetch_fonts.sh):+ Big Shoulders Display — Patric King / Google Fonts+ Outfit — Rodrigo Fuenzalida / Google Fonts+ Noto Sans SC — Adobe / Google-Music (music/compose.py; original, 100 BPM open-D folk)-- Acoustic guitar: physical-model strums (core/audio/pluck.py); slide guitar: additive synthesis in numpy.-- VCSL — Versilian Community Sample Library (CC0 1.0), https://github.com/sgossner/VCSL: harmonica, cajon, snare (brushes), shaker.-- VSCO 2 Community Edition (CC0 1.0), https://github.com/sgossner/VSCO-2-CE: suspended cymbal.-- Karoryfer Samples "Sneakybass" upright bass (CC0 1.0), https://github.com/sfzinstruments+Voice: Kokoro-82M v1.0 (hexgrad, Apache-2.0) via kokoro-onnx, voice bf_emma. Checked with faster-whisper (MIT), model base.en.-Sound effects and ambience-- Synthesized in mix.py: squeegee on mesh, ink bead, screen hinge, paper stamps, registration clamp, pine brush, lake, waterfall, wind, visitor-center room.+Music (original score, music/compose.py) and sound (procedural foley and ambience, mix.py):+ guitar_nylon, accordion, world_perc (darbuka) — FreePats project (freepats.zenvoid.org), CC0+ jazz_bass — Karoryfer Samples "Sneakybass" / sfzinstruments, CC0+ glockenspiel, harmonica, snare2 (taps), shaker, cajon — Versilian Community Sample Library (Versilian Studios), CC0+ sus_cymbal — Versilian Studios Chamber Orchestra 2 Community Edition (VSCO 2 CE), CC0+ Squeegee, ink, screen, paper, clamp, wind, water, birds, gulls, ferry horn, bicycle bell and crickets: synthesized in code+ (core/audio/sfx.py + mix.py).diff --git a/styles/silkscreen-poster/demo/FACTS.md b/styles/silkscreen-poster/demo/FACTS.mdnew file mode 100644index 0000000..ece21aa--- /dev/null+++ b/styles/silkscreen-poster/demo/FACTS.md@@ -0,0 +1,37 @@+# FACTS · The Long Way Home++Every number and year printed on the ticket stubs or spoken in the narration.++## Distances (great-circle, from Beijing)++Method: haversine formula on a sphere of mean Earth radius 6,371.0088 km (IUGG mean radius R1), city-centre coordinates as listed on each city's Wikipedia page; rounded to the nearest 10 km on the stubs, to the nearest thousand in the narration. Recompute with the snippet at the end.++| City | Coordinates | Distance from Beijing | On the stub | Spoken |+|---|---|---|---|---|+| Beijing | 39.9042 N, 116.4074 E | 0 km | 0 KM | "zero kilometres" |+| Istanbul | 41.0082 N, 28.9784 E | 7,056 km | 7,060 KM | "seven thousand" |+| Paris | 48.8566 N, 2.3522 E | 8,217 km | 8,220 KM | "eight thousand two hundred" |+| Buenos Aires | 34.6037 S, 58.3816 W | 19,267 km | 19,270 KM | "nineteen thousand" |++- Farthest point on Earth from Beijing (its antipode, 39.9 S, 63.6 W, in Argentina): 20,015 km = half the circumference of that sphere. Basis for "on a round world, that is almost as far as you can go" (19,267 / 20,015 = 96 %).+- Route legs: Beijing–Istanbul 7,056, Istanbul–Paris 2,256, Paris–Buenos Aires 11,050, Buenos Aires–Beijing 19,267; total 39,629 km → stub "TRAVELLED 39,630 KM", spoken "thirty-nine thousand six hundred". Equatorial circumference 40,075 km (WGS 84), so the loop is "almost once around the world" (99 %).+- The trip itself (days, the traveller) is fiction; only the geometry is fact.++## Landmarks (year on the stub)++| Stub | Fact | Source |+|---|---|---|+| TEMPLE OF HEAVEN · BUILT 1420 | Temple of Heaven complex built 1406–1420 under the Yongle Emperor (the present Hall of Prayer for Good Harvests is the 1890 rebuild after the 1889 fire) | UNESCO World Heritage List no. 881, https://whc.unesco.org/en/list/881 ; https://en.wikipedia.org/wiki/Temple_of_Heaven |+| HAGIA SOPHIA · BUILT 537 | completed and dedicated in 537 under Justinian I | https://en.wikipedia.org/wiki/Hagia_Sophia ; UNESCO no. 356 (Historic Areas of Istanbul) |+| EIFFEL TOWER · BUILT 1889 | completed for the 1889 Exposition Universelle | https://www.toureiffel.paris/en/the-monument/history |+| OBELISCO · BUILT 1936 | the Obelisco de Buenos Aires, inaugurated 23 May 1936 | https://en.wikipedia.org/wiki/Obelisco_de_Buenos_Aires |++## Recompute++```python+from math import radians, sin, cos, asin, sqrt+R = 6371.0088+def d(a, b):+ (p1, l1), (p2, l2) = [(radians(x), radians(y)) for x, y in (a, b)]+ return 2 * R * asin(sqrt(sin((p2 - p1) / 2) ** 2 + cos(p1) * cos(p2) * sin((l2 - l1) / 2) ** 2))+```diff --git a/styles/silkscreen-poster/demo/build.sh b/styles/silkscreen-poster/demo/build.shindex 7fdab6a..be3b1e4 100755--- a/styles/silkscreen-poster/demo/build.sh+++ b/styles/silkscreen-poster/demo/build.sh@@ -1,17 +1,53 @@#!/bin/sh-# Rebuild "Three Trails" from scratch: sh styles/silkscreen-poster/demo/build.sh (runs from any directory)-# To change the content: edit demo/content.json (or CONTENT=content_alt.json), then rerun this script. No narration, so no TTS needed.+# One command: THE LONG WAY HOME 绕远路回家 (Silkscreen Travel Poster demo), 50 s, 1920×1080, 24 fps+# sh demo/build.sh fonts if missing, voice if missing + speech check, subtitles, events, score, mix, picture, master,+# readcheck, poster and the gallery style frame+# VOICE=1 sh demo/build.sh regenerate the narration before the check+# WORKERS=3 sh demo/build.sh more render workers (default 2)+# sh demo/build.sh 28 36 only a span of the film (film seconds) → demo/out/film-28-36.mp4+# Needs the voice tier (Kokoro model, faster-whisper) and the FreePats, Karoryfer, VCSL and VSCO 2 CE sample libraries:+# sh plugin/skills/lemo-opuscar/scripts/setup.sh deps voice+# sh tools/fetch.sh instruments freepats; sh tools/fetch.sh instruments karoryfer; sh tools/fetch.sh instruments vcsl; sh tools/fetch.sh instruments vsco2ceset -e-cd "$(dirname "$0")/../../.."-PY=.venv/bin/python; D=styles/silkscreen-poster/demo; O=styles/silkscreen-poster-Q=""; [ -n "$CONTENT" ] && Q="content=$CONTENT"-node $D/tools/timeline.mjs $CONTENT # 1. print the timeline (derived from content.json)-node core/render/events.mjs $D # 2. picture events → events.json (content.json by default)-$PY $D/music/compose.py # 3. score → music/score.wav + stems-$PY $D/mix.py # 4. ambience + foley + score ducking → mix.wav-$PY $D/tools/cuecheck.py # 5. sync-point self-check-G="" # machine-wide render throttling now lives in core/render/video.mjs-$G node core/render/video.mjs $D --fps 24 --workers 2 ${Q:+--q $Q} --out $D/out/video24.mp4 # 6. frame-by-frame render (throttled)-sh core/render/mux.sh $D/out/video24.mp4 $D/mix.wav $O/silkscreen-poster.mp4 24 3 # 7. −14 LUFS, grain 3-node core/render/still.mjs $D 33 --out $D/out/still --prefix sf_ && cp $D/out/still/sf_33.jpg $D/stills/styleframe.jpg && cp $D/out/still/sf_33.jpg $O/poster.jpg-node core/render/still.mjs $D 2.5 19.2 30.5 39.5 --q content=content_alt.json --prefix alt_ --out $D/out/alt # 8. stills with the alternate content+HERE=$(cd "$(dirname "$0")" && pwd) # .../styles/silkscreen-poster/demo+FILM=$(cd "$HERE/.." && pwd) # .../styles/silkscreen-poster+LIB=${LIB:-$(cd "$HERE/../../.." && pwd)} # library root+export LIB+[ -f "$LIB/core/render/video.mjs" ] || { echo "set LIB to the library folder"; exit 1; }+PY=${PY:-"$LIB/.venv/bin/python"}+NAME=silkscreen-poster+WORKERS=${WORKERS:-2}+A=${1:-0}; B=${2:-50}+cd "$LIB"+mkdir -p "$HERE/out/voice" "$HERE/stills"+sh "$HERE/tools/fetch_fonts.sh"++# narration: Kokoro bf_emma, one clip per line; every clip must pass the speech-to-text check+if [ "${VOICE:-0}" = "1" ] || [ ! -f "$HERE/out/voice/L10.wav" ]; then+ "$PY" core/tts/tts.py "$HERE/voice/lines.json" "$HERE/out/voice"+fi+"$PY" core/tts/asr_check.py "$HERE/voice/lines.json" "$HERE/out/voice" --lang en++if [ "$A" != 0 ] || [ "$B" != 50 ]; then # a span, for checking a part of the film+ "$PY" "$HERE/tools/cues.py" "$A" "$B" "$HERE/out/film-$A-$B.srt"+ node core/render/events.mjs "$HERE"+ "$PY" "$HERE/music/compose.py"+ "$PY" "$HERE/mix.py" "$A" "$B"+ node core/render/video.mjs "$HERE" --q "a=$A&b=$B" --fps 24 --workers "$WORKERS" --out "$HERE/out/video-$A-$B.mp4"+ sh core/render/mux.sh "$HERE/out/video-$A-$B.mp4" "$HERE/out/mix.wav" "$HERE/out/film-$A-$B.mp4" 24 2+ echo "done: $HERE/out/film-$A-$B.mp4"; exit 0+fi++"$PY" "$HERE/tools/cues.py" # voice/cues.json + ../silkscreen-poster.srt+node core/render/events.mjs "$HERE" # → events.json (film times)+"$PY" "$HERE/music/compose.py" # → music/score.wav+"$PY" "$HERE/mix.py" # → out/mix.wav+node core/render/video.mjs "$HERE" --fps 24 --workers "$WORKERS" --out "$HERE/out/video.mp4"+sh core/render/mux.sh "$HERE/out/video.mp4" "$HERE/out/mix.wav" "$FILM/$NAME.mp4" 24 2++# checks, poster and the gallery style frame (Beijing at night, without subtitles)+node core/render/readcheck.mjs "$HERE" > "$HERE/out/readcheck.txt" && echo "readcheck ok" || { grep -v '^OK' "$HERE/out/readcheck.txt" | tail -8; }+node core/render/still.mjs "$HERE" 44.5 --q nocap=1 --out "$HERE/out/poster" > /dev/null+ffmpeg -v error -y -i "$HERE/out/poster/t_44.5.jpg" -q:v 3 "$FILM/poster.jpg"+cp "$FILM/poster.jpg" "$HERE/stills/styleframe.jpg"+echo "done: $FILM/$NAME.mp4"diff --git a/styles/silkscreen-poster/demo/content.json b/styles/silkscreen-poster/demo/content.jsondeleted file mode 100644index 70a4b6d..0000000--- a/styles/silkscreen-poster/demo/content.json+++ /dev/null@@ -1,47 +0,0 @@-{- "park": "Granite Valley",- "title": "3 Trails in Granite Valley",- "kicker": "Visitor Center Trail Guide",- "footer": "Free trail maps at the Visitor Center",- "units": { "distance": "km", "elevation": "m" },- "trails": [- {- "name": "Lakeshore Loop",- "difficulty": "easy",- "distance": 3.2,- "time": "1 h",- "elevation": null,- "scene": "lake",- "time_of_day": "dawn"- },- {- "name": "Cascade Falls Trail",- "difficulty": "moderate",- "distance": 7,- "time": "3 h",- "elevation": null,- "scene": "waterfall",- "time_of_day": "noon"- },- {- "name": "Summit Ridge",- "difficulty": "hard",- "distance": 14,- "time": "7 h",- "elevation": 1100,- "scene": "ridge",- "time_of_day": "dusk"- }- ],- "banner_time": "banner",- "palette": {- "banner": { "sky1": "#F7C66B", "sky2": "#E4683F", "far": "#2F6F73", "mid": "#2F6F73", "near": "#1C2A33", "sun": "#FBE3A6", "glow": "#F7C66B" },- "paper": "#F2E8D2",- "wall": { "board": "#5E4432", "groove": "#3F2C21", "rail": "#8A6547" },- "dawn": { "sky1": "#F6CD98", "sky2": "#EE9A73", "far": "#9A7FA8", "mid": "#3E7079", "near": "#1E3B3F", "sun": "#FBE6B4" },- "noon": { "sky1": "#E4EEDC", "sky2": "#86BCD0", "far": "#C2AE92", "mid": "#4C8753", "near": "#1D4331", "sun": "#F2C14A", "glow": "#F0DFA6" },- "golden": { "sky1": "#F7D787", "sky2": "#E9A94F", "far": "#A57C68", "mid": "#5E7A45", "near": "#2B3A28", "sun": "#FFF1C4", "glow": "#F4C065" },- "dusk": { "sky1": "#F4B461", "sky2": "#D8613F", "far": "#7C3E5F", "mid": "#43325A", "near": "#1B1B2F", "sun": "#FBE3A6", "glow": "#E8683F" },- "night": { "sky1": "#3D4B72", "sky2": "#27304F", "far": "#4E5C82", "mid": "#232B45", "near": "#12152A", "sun": "#EDE6C8" }- }-}diff --git a/styles/silkscreen-poster/demo/content_alt.json b/styles/silkscreen-poster/demo/content_alt.jsondeleted file mode 100644index 0adfc99..0000000--- a/styles/silkscreen-poster/demo/content_alt.json+++ /dev/null@@ -1,56 +0,0 @@-{- "park": "Cedar Point Shores",- "title": "4 Walks on Cedar Point",- "kicker": "Harbor Inn Guest Guide",- "footer": "Ask the front desk for a tide table",- "units": { "distance": "km", "elevation": "m" },- "trails": [- {- "name": "Tidepool Walk",- "difficulty": "easy",- "distance": 2.4,- "time": "45 min",- "elevation": null,- "scene": "coast",- "time_of_day": "dawn"- },- {- "name": "Old Cedar Grove",- "difficulty": "easy",- "distance": 5,- "time": "2 h",- "elevation": 120,- "scene": "forest",- "time_of_day": "golden"- },- {- "name": "Harbor Lake Circuit",- "difficulty": "moderate",- "distance": 8.5,- "time": "3 h",- "elevation": null,- "scene": "lake",- "time_of_day": "noon"- },- {- "name": "Signal Hill Night Hike",- "difficulty": "hard",- "distance": 11,- "time": "5 h",- "elevation": 640,- "scene": "ridge",- "time_of_day": "night"- }- ],- "banner_time": "banner",- "palette": {- "paper": "#EFE9DA",- "wall": { "board": "#3E5058", "groove": "#2A383E", "rail": "#6E8A8F" },- "banner": { "sky1": "#BFE0DA", "sky2": "#3E8A9A", "far": "#E0A43C", "mid": "#E0A43C", "near": "#1E2B3A", "sun": "#F6E3B0", "glow": "#BFE0DA" },- "dawn": { "sky1": "#F7D9C2", "sky2": "#E7928A", "far": "#6A8FB0", "mid": "#3D6F8E", "near": "#22354A", "sun": "#FFF0D2", "glow": "#F7D9C2" },- "noon": { "sky1": "#E8F1E6", "sky2": "#7CB6CF", "far": "#D0B98E", "mid": "#3E8A6A", "near": "#17392E", "sun": "#EFC03E", "glow": "#F3E3AE" },- "golden": { "sky1": "#F8DC8E", "sky2": "#E59A3A", "far": "#8D6B4A", "mid": "#51683A", "near": "#26301F", "sun": "#FFF3C9", "glow": "#F6C35A" },- "dusk": { "sky1": "#F4B461", "sky2": "#D8613F", "far": "#7C3E5F", "mid": "#43325A", "near": "#1B1B2F", "sun": "#FBE3A6", "glow": "#E8683F" },- "night": { "sky1": "#46598A", "sky2": "#28325A", "far": "#6C7BA8", "mid": "#2D3659", "near": "#11152A", "sun": "#F3EACB", "glow": "#9FB2E0" }- }-}diff --git a/styles/silkscreen-poster/demo/engine/poster.js b/styles/silkscreen-poster/demo/engine/poster.jsindex da57cc0..18173ea 100644--- a/styles/silkscreen-poster/demo/engine/poster.js+++ b/styles/silkscreen-poster/demo/engine/poster.js@@ -1,225 +1,205 @@-// poster.js · travel-poster layout: scene layers + header + standard info band at the bottom (name, difficulty, distance, time, elevation gain) + banner-// All copy comes from content.json; this file only handles layout and "how it gets printed"-import { hex2rgb, ink, wipeRegion, wipeFront, inkFinish, paperSheet, texFill, rectPath, polyPath, circlePath, ringPath, clamp, lerp, hash } from './silk.js';-import { buildScene, PW, PH, ART } from './scenes.js';+// poster.js · the full-bleed 16:9 travel print of "The Long Way Home": art to every edge, the city name printed into the sky,+// a ticket stub (DAY · FROM HOME · landmark) printed last on the right. Every piece is printed by a named pull;+// st.prog(name) → 0..1 says how far that pull has gone.+import { hex2rgb, ink, wipeRegion, wipeFront, inkFinish, paperSheet, rectPath, circlePath, unionPath, clamp, hash } from './silk.js';+import { AW, AH, BLEED } from './scenes.js';+export { AW, AH, BLEED };-export { PW, PH, ART };-const FONT_D = 'BigShoulders', FONT_T = 'Outfit';-const LEVEL = { easy: 1, moderate: 2, hard: 3, expert: 3 };+export const FONT_D = 'BigShoulders', FONT_T = 'Outfit', FONT_C = 'NotoSC';+export const STUB = [1478, 236, 350, 556]; // x, y, w, h+const NOTCH_Y = 352;-function fitFont(ctx, text, weight, family, maxW, maxS, minS, ls = 0) {- let s = maxS;- for (; s > minS; s -= 2) { ctx.font = `${weight} ${s}px ${family}`; ctx.letterSpacing = (ls * s) + 'px'; if (ctx.measureText(text).width <= maxW) break; }- return s;-}-const fmtNum = (v) => typeof v === 'number' ? v.toLocaleString('en-US') : String(v);--// Stat items: generated from content (if elevation is empty it doesn't appear)-export function statItems(trail, units = { distance: 'km', elevation: 'm' }) {- const it = [];- it.push({ key: 'difficulty', label: 'LEVEL', value: String(trail.difficulty || '').toUpperCase(), level: LEVEL[(trail.difficulty || '').toLowerCase()] || 1 });- if (trail.distance != null) it.push({ key: 'distance', label: 'DISTANCE', value: `${fmtNum(trail.distance)} ${units.distance.toUpperCase()}` });- if (trail.time) it.push({ key: 'time', label: 'TIME', value: String(trail.time).toUpperCase() });- if (trail.elevation != null) it.push({ key: 'elevation', label: 'CLIMB', value: `↑${fmtNum(trail.elevation)} ${units.elevation.toUpperCase()}`, climb: true });- return it;-}-// Minimum hold for one piece of information (BRIEF_SCENE: characters/12 + 1, at least 1.5 s)-export const readTime = (s) => Math.max(1.5, String(s).length / 12 + 1);--export function buildPoster(content, trail, idx, n) {- const sc = buildScene(trail.scene, 11 + idx * 17);- const items = statItems(trail, content.units);- // cumulative length of the trail polyline- let L = 0; const tr = sc.trail.map((q, i, a) => { if (i) L += Math.hypot(q.x - a[i - 1].x, q.y - a[i - 1].y); return { ...q, s: L }; });- return { sc, trail, items, idx, n, paper: content.palette.paper, park: content.park, trailPts: tr, trailLen: L, seed: idx * 13 + 5 };-}--// Trail dashed line (draws only the segment on this plane; reveal = fraction of arc length already printed)-function trailDashes(ctx, P, plane, reveal, color) {- const pts = P.trailPts, maxS = reveal * P.trailLen, dash = 16, gap = 12;- ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = 7; ctx.lineCap = 'butt';- for (let i = 1; i < pts.length; i++) {- const a = pts[i - 1], b = pts[i]; if (b.plane !== plane && a.plane !== plane) continue;- if (b.plane !== plane) continue;- const len = b.s - a.s;- for (let s = Math.ceil(a.s / (dash + gap)) * (dash + gap); s < b.s && s < maxS; s += dash + gap) {- const t0 = (s - a.s) / len, t1 = Math.min(1, (Math.min(s + dash, maxS) - a.s) / len);- ctx.beginPath(); ctx.moveTo(lerp(a.x, b.x, t0), lerp(a.y, b.y, t0)); ctx.lineTo(lerp(a.x, b.x, t1), lerp(a.y, b.y, t1)); ctx.stroke();- }- }- ctx.restore();-}---// Contrast: pick an ink with enough contrast against the background by WCAG relative luminance (so text doesn't "vanish" when content or palette changes)+// WCAG contrast: text inks are chosen against the ink underneathconst lum = (h) => { const c = hex2rgb(h).map(v => { v /= 255; return v <= .03928 ? v / 12.92 : Math.pow((v + .055) / 1.055, 2.4); }); return .2126 * c[0] + .7152 * c[1] + .0722 * c[2]; };export const contrast = (a, b) => { const x = lum(a), y = lum(b); return (Math.max(x, y) + .05) / (Math.min(x, y) + .05); };export function pickInk(bgs, cands, need = 3) { bgs = [].concat(bgs); for (const c of cands) if (c && bgs.every(b => contrast(c, b) >= need)) return c; return cands.filter(Boolean).sort((a, b) => Math.min(...bgs.map(x => contrast(b, x))) - Math.min(...bgs.map(x => contrast(a, x))))[0]; }-// ---- layout constants -----// The picture area runs to y=1140; the whole scene shifts up by SHIFT (cropping a little sky) to make room for a taller info band-export const ARTV = [26, 26, 948, 1114], SHIFT = 50, BAND = [26, 1148, 948, 326];-const NAME_Y = 1262, RULE_Y = 1290, LABEL_Y = 1348, VALUE_Y = 1440;-// Ink-pull area in a rotated frame (for the colour-swap reprint, pushed diagonally)-function tiltedWipe(ctx, p, angle, seed) {- const m = ctx.getTransform();- ctx.translate(PW / 2, PH / 2); ctx.rotate(angle); ctx.translate(-PW / 2, -PH / 2);- const box = [-400, -300, PW + 800, PH + 600];- ctx.clip(wipeRegion(box, 'up', p, seed, 50, 7));- ctx.setTransform(m);+// a pull's printed region with the squeegee travelling at an angle (rotated about the print's centre)+const BOX = [-300, -300, AW + 600, AH + 600];+function rot(angle) { return new DOMMatrix().translate(AW / 2, AH / 2).rotate(angle * 180 / Math.PI).translate(-AW / 2, -AH / 2); }+export function tiltRegion(p, angle, seed, tail = 34) {+ if (p >= 1) return null;+ const out = new Path2D(); out.addPath(wipeRegion(BOX, 'down', p, seed, tail, 6), rot(angle)); return out;}-export function swapFrontLine(p, angle) { // squeegee position (poster coordinates): returns both ends of the blade- const box = [-400, -300, PW + 800, PH + 600], y = wipeFront(box, 'up', p, 50);- const c = Math.cos(angle), s = Math.sin(angle), rot = (x, yy) => { const dx = x - PW / 2, dy = yy - PH / 2; return [PW / 2 + dx * c - dy * s, PH / 2 + dx * s + dy * c]; };- return [rot(-400, y), rot(PW + 400, y)];+export function tiltFront(p, angle, tail = 34) {+ const y = wipeFront(BOX, 'down', p, tail), m = rot(angle);+ const a = m.transformPoint(new DOMPoint(-300, y)), b = m.transformPoint(new DOMPoint(AW + 300, y));+ const d = m.transformPoint(new DOMPoint(0, 1)), o = m.transformPoint(new DOMPoint(0, 0));+ return { a: [a.x, a.y], b: [b.x, b.y], lead: [d.x - o.x, d.y - o.y] };}+const R2 = (seed, amp) => [(hash(seed * 3.1 + 1) - .5) * 2 * amp, (hash(seed * 7.7 + 1.3) - .5) * 2 * amp];+function inverse(p) { const q = new Path2D(); q.rect(-1e4, -1e4, 2e4, 2e4); q.addPath(p); return q; }-// ---- draw one poster (under the current transform, in poster units) -----// st: { pal, T, prog(id)->0..1, off(id)->[dx,dy], reg, sep(0..1 paper-stencil separation), trail, band, name, header, items[], swap:{pal,p,angle}, finish }-export function drawPoster(ctx, P, st) {- paperSheet(ctx, st.T, 0, 0, PW, PH);- body(ctx, P, st, st.pal);- if (st.swap && st.swap.p > 0) {- ctx.save(); tiltedWipe(ctx, st.swap.p, st.swap.angle ?? -.2, 7 + P.idx);- paperSheet(ctx, st.T, 0, 0, PW, PH);- body(ctx, P, st, st.swap.pal);- ctx.restore();- }- if (st.finish !== false) inkFinish(ctx, st.T, 0, 0, PW, PH, .6, 1);+// the stub panel: near ink, two half-round notches and a perforation row knocked out to paper+export function stubPath() {+ const [x, y, w, h] = STUB, p = rectPath(x, y, w, h);+ const knock = new Path2D();+ knock.arc(x, NOTCH_Y, 18, -Math.PI / 2, Math.PI / 2); knock.closePath();+ knock.moveTo(x + w, NOTCH_Y - 18); knock.arc(x + w, NOTCH_Y, 18, -Math.PI / 2, Math.PI / 2, true); knock.closePath();+ for (let xx = x + 34; xx < x + w - 26; xx += 22) { knock.moveTo(xx + 4.5, NOTCH_Y); knock.arc(xx, NOTCH_Y, 4.5, 0, Math.PI * 2); }+ return { path: p, knock };}-const R2 = (seed, k, amp) => [(hash(seed * 3.1 + k) - .5) * 2 * amp, (hash(seed * 7.7 + k * 1.3) - .5) * 2 * amp];-function body(ctx, P, st, pal) {- const prog = st.prog || (() => 1), off = st.off || (() => [0, 0]), regAmt = st.reg ?? 1, sep = st.sep || 0;- ctx.save(); ctx.beginPath(); ctx.rect(ARTV[0], ARTV[1], ARTV[2], ARTV[3]); ctx.clip();- ctx.translate(0, -SHIFT);- P.sc.planes.forEach((pl, k) => {- const p = prog(pl.id); if (p <= 0) return;- const [ox, oy] = off(pl.id, pl);- ctx.save(); ctx.translate(ox, oy);- const box = [ART[0] - ox, ART[1] - oy - 60, ART[2], ART[3] + 180];- // paper-stencil separation: offset this stencil's outline upward a little to print a paper-white gap, then one more step up a paper-thickness shadow (falling on the layer below)- if (sep > 0 && k > 1 && p >= 1) {- const sil = pl.parts[0].path;- ctx.save(); ctx.translate(0, -9 * sep); ctx.globalAlpha = .28 * Math.min(1, sep * 1.5); ctx.fillStyle = '#140f14'; ctx.fill(sil); ctx.restore();- ctx.save(); ctx.translate(1.5 * sep, -3.2 * sep); ctx.fillStyle = P.paper; ctx.fill(sil); ctx.restore();- }- pl.parts.forEach((pt, j) => {- const pp = pt.sub ? clamp(p * 1.35 - .35) : clamp(p * 1.35); // accent colour half a beat later- if (pp <= 0) return;- const reg = R2(P.seed + k * 5 + j, 1, 2.2 * regAmt);- ink(ctx, pt, { color: pal[pt.ink] || (pt.ink === 'glow' ? pal.sky2 : pal.far), reg, clip: pp < 1 ? wipeRegion(box, st.dir || 'down', pp, P.seed + k * 3 + j, 30, 5) : null, sheen: 1, trap: 1, lw: 1.8 });- });- if (st.trail != null ? st.trail > 0 : true) {- const rv = st.trail ?? 1;- ctx.save(); ctx.translate(...R2(P.seed + 91, 1, 1.5 * regAmt)); trailDashes(ctx, P, pl.id, rv, pal.sun); ctx.restore();- }+// P = { scene, city, cityZh, day, km, landmark, built, seed }; st = { pal, T, prog(name), angle, reg, imprint, off(pull) }+export function drawPrint(ctx, P, st) {+ const pal = st.pal, prog = st.prog, reg = st.reg ?? 1, ang = st.angle ?? -.08;+ paperSheet(ctx, st.T, -BLEED, -BLEED, AW + 2 * BLEED, AH + 2 * BLEED, .6);+ P.scene.parts.forEach((pt, j) => {+ const p = prog(pt.pull); if (p <= 0) return;+ const off = st.off ? st.off(pt.pull) : [0, 0];+ ctx.save(); ctx.translate(off[0], off[1]);+ if (pt.cut) ctx.clip(inverse(pt.cut), 'evenodd');+ ink(ctx, pt, { color: pal[pt.ink], reg: R2(P.seed + j * 5, 2.2 * reg), clip: tiltRegion(p, ang, P.seed + j * 3), sheen: 1, trap: pt.lit ? 0 : 1, lw: 1.8 });ctx.restore();});- ctx.restore();- // header: park name (printed over the sky)- const hp = st.header ?? 1;+ // ---- the city, printed into the sky ----+ const hp = prog('header');if (hp > 0) {- ink(ctx, { paint: (c) => { c.font = `800 62px ${FONT_D}`; c.letterSpacing = '14px'; c.textAlign = 'center'; c.textBaseline = 'alphabetic'; c.fillText(P.park.toUpperCase(), PW / 2 + 7, 112); } },- { color: pickInk([pal.sky2, pal.sky1], [pal.near, pal.sun, pal.sky1], 3), reg: R2(P.seed + 44, 1, 1.4 * regAmt), clip: hp < 1 ? wipeRegion([0, 40, PW, 100], 'right', hp, 3) : null });- }- // info band- const bp = st.band ?? 1;- if (bp > 0) {- ink(ctx, { path: rectPath(...BAND) }, { color: pal.near, reg: R2(P.seed + 51, 1, 1.2 * regAmt), clip: bp < 1 ? wipeRegion(BAND, 'right', bp, 9, 40) : null, sheen: 1 });- }- const np = st.name ?? 1;- if (np > 0) {+ const clip = hp < 1 ? wipeRegion([80, 60, 900, 200], 'right', hp, 13, 40) : null;+ const col = pickInk([pal.sky2, pal.sky1], [pal.near, pal.mid], 3);ink(ctx, { paint: (c) => {- const s = fitFont(c, P.trail.name.toUpperCase(), 900, FONT_D, 690, 122, 60, .01);- c.textAlign = 'left'; c.textBaseline = 'alphabetic'; c.fillText(P.trail.name.toUpperCase(), 64, NAME_Y);- } }, { color: pickInk(pal.near, [pal.sky1, pal.sun, pal.glow], 4.5), reg: R2(P.seed + 61, 1, 1.4 * regAmt), clip: np < 1 ? wipeRegion([40, 1150, 900, 130], 'right', np, 21, 30) : null });- ink(ctx, { paint: (c) => { c.font = `900 122px ${FONT_D}`; c.letterSpacing = '0px'; c.textAlign = 'right'; c.fillText(String(P.idx + 1).padStart(2, '0'), 938, NAME_Y); } },- { color: pal.sun, reg: R2(P.seed + 62, 1, 1.4 * regAmt), clip: np < 1 ? wipeRegion([780, 1150, 170, 130], 'down', np, 23, 30) : null });- ink(ctx, { path: rectPath(64, RULE_Y, 874, 6) }, { color: pal.sun, reg: R2(P.seed + 63, 1, 1.2 * regAmt), clip: np < 1 ? wipeRegion([60, RULE_Y - 10, 880, 26], 'right', np, 5, 20) : null });+ c.font = `900 150px ${FONT_D}`; c.letterSpacing = '16px'; c.textAlign = 'left'; c.textBaseline = 'alphabetic'; c.fillText(P.city, 104, 214);+ const w = c.measureText(P.city).width;+ c.font = `600 54px ${FONT_C}`; c.letterSpacing = '6px'; c.fillText(P.cityZh, 104 + w + 18, 210);+ } }, { color: col, reg: R2(P.seed + 44, 1.4 * reg), clip });}- // stat items: one row of n columns; labels 38u (≥18 px on the wall), values 64u condensed (≥30 px on the wall); column widths allocated by content- const L = statLayout(ctx, P);- P.items.forEach((it, i) => {- const ip = st.items ? (st.items[i] ?? 0) : 1; if (ip <= 0) return;- const x = L.xs[i], cw = L.ws[i], box = [x - 6, LABEL_Y - 44, cw + 12, 150];- const clip = ip < 1 ? wipeRegion(box, 'right', ip, 31 + i, 24) : null;- ink(ctx, { paint: (c) => { c.font = `600 ${L.ls}px ${FONT_T}`; c.letterSpacing = (L.ls * .1) + 'px'; c.textAlign = 'left'; c.fillText(it.label, x, LABEL_Y); } },- { color: pickInk(pal.near, [pal.sky2, pal.glow, pal.far, pal.sky1], 3), reg: R2(P.seed + 70 + i, 1, 1.2 * regAmt), clip });- ink(ctx, { paint: (c) => {- let tx = x;- if (it.key === 'difficulty') { icons(c, x, it.level, L.vs); tx = x + L.vs * 1.3; }- c.font = `800 ${L.vs}px ${FONT_D}`; c.letterSpacing = (L.vs * .01) + 'px'; c.textAlign = 'left'; c.fillText(it.value, tx, VALUE_Y);- } }, { color: it.climb || it.key === 'difficulty' ? pickInk(pal.near, [pal.sun, pal.sky1], 4.5) : pickInk(pal.near, [pal.sky1, pal.sun, pal.glow], 4.5), reg: R2(P.seed + 80 + i, 1, 1.2 * regAmt), clip });- });-}-function icons(c, x, level, vs) { // three small mountain icons: filled = difficulty level- const w = vs * .34, h = vs * .52, g = vs * .4;- for (let k = 0; k < 3; k++) {- const px = x + k * g; c.beginPath(); c.moveTo(px, VALUE_Y); c.lineTo(px + w / 2, VALUE_Y - h); c.lineTo(px + w, VALUE_Y); c.closePath();- if (k < level) c.fill(); else { c.save(); c.lineWidth = vs * .055; c.strokeStyle = c.fillStyle; c.globalAlpha *= .6; c.stroke(); c.restore(); }+ // ---- the ticket stub, printed last ----+ const sp = prog('stub');+ if (sp > 0) {+ const s = stubPath();+ ink(ctx, s, { color: pal.near, reg: R2(P.seed + 51, 1.2 * reg), clip: sp < 1 ? wipeRegion([STUB[0] - 30, STUB[1] - 20, STUB[2] + 60, STUB[3] + 40], 'down', sp, 9, 40) : null, sheen: 1 });}+ const [X, Y, Wd] = STUB, lx = X + 34;+ const lab = pickInk(pal.near, [pal.sky1, pal.glow, pal.sky2], 4.5), val = pickInk(pal.near, [pal.sky1, pal.sun], 4.5), key = pickInk(pal.near, [pal.sun, pal.sky1], 3);+ const item = (name, fn, color, box) => { const p = prog(name); if (p <= 0) return; ink(ctx, { paint: fn }, { color, reg: R2(P.seed + name.length * 7, 1.2 * reg), clip: p < 1 ? wipeRegion(box, 'right', p, 31 + name.length, 24) : null }); };+ item('day', (c) => { c.font = `600 30px ${FONT_T}`; c.letterSpacing = '6px'; c.textAlign = 'left'; c.fillText('DAY', lx, Y + 76); c.font = `800 64px ${FONT_D}`; c.letterSpacing = '1px'; c.fillText(String(P.day), lx + 96, Y + 82); }, lab, [X, Y + 10, Wd, 100]);+ item('km', (c) => {+ c.font = `600 30px ${FONT_T}`; c.letterSpacing = '6px'; c.textAlign = 'left'; c.fillStyle = lab; c.fillText('FROM HOME', lx, Y + 186);+ c.fillStyle = key; c.font = `900 ${P.km.length > 5 ? 112 : 132}px ${FONT_D}`; c.letterSpacing = '2px'; c.fillText(P.km + ' KM', lx - 4, Y + 318);+ c.fillRect(lx, Y + 344, Wd - 68, 6);+ }, key, [X, Y + 140, Wd, 230]);+ item('landmark', (c) => {+ c.font = `600 25px ${FONT_T}`; c.letterSpacing = '4px'; c.textAlign = 'left'; c.fillStyle = lab; c.fillText(P.landmark, lx, Y + 414);+ c.fillStyle = val; c.font = `800 62px ${FONT_D}`; c.letterSpacing = '1px'; c.fillText('BUILT ' + P.built, lx, Y + 488);+ }, val, [X, Y + 380, Wd, 130]);+ // ---- optional printer's imprint, bottom right (page option ?sign=1; off in the film) ----+ const ip = st.imprint ? prog('sign') : 0;+ if (ip > 0) ink(ctx, { paint: (c) => { c.font = `600 26px ${FONT_T}`; c.letterSpacing = '4px'; c.textAlign = 'right'; c.textBaseline = 'alphabetic'; c.fillText('LemoLab × Claude Opus 5.5', AW - 52, AH - 30); } },+ { color: pickInk(pal.near, ['#F3EAD8', pal.sky1], 4.5), reg: R2(P.seed + 95, reg), clip: ip < 1 ? wipeRegion([AW - 520, AH - 70, 500, 60], 'right', ip, 41, 24) : null });+ if (st.finish !== false) inkFinish(ctx, st.T, -BLEED, -BLEED, AW + 2 * BLEED, AH + 2 * BLEED, .6, 1);}-function statLayout(ctx, P) {- if (P._stat) return P._stat;- const x0 = 64, x1 = 938, avail = x1 - x0, n = P.items.length;- let vs = 68, ls = 38, ws;- for (; ; vs -= 2, ls = Math.max(34, ls - 1)) {- ctx.save();- ws = P.items.map(it => {- ctx.font = `600 ${ls}px ${FONT_T}`; ctx.letterSpacing = (ls * .1) + 'px'; const lw = ctx.measureText(it.label).width;- ctx.font = `800 ${vs}px ${FONT_D}`; ctx.letterSpacing = (vs * .01) + 'px'; const vw = ctx.measureText(it.value).width + (it.key === 'difficulty' ? vs * 1.3 : 0);- return Math.max(lw, vw);- });++// boxes of the printed texts (art units), for window.TEXTS+export function textBoxes(P) {+ const [X, Y, Wd] = STUB;+ return [+ { id: 'header', pull: 'header', text: P.city + ' ' + P.cityZh, box: [104, 90, 980, 224] },+ { id: 'day', pull: 'day', text: 'DAY ' + P.day, box: [X + 30, Y + 30, X + 220, Y + 92] },+ { id: 'km', pull: 'km', text: 'FROM HOME ' + P.km + ' KM', box: [X + 26, Y + 156, X + Wd - 20, Y + 350] },+ { id: 'landmark', pull: 'landmark', text: P.landmark + ' BUILT ' + P.built, box: [X + 30, Y + 390, X + Wd - 20, Y + 496] },+ ];+}++// ======================================================================================================+// Generic pieces for the rest of the film: any scene (any width/height), loose layers, split fountain,+// a re-ink sweep between two prints, and the ticket stub drawn on its own (it stays put on screen).+// ======================================================================================================+// S = scene from scenes.js; st = { pal, T, prog(pull) (default 1), angle, reg, off(pull, depth), sep, header: {text, zh, p}, seed }+export function drawArt(ctx, S, st) {+ const W0 = S.w || AW, H0 = S.h || AH, pal = st.pal, reg = st.reg ?? 1, ang = st.angle ?? -.08, seed = st.seed || 1;+ const prog = st.prog || (() => 1), sep = st.sep || 0;+ paperSheet(ctx, st.T, -BLEED, -BLEED, W0 + 2 * BLEED, H0 + 2 * BLEED, .6);+ const box = [-300, -300, W0 + 600, H0 + 600];+ const region = (p, sd) => { if (p >= 1) return null; const m = new DOMMatrix().translate(W0 / 2, H0 / 2).rotate(ang * 180 / Math.PI).translate(-W0 / 2, -H0 / 2); const o = new Path2D(); o.addPath(wipeRegion(box, 'down', p, sd, 34, 6), m); return o; };+ S.parts.forEach((pt, j) => {+ const p = prog(pt.pull); if (p <= 0) return;+ const d = (S.depth && S.depth[pt.pull]) ?? .5;+ const off = st.off ? st.off(pt.pull, d) : [0, 0];+ ctx.save(); ctx.translate(off[0], off[1]);+ if (pt.cut) ctx.clip(inverse(pt.cut), 'evenodd');+ // loose layers: a sliver of bare paper and a paper-thickness shadow along the upper edge of each loose stencil+ if (sep > 0 && d >= .25 && p >= 1 && !pt.lit) {+ ctx.save(); ctx.translate(0, -9 * sep * d); ctx.globalAlpha = .26 * Math.min(1, sep * 1.5); ctx.fillStyle = '#140f14'; ctx.fill(pt.path); ctx.restore();+ ctx.save(); ctx.translate(1.5 * sep, -3.4 * sep); ctx.fillStyle = '#F3EAD8'; ctx.fill(pt.path); ctx.restore();+ }+ const clip = region(p, seed + j * 3), rg = R2(seed + j * 5, 2.2 * reg);+ if (pt.ink === 'fountain') {+ for (const s of S.fountain) { ctx.save(); ctx.beginPath(); ctx.rect(s.x0 - .5, -BLEED - 100, s.x1 - s.x0 + 1, H0 + 2 * BLEED + 200); ctx.clip(); ink(ctx, pt, { color: s.color, reg: rg, clip, sheen: 1, trap: 1, lw: 1.8 }); ctx.restore(); }+ } else ink(ctx, pt, { color: pal[pt.ink], reg: rg, clip, sheen: 1, trap: pt.lit ? 0 : 1, lw: 1.8 });+ ctx.restore();+ });+ const hd = st.header, hdr = S.header;+ if (hd && hdr && hd.p > 0) {+ const off = st.off ? st.off('sky', 0) : [0, 0];+ ctx.save(); ctx.translate(off[0], off[1]);+ const clip = hd.p < 1 ? wipeRegion([hdr.x - 20, hdr.y - hdr.size, 1700, hdr.size * 1.3], 'right', hd.p, 13, 40) : null;+ const col = pickInk([pal.sky2, pal.sky1], [pal.near, pal.mid, pal.sun, '#F3EAD8'], 3);+ ink(ctx, { paint: (c) => {+ c.font = `900 ${hdr.size}px ${FONT_D}`; c.letterSpacing = (hdr.size * .1) + 'px'; c.textAlign = 'left'; c.textBaseline = 'alphabetic'; c.fillText(hd.text, hdr.x, hdr.y);+ const w = c.measureText(hd.text).width;+ c.font = `600 ${Math.round(hdr.size * .36)}px ${FONT_C}`; c.letterSpacing = '6px'; c.fillText(hd.zh, hdr.x + w + 18, hdr.y - 4);+ } }, { color: col, reg: R2(seed + 44, 1.4 * reg), clip });ctx.restore();- if (ws.reduce((a, b) => a + b, 0) + (n - 1) * 30 <= avail || vs <= 48) break;}- const gap = n > 1 ? (avail - ws.reduce((a, b) => a + b, 0)) / (n - 1) : 0;- const xs = []; let x = x0; ws.forEach(w => { xs.push(x); x += w + Math.min(gap, 140); });- return (P._stat = { xs, ws, vs, ls });+ if (st.finish !== false) inkFinish(ctx, st.T, -BLEED, -BLEED, W0 + 2 * BLEED, H0 + 2 * BLEED, .6, 1);+}+// header boxes in art units (two pieces, read separately)+export function headerBoxes(S, hd) {+ const h = S.header; if (!h) return [];+ const w = hd.text.length * h.size * .56;+ return [{ id: 'hdr-en', text: hd.text, box: [h.x, h.y - h.size * .8, h.x + w, h.y + 4] }, { id: 'hdr-zh', text: hd.zh, box: [h.x + w + 18, h.y - h.size * .5, h.x + w + 18 + hd.zh.length * h.size * .4, h.y] }];}-// ---- Banner (title): 1800×440 units (about 4:1; in the opening close-up it fills the frame width and about 40% of the frame height) -----export const BW = 1800, BH = 440, BANNER_ART = [14, 14, 1772, 360];-export const BANNER_BANDS = { sky2: [0, 150], sky1: [150, 300], far: [300, 374] }; // ink-bead segments for the split-fountain pull-function splitTitle(ctx, text, family, size) { // two lines: break where widths are most balanced- const w = text.split(' '); if (w.length < 2) return [text];- ctx.font = `900 ${size}px ${family}`; let best = null;- for (let i = 1; i < w.length; i++) { const a = w.slice(0, i).join(' '), b = w.slice(i).join(' '); const d = Math.max(ctx.measureText(a).width, ctx.measureText(b).width); if (!best || d < best.d) best = { d, l: [a, b] }; }- return best.l;+// the ticket stub on its own. st = { pal, T, panel, rows: { day:{p, n}, big:{p, label, value}, small:{p, label, value} }, seed, reg }+export function drawStub(ctx, st) {+ const pal = st.pal, reg = st.reg ?? 1, seed = st.seed || 3, [X, Y, Wd] = STUB, lx = X + 34;+ if (st.panel > 0) ink(ctx, stubPath(), { color: pal.near, reg: R2(seed + 51, 1.2 * reg), clip: st.panel < 1 ? wipeRegion([X - 30, Y - 20, Wd + 60, STUB[3] + 40], 'down', st.panel, 9, 40) : null, sheen: 1 });+ const lab = pickInk(pal.near, [pal.sky1, pal.glow, pal.sky2, '#C3CADB'], 4.5), val = pickInk(pal.near, [pal.sky1, pal.sun, '#F3EAD8'], 4.5), key = pickInk(pal.near, [pal.sun, pal.sky1], 3);+ const R = st.rows || {};+ const item = (r, fn, color, box, k) => { if (!r || r.p <= 0) return; ink(ctx, { paint: fn }, { color, reg: R2(seed + k * 7, 1.2 * reg), clip: r.p < 1 ? wipeRegion(box, 'right', r.p, 31 + k, 24) : null }); };+ item(R.day, (c) => { c.font = `600 30px ${FONT_T}`; c.letterSpacing = '6px'; c.textAlign = 'left'; c.fillText('DAY', lx, Y + 76); c.font = `800 64px ${FONT_D}`; c.letterSpacing = '1px'; c.fillText(String(R.day.n), lx + 96, Y + 82); }, lab, [X, Y + 10, Wd, 100], 1);+ item(R.big, (c) => {+ c.font = `600 30px ${FONT_T}`; c.letterSpacing = '6px'; c.textAlign = 'left'; c.fillStyle = lab; c.fillText(R.big.label, lx, Y + 186);+ const v = R.big.value + ' KM'; c.fillStyle = key; let fs = 132; c.font = `900 ${fs}px ${FONT_D}`; c.letterSpacing = '2px';+ while (c.measureText(v).width > Wd - 60 && fs > 60) { fs -= 4; c.font = `900 ${fs}px ${FONT_D}`; }+ c.fillText(v, lx - 4, Y + 318); c.fillRect(lx, Y + 344, Wd - 68, 6);+ }, key, [X, Y + 140, Wd, 230], 2);+ item(R.small, (c) => {+ c.font = `600 25px ${FONT_T}`; c.letterSpacing = '4px'; c.textAlign = 'left'; c.fillStyle = lab; c.fillText(R.small.label, lx, Y + 414);+ c.fillStyle = val; c.font = `800 62px ${FONT_D}`; c.letterSpacing = '1px'; c.fillText(R.small.value, lx, Y + 488);+ }, val, [X, Y + 380, Wd, 130], 3);+ if (st.finish !== false && st.panel > 0) { ctx.save(); ctx.clip(stubPath().path); inkFinish(ctx, st.T, X - 30, Y - 20, Wd + 60, STUB[3] + 40, .6, 1); ctx.restore(); }}-export function drawBanner(ctx, content, st) {- const pal = st.pal, T = st.T;- paperSheet(ctx, T, 0, 0, BW, BH);- const sp = st.sky ?? 1;- ctx.save(); ctx.beginPath(); ctx.rect(...BANNER_ART); ctx.clip();- if (sp > 0) {- const clip = sp < 1 ? wipeRegion([0, 0, BW, BH], 'right', sp, 4, 34, 4) : null;- ink(ctx, { path: rectPath(0, 0, BW, BH), knock: ringPath(1590, 300, 118, 132) }, { color: pal.sky1, reg: [0, 0], clip, sheen: 1 });- const top = new Path2D(); top.rect(0, 0, BW, 96);- for (let i = 0; i < 5; i++) { const cell = 22, th = cell * (1 - (i + .5) / 5) * .95 + 1.5; top.rect(0, 96 + i * cell, BW, th); }- ink(ctx, { path: top }, { color: pal.sky2, reg: [1.2, .6], clip, sheen: 1, trap: .35 });- ink(ctx, { path: circlePath(1590, 300, 96) }, { color: pal.sun || pal.sky1, reg: [2, 1], clip, sheen: 1 });- const mt = []; mt.push([-10, 400]); for (let x = 0; x <= BW + 20; x += 20) { const y = 352 - 44 * Math.abs(Math.sin(x * .0035 + 1.3)) - 22 * Math.abs(Math.sin(x * .011)); mt.push([x, y]); } mt.push([BW + 20, 400]);- ink(ctx, { path: polyPath(mt) }, { color: pal.far, reg: [-.8, 1], clip, sheen: 1 });+export function stubBoxes(rows) {+ const [X, Y, Wd] = STUB, out = [];+ if (rows.day) out.push({ id: 'day', text: 'DAY ' + rows.day.n, p: rows.day.p, box: [X + 30, Y + 30, X + 220, Y + 92] });+ if (rows.big) out.push({ id: 'big', text: rows.big.label + ' ' + rows.big.value + ' KM', p: rows.big.p, box: [X + 26, Y + 156, X + Wd - 20, Y + 350], live: rows.big.live });+ if (rows.small) out.push({ id: 'small', text: rows.small.label + ' ' + rows.small.value, p: rows.small.p, box: [X + 30, Y + 390, X + Wd - 20, Y + 496], live: rows.small.live });+ return out;+}++// the end card: a wider ticket printed over the right side in two pulls+export const CARD = [1300, 236, 560, 600];+export function drawEndCard(ctx, pal, T, p1, p2) {+ const [X, Y, Wd, Hd] = CARD;+ if (p1 > 0) {+ const knock = new Path2D(); const ny = Y + 300;+ knock.arc(X, ny, 20, -Math.PI / 2, Math.PI / 2); knock.closePath();+ knock.moveTo(X + Wd, ny - 20); knock.arc(X + Wd, ny, 20, -Math.PI / 2, Math.PI / 2, true); knock.closePath();+ for (let xx = X + 40; xx < X + Wd - 30; xx += 24) { knock.moveTo(xx + 5, ny); knock.arc(xx, ny, 5, 0, Math.PI * 2); }+ ink(ctx, { path: rectPath(X, Y, Wd, Hd), knock }, { color: pal.near, reg: [1, -.6], clip: p1 < 1 ? wipeRegion([X - 30, Y - 20, Wd + 60, Hd + 40], 'down', p1, 5, 40) : null, sheen: 1 });}- ctx.restore();- const tp = st.title ?? 1;- if (tp > 0) {+ if (p2 > 0) {+ const hi = pickInk(pal.near, [pal.sky1, '#F3EAD8'], 4.5), key = pickInk(pal.near, [pal.sun, pal.sky1], 3), lo = pickInk(pal.near, [pal.glow, pal.sky1, '#AEB8CF'], 4.5);ink(ctx, { paint: (c) => {- const T0 = content.title.toUpperCase(); let size = 150, lines = splitTitle(c, T0, FONT_D, size);- if (lines.length === 1) { size = fitFont(c, T0, 900, FONT_D, BW - 200, 170, 60, .02); }- else { c.font = `900 ${size}px ${FONT_D}`; c.letterSpacing = (size * .02) + 'px'; const m = Math.max(...lines.map(l => c.measureText(l).width)); if (m > BW - 200) size = Math.floor(size * (BW - 200) / m); c.font = `900 ${size}px ${FONT_D}`; c.letterSpacing = (size * .02) + 'px'; }- c.textAlign = 'center'; c.textBaseline = 'alphabetic';- if (lines.length === 1) c.fillText(T0, BW / 2, 200 + size * .35);- else { c.fillText(lines[0], BW / 2, 160); c.fillText(lines[1], BW / 2, 160 + size * .98); }- } }, { color: pickInk([pal.sky1, pal.sky2], [pal.near, pal.far], 3), reg: [1.5, -1], clip: tp < 1 ? wipeRegion([0, 20, BW, 330], 'right', tp, 17, 40) : null });- }- const fp = st.footer ?? 1;- if (fp > 0) {- const clip = fp < 1 ? wipeRegion([0, 378, BW, 56], 'right', fp, 19, 30) : null;- ink(ctx, { path: rectPath(14, 382, BW - 28, 44) }, { color: pal.near, reg: [0, 0], clip, sheen: 1 });- ink(ctx, { paint: (c) => { c.font = `600 25px ${FONT_T}`; c.letterSpacing = '9px'; c.textAlign = 'center'; c.fillText(content.footer.toUpperCase(), BW / 2, 413); } }, { color: pickInk(pal.near, [pal.sky1, pal.sun], 4.5), reg: [.8, .6], clip });+ const lx = X + 44; c.textAlign = 'left'; c.textBaseline = 'alphabetic';+ c.fillStyle = key; c.font = `900 96px ${FONT_D}`; c.letterSpacing = '3px'; c.fillText('THE LONG', lx, Y + 116); c.fillText('WAY HOME', lx, Y + 206);+ c.fillStyle = hi; c.font = `600 44px ${FONT_C}`; c.letterSpacing = '8px'; c.fillText('绕远路回家', lx, Y + 268);+ c.fillStyle = lo; c.font = `600 26px ${FONT_T}`; c.letterSpacing = '5px'; c.fillText('SILKSCREEN TRAVEL POSTER', lx, Y + 372);+ c.font = `600 30px ${FONT_C}`; c.letterSpacing = '6px'; c.fillText('丝印旅行海报', lx, Y + 420);+ c.fillStyle = key; c.fillRect(lx, Y + 456, Wd - 88, 5);+ c.fillStyle = hi; c.font = `600 30px ${FONT_T}`; c.letterSpacing = '3px'; c.fillText('LemoLab × Claude Opus 5.5', lx, Y + 520);+ } }, { color: hi, reg: [1.2, .6], clip: p2 < 1 ? wipeRegion([X, Y, Wd, Hd], 'right', p2, 9, 50) : null });}- if (st.finish !== false) inkFinish(ctx, T, 0, 0, BW, BH, .6, 1);+ if (p1 > 0) { ctx.save(); ctx.clip(rectPath(X, Y, Wd, Hd)); inkFinish(ctx, T, X - 30, Y - 20, Wd + 60, Hd + 40, .6, 1); ctx.restore(); }}diff --git a/styles/silkscreen-poster/demo/engine/scenes.js b/styles/silkscreen-poster/demo/engine/scenes.jsindex 0efd109..fdc77ac 100644--- a/styles/silkscreen-poster/demo/engine/scenes.js+++ b/styles/silkscreen-poster/demo/engine/scenes.js@@ -1,219 +1,280 @@-// scenes.js · scenes built into the engine: lake / waterfall / ridge / forest / coast-// Each scene returns its "layers" (planes) in printing order: { id, depth, parts:[{ ink, path, knock?, sub }] }-// ink = palette key (sky1 sky2 far mid near sun), sub = which pull within the same beat (0 main colour, 1 accent colour, half a beat later)-// depth: parallax factor (1 = paper surface; <1 farther; >1 nearer), used only in the "layered parallax" shot-// Also returns trail: the trail polyline [{x,y,plane}], segmented by the layer it lies on; the dashed line is drawn by the poster layer-// Coordinates: poster units, sheet 1000×1500, picture area x 26..974, y 26..1190 (the rest is paper margin and info band)-import { mulberry, polyPath, circlePath, ringPath, rectPath, unionPath, ridgeLine, bandSteps, lerp } from './silk.js';+// scenes.js · the cities of "The Long Way Home", as full-bleed 16:9 prints (1920×1080 u), ink layers in print order.+// A scene = { parts: [{ pull, ink, path, knock?, lit? }] }. `pull` names the squeegee pass that prints the part (one pass may carry+// several parts); `ink` is a palette key: sky1 sky2 far mid near sun glow. Landmarks are stylised silhouettes, not traced from photos.+import { mulberry, polyPath, circlePath, ringPath, rectPath, unionPath, bandSteps, lerp } from './silk.js';-export const PW = 1000, PH = 1500, ART = [26, 26, 948, 1164];+export const AW = 1920, AH = 1080, BLEED = 60;+const FULL = () => rectPath(-BLEED, -BLEED, AW + 2 * BLEED, AH + 2 * BLEED);-// ---- shape building blocks -----function pine(p, x, base, h, w, tiers = 4) { // a stylized pine: tiers of drooping branch layers + a short trunk, one outer outline- const tw = Math.max(3, w * .06), trunkTop = base - h * .1;- const R = [[x, base - h]];- for (let i = 0; i < tiers; i++) {- const t = (i + 1) / tiers;- const yb = base - h * .1 - (h * .9) * (1 - t) * .98; // lower edge of this tier- const hw = w / 2 * (.28 + .72 * t); // half-width: wider further down- R.push([x + hw, yb + h * .012]); // drooping branch tip- if (i < tiers - 1) R.push([x + hw * .42, yb - h * .02]); // pull back in to the start of the next tier+function blob(p, x, y, rx, ry, a0 = 0, a1 = Math.PI * 2) { p.moveTo(x + rx * Math.cos(a0), y + ry * Math.sin(a0)); p.ellipse(x, y, rx, ry, 0, a0, a1); p.closePath(); }+// a cypress crown: overlapping flat-bottomed clumps (one outline, no strokes)+function cypress(p, x, base, h, w, seed) {+ const r = mulberry(seed);+ p.rect(x - w * .035, base - h * .45, w * .07, h * .45 + 30); // trunk+ const n = 7;+ for (let i = 0; i < n; i++) {+ const t = i / (n - 1), cy = base - h * (.35 + .62 * t), cw = w * (.5 - .32 * t) * (.8 + .4 * r()), ch = h * (.13 + .04 * r());+ const cx = x + (r() - .5) * w * .28;+ blob(p, cx, cy, cw, ch);+ if (r() < .7) blob(p, cx + cw * (r() < .5 ? -.7 : .7), cy + ch * .3, cw * .55, ch * .8);}- R.push([x + tw, trunkTop], [x + tw, base + 6]);- const L = R.slice(1).reverse().map(q => [2 * x - q[0], q[1]]);- const pts = R.concat(L);- pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); p.closePath();}-function forest(x0, x1, base, hmin, hmax, seed, dense = 1, bottom = 1500) { // a row of pines + solid base- const p = new Path2D(), r = mulberry(seed);- p.rect(x0 - 40, base, x1 - x0 + 80, bottom - base);- let x = x0 - 20;- while (x < x1 + 30) { const h = lerp(hmin, hmax, r()), w = h * (.34 + r() * .12); pine(p, x, base + 4, h, w, 3 + (r() * 3 | 0)); x += w * (.42 + r() * .35) / dense; }- return p;-}-function range(x0, x1, yBase, peaks, seed, rough = 22) { // mountain-range silhouette: peaks=[[x,y],...]- const pts = [[x0 - 30, yBase], [x0 - 30, peaks[0][1] + 60]];- let prev = [x0 - 30, peaks[0][1] + 60];- for (let i = 0; i < peaks.length; i++) { const seg = ridgeLine(prev, peaks[i], rough, 3, seed + i); pts.push(...seg.slice(1)); prev = peaks[i]; }- const end = [x1 + 30, peaks[peaks.length - 1][1] + 80]; pts.push(...ridgeLine(prev, end, rough, 3, seed + 99).slice(1));- pts.push([x1 + 30, yBase]);- return { path: polyPath(pts), pts };+// a conical eave roof seen from the front: concave slopes, eave tips flaring up+function roof(cx, yBot, wBot, yTop, wTop, flare = 12) {+ const pts = [];+ const k = 8;+ for (let i = 0; i <= k; i++) { const t = i / k, y = lerp(yBot - flare, yTop, t), w = lerp(wBot, wTop, 1 - Math.pow(1 - t, 1.7)); pts.push([cx - w, y]); }+ const R = pts.slice().reverse().map(([x, y]) => [2 * cx - x, y]);+ return polyPath([[cx - wBot + 22, yBot + 4], ...pts, ...R, [cx + wBot - 22, yBot + 4]]);}-// Lit faces: a jagged block running down one side of each peak from the summit (WPA-style two-tone mountains)-function facets(peaks, side, depth, seed, jag = 18) {- const p = new Path2D(), r = mulberry(seed);- for (const [x, y] of peaks) {- const d = depth * (.8 + r() * .5), sx = side * d * .75;- const pts = [[x, y]];- const n = 5;- for (let i = 1; i <= n; i++) { const t = i / n; pts.push([x + sx * t + (r() - .5) * jag, y + d * t]); pts.push([x + sx * t * .45 + side * jag * .3, y + d * t + jag * .5]); }- pts.push([x + side * 4, y + d * 1.05]);- pts.forEach((q, i) => i ? p.lineTo(q[0], q[1]) : p.moveTo(q[0], q[1])); p.closePath();- }- return p;+function roofLit(cx, yBot, wBot, yTop, wTop, flare = 12) { // the left (sun-facing) half, a jagged-edged lit face+ const pts = [[cx - wBot + 22, yBot + 4]], k = 8;+ for (let i = 0; i <= k; i++) { const t = i / k, y = lerp(yBot - flare, yTop, t), w = lerp(wBot, wTop, 1 - Math.pow(1 - t, 1.7)); pts.push([cx - w, y]); }+ pts.push([cx - wTop * .2, yTop + 2], [cx - wBot * .32, yBot - (yBot - yTop) * .35], [cx - wBot * .42, yBot + 4]);+ return polyPath(pts);}-function sunParts(x, y, r, rings = 1) {- const knock = new Path2D(); knock.addPath(circlePath(x, y, r + 5));- for (let i = 0; i < rings; i++) knock.addPath(ringPath(x, y, r + 22 + i * 30, r + 32 + i * 30));- return { knock, disc: circlePath(x, y, r) };-}-function skyPlane(sunKnock, bandTop, bandBot, extraTop = 0) {- const flood = rectPath(-60, -60 - extraTop, PW + 120, 1700 + extraTop);- const top = new Path2D(); top.rect(-60, -60 - extraTop, PW + 120, bandTop + 60 + extraTop); top.addPath(bandSteps(-60, PW + 120, bandTop, bandBot, 5, 10));- return { id: 'sky', depth: .15, parts: [{ ink: 'sky1', path: flood, knock: sunKnock, sub: 0 }, { ink: 'sky2', path: top, sub: 1 }] };++// ================= BEIJING · Temple of Heaven, Hall of Prayer for Good Harvests (dawn) =================+export function temple(seed = 3) {+ const CX = 820, SUN = [1240, 452], SR = 86;+ // sky+ const sunKnock = unionPath([circlePath(SUN[0], SUN[1], SR + 9), ringPath(SUN[0], SUN[1], SR + 30, SR + 40), ringPath(SUN[0], SUN[1], SR + 64, SR + 71)]);+ const sky2 = new Path2D(); sky2.rect(-BLEED, -BLEED, AW + 2 * BLEED, 170 + BLEED); sky2.addPath(bandSteps(-BLEED, AW + 2 * BLEED, 150, 470, 6, 14));+ // hall + terraces (their silhouette is knocked out of the woods and the ground, so the marble stays bare paper)+ const T1 = [CX - 480, 806, 960, 50], T2 = [CX - 396, 766, 792, 40], T3 = [CX - 312, 728, 624, 38];+ const terr = unionPath([rectPath(...T1), rectPath(...T2), rectPath(...T3)]);+ const R1 = [CX, 642, 300, 594, 178], R2 = [CX, 556, 252, 512, 142], R3 = [CX, 476, 212, 416, 34];+ const roofs = unionPath([roof(...R1), roof(...R2), roof(...R3, 10)]);+ const drums = unionPath([rectPath(CX - 202, 652, 404, 76), rectPath(CX - 166, 566, 332, 28), rectPath(CX - 130, 486, 260, 26)]);+ const finial = unionPath([circlePath(CX, 384, 14), rectPath(CX - 5, 398, 10, 10), polyPath([[CX - 12, 408], [CX + 12, 408], [CX + 22, 416], [CX - 22, 416]])]);+ const hallSil = unionPath([roofs, drums, finial]);+ const sil = unionPath([terr, hallSil]);+ // far: the old cypress woods and the round enclosure wall behind the hall+ const far = new Path2D();+ { const r = mulberry(seed + 4); far.rect(-BLEED, 690, AW + 2 * BLEED, 500);+ for (let x = -BLEED; x < AW + BLEED; x += 46 + r() * 40) blob(far, x, 690 - r() * 34, 40 + r() * 46, 28 + r() * 26); }+ const wall = rectPath(-BLEED, 744, AW + 2 * BLEED, 26); // enclosure wall: a lighter band (glow) across the woods+ // mid: the blue tiled roofs; under-eave shadows; the terrace shadows and stair treads+ const eaves = unionPath([rectPath(CX - 262, 642, 524, 12), rectPath(CX - 216, 556, 432, 10), rectPath(CX - 178, 476, 356, 10)]);+ const terrShade = unionPath([rectPath(T1[0], T1[1], T1[2], 9), rectPath(T2[0], T2[1], T2[2], 8), rectPath(T3[0], T3[1], T3[2], 8),+ ...[0, 1, 2].map(i => { const t = [T1, T2, T3][i]; const post = new Path2D(); for (let x = t[0] + 14; x < t[0] + t[2] - 8; x += 26) post.rect(x, t[1] - 13, 6, 13); return post; })]);+ const stair = new Path2D(); for (let y = 732; y < 852; y += 10) stair.rect(CX - 62, y, 124, 3.5);+ // near: ground with the raised walkway knocked out (paper), the big cypresses, the doors in the drums, birds+ const ground = polyPath([[-BLEED, 856], [AW + BLEED, 856], [AW + BLEED, AH + BLEED], [-BLEED, AH + BLEED]]);+ const walk = polyPath([[CX - 120, 856], [CX + 120, 856], [CX + 360, AH + BLEED], [CX - 360, AH + BLEED]]);+ const walkLines = new Path2D(); for (let i = 1; i < 7; i++) { const y = 856 + Math.pow(i / 7, 1.6) * 260; const w = lerp(120, 360, (y - 856) / (AH + BLEED - 856)); walkLines.rect(CX - w, y, 2 * w, 3 + i); }+ const trees = new Path2D();+ cypress(trees, 150, 1100, 660, 470, seed + 11); cypress(trees, 400, 1110, 470, 330, seed + 12); cypress(trees, -40, 1100, 800, 380, seed + 13);+ cypress(trees, 1350, 1110, 470, 330, seed + 14); cypress(trees, 1560, 1110, 640, 460, seed + 15); cypress(trees, 1860, 1100, 820, 520, seed + 16);+ const doors = new Path2D(); for (let i = -3; i <= 3; i++) doors.rect(CX + i * 52 - 9, 664, 18, 58);+ for (let i = -2; i <= 2; i++) doors.rect(CX + i * 56 - 7, 570, 14, 20);+ for (let i = -2; i <= 2; i++) doors.rect(CX + i * 44 - 6, 490, 12, 18);+ const birds = new Path2D();+ for (const [x, y, s] of [[560, 300, 1], [612, 270, .8], [520, 252, .65], [1010, 330, .7]]) birds.addPath(polyPath([[x - 24 * s, y - 6 * s], [x - 11 * s, y - 10 * s], [x, y], [x + 11 * s, y - 10 * s], [x + 24 * s, y - 6 * s], [x + 11 * s, y - 5 * s], [x, y + 5 * s], [x - 11 * s, y - 5 * s]]));+ // lit faces: the sun side of each roof (glow), the cypress tops (mid)+ const lit = unionPath([roofLit(...R1), roofLit(...R2), roofLit(...R3, 10)]);+ const crownsLit = new Path2D(); { const r = mulberry(seed + 21); for (const [x, base, h, w] of [[150, 1100, 760, 560], [380, 1110, 520, 360], [1560, 1110, 640, 460], [1860, 1100, 820, 520]]) for (let i = 0; i < 4; i++) { const t = (i + 1) / 6, cy = base - h * (.35 + .62 * t) - h * .05, cw = w * (.5 - .32 * t) * .55; blob(crownsLit, x - cw * .4 + (r() - .5) * 20, cy, cw, h * .045, Math.PI, Math.PI * 2); } }+ return {+ sun: SUN, focus: [CX, 600], header: { x: 104, y: 214, size: 150 },+ depth: { sun: .1, sky1: 0, sky2: 0, far: .3, mid: .6, near: .9, acc: .6, lit: .6 },+ parts: [+ { pull: 'sun', ink: 'sun', path: circlePath(SUN[0], SUN[1], SR) },+ { pull: 'sky1', ink: 'sky1', path: FULL(), knock: sunKnock, cut: unionPath([terr, walk]) },+ { pull: 'sky2', ink: 'sky2', path: sky2 },+ { pull: 'far', ink: 'far', path: far, cut: unionPath([sil, walk]) },+ { pull: 'mid', ink: 'mid', path: unionPath([roofs, eaves]) },+ { pull: 'mid', ink: 'far', path: unionPath([terrShade, stair]), lit: 1 },+ { pull: 'near', ink: 'mid', path: ground, cut: unionPath([walk, sil]) },+ { pull: 'near', ink: 'near', path: unionPath([trees, doors, birds]) },+ { pull: 'near', ink: 'far', path: walkLines, lit: 1 },+ { pull: 'acc', ink: 'sun', path: unionPath([drums, finial]), knock: doors },+ { pull: 'lit', ink: 'glow', path: lit, lit: 1 },+ ],+ };}-function wavesPath(x0, x1, y0, y1, n, seed, len = 60) { // water reflections: short horizontal dashes++// ---------------- shared helpers for the other cities ----------------+function halfDome(p, cx, cy, rx, ry) { p.moveTo(cx - rx, cy); p.ellipse(cx, cy, rx, ry, 0, Math.PI, Math.PI * 2); p.closePath(); }+function waterBars(x0, x1, y0, y1, n, seed, len = 220) {const p = new Path2D(), r = mulberry(seed);- for (let i = 0; i < n; i++) { const y = lerp(y0, y1, Math.pow(r(), 1.3)), l = len * (.4 + r()) * (.4 + (y - y0) / (y1 - y0)), x = lerp(x0, x1, r()), th = 2.5 + (y - y0) / (y1 - y0) * 5; p.rect(x, y, l, th); }+ for (let i = 0; i < n; i++) {+ const k = i / n, y = y0 + (y1 - y0) * Math.pow(k, 1.5), th = 2.5 + 16 * Math.pow(k, 1.4);+ let x = x0 + r() * 80;+ while (x < x1) { const L = len * (.5 + r()), g = 30 + r() * 90 * (.4 + k); p.rect(x, y, L, th); x += L + g; }+ }return p;}--// ================= LAKE =================-function lake(seed) {- const sun = sunParts(640, 575, 92, 2);- const peaks = [[120, 430], [300, 360], [470, 455], [610, 400], [800, 470], [930, 420]];- const R = range(0, PW, 760, peaks, seed + 3, 26);- const lakeTop = 660;- const shore = forest(-40, 1040, 668, 26, 58, seed + 5, 1.3, 700);- const lakeP = rectPath(-60, lakeTop, PW + 120, 900);- const glints = new Path2D();- for (let i = 0; i < 12; i++) { const y = 690 + i * 22 + i * i * 1.6, w = 170 - i * 9 + (i % 3) * 18; glints.rect(640 - w / 2 + ((i * 37) % 23) - 11, y, w, 4 + i * .7); }- const refl = wavesPath(40, 900, 700, 1000, 22, seed + 7, 70);- // near layer: big pine on the left + pine on the right + shore rocks in the foreground- const near = new Path2D();- pine(near, 110, 1250, 1080, 330, 7); pine(near, 250, 1260, 760, 250, 6); pine(near, -20, 1250, 900, 300, 6);- pine(near, 905, 1250, 820, 270, 6); pine(near, 1010, 1250, 1000, 300, 7);- near.addPath(polyPath([[-60, 1030], [140, 1000], [300, 1022], [420, 1060], [560, 1045], [720, 1070], [860, 1020], [1060, 1000], [1060, 1600], [-60, 1600]]));- near.addPath(polyPath([[560, 1045], [610, 990], [690, 975], [760, 1010], [790, 1060]])); // big shore rock- const rockLit = polyPath([[610, 990], [690, 975], [705, 1000], [640, 1012]]);- const trail = [[500, 1200], [470, 1150], [520, 1110], [640, 1090], [780, 1100], [880, 1080], [990, 1060]].map(q => ({ x: q[0], y: q[1], plane: 'near' }));- return {- planes: [- skyPlane(sun.knock, 150, 360),- { id: 'sun', depth: .15, parts: [{ ink: 'sun', path: sun.disc, sub: 0 }] },- { id: 'far', depth: .35, parts: [{ ink: 'far', path: R.path, sub: 0 }, { ink: 'sky2', path: facets(peaks, 1, 110, seed + 11, 14), sub: 1 }] },- { id: 'mid', depth: .7, parts: [{ ink: 'sky2', path: lakeP, sub: 0 }, { ink: 'sun', path: glints, sub: 1 }, { ink: 'sky1', path: refl, sub: 1 }, { ink: 'mid', path: shore, sub: 0 }] },- { id: 'near', depth: 1.5, parts: [{ ink: 'near', path: near, sub: 0 }, { ink: 'mid', path: rockLit, sub: 1 }] },- ], trail, sun: [640, 575],- };+const bird = (p, x, y, s) => p.addPath(polyPath([[x - 24 * s, y - 6 * s], [x - 11 * s, y - 10 * s], [x, y], [x + 11 * s, y - 10 * s], [x + 24 * s, y - 6 * s], [x + 11 * s, y - 5 * s], [x, y + 5 * s], [x - 11 * s, y - 5 * s]]));+function sunParts(x, y, r) {+ return { disc: circlePath(x, y, r), knock: unionPath([circlePath(x, y, r + 9), ringPath(x, y, r + 28, r + 37), ringPath(x, y, r + 58, r + 64)]) };}-// ================= WATERFALL =================-function waterfall(seed) {- const sun = sunParts(810, 190, 52, 1);- const peaks = [[90, 330], [260, 280], [430, 350], [640, 300], [860, 360]];- const R = range(0, PW, 700, peaks, seed + 3, 20);- // cliffs: left and right blocks + back wall, water pouring out of a V notch in the middle; rock faces use three large facets (WPA-style faceted rock)- const cliff = polyPath([[-60, 430], [120, 398], [260, 412], [380, 440], [452, 478], [470, 520], [530, 520], [550, 476], [640, 452], [780, 424], [900, 440], [1060, 420], [1060, 1300], [-60, 1300]]);- const fall = polyPath([[470, 516], [530, 516], [538, 600], [552, 760], [578, 950], [422, 950], [448, 760], [462, 600]]);- const shadows = unionPath([- polyPath([[-60, 440], [120, 398], [70, 520], [130, 640], [60, 780], [140, 920], [80, 1000], [-60, 1000]]),- polyPath([[1060, 420], [900, 440], [950, 560], [880, 700], [960, 840], [900, 1000], [1060, 1000]]),- polyPath([[380, 441], [452, 478], [463, 600], [449, 760], [423, 950], [352, 950], [392, 770], [404, 600], [370, 520]]),- polyPath([[550, 476], [640, 453], [612, 540], [602, 700], [622, 850], [646, 950], [578, 950], [552, 760], [538, 600]])]);- const lit = new Path2D(); lit.addPath(polyPath([[120, 398], [260, 412], [380, 440], [452, 478], [456, 492], [380, 456], [260, 424], [124, 410]])); lit.addPath(polyPath([[550, 476], [640, 452], [780, 424], [900, 440], [900, 452], [780, 437], [640, 465], [552, 490]]));- const streaks = new Path2D(); for (let i = 0; i < 5; i++) { const x0 = 480 + i * 10, x1 = 452 + i * 24; streaks.addPath(polyPath([[x0, 560 + i * 20], [x0 + 3, 560 + i * 20], [x1 + 4, 940], [x1, 940]])); }- const topForest = unionPath([forest(-40, 230, 418, 40, 84, seed + 6, .8, 424), forest(700, 1040, 448, 40, 88, seed + 7, .8, 452)]);- const pool = new Path2D(); pool.ellipse(500, 985, 250, 48, 0, 0, Math.PI * 2);- const foam = new Path2D();- for (let i = 0; i < 2; i++) { const rx = 150 + i * 70, y = 978 + i * 18; foam.moveTo(500 - rx, y); foam.quadraticCurveTo(500, y + 10, 500 + rx, y); foam.quadraticCurveTo(500, y + 16, 500 - rx, y); foam.closePath(); }- foam.addPath(polyPath([[422, 950], [578, 950], [600, 968], [400, 968]]));- const slopeForest = unionPath([forest(-40, 300, 1010, 90, 170, seed + 8, .8, 1300), forest(700, 1040, 1000, 90, 180, seed + 9, .8, 1300)]);- const near = new Path2D();- pine(near, 40, 1260, 1000, 300, 7); pine(near, 180, 1270, 620, 210, 5);- pine(near, 920, 1260, 1060, 320, 8); pine(near, 1040, 1260, 820, 260, 6);- near.addPath(polyPath([[-60, 1080], [200, 1060], [330, 1110], [520, 1120], [700, 1100], [880, 1070], [1060, 1090], [1060, 1600], [-60, 1600]]));- const ferns = new Path2D(); for (let i = 0; i < 9; i++) { const x = 250 + i * 64, y = 1112 - (i % 3) * 6; ferns.addPath(polyPath([[x, y], [x + 22, y - 44 - (i % 2) * 18], [x + 32, y - 40], [x + 16, y]])); }- const trail = [[330, 1200], [360, 1150], [300, 1120], [360, 1090], [440, 1080]].map(q => ({ x: q[0], y: q[1], plane: 'near' }));+// ================= ISTANBUL · Hagia Sophia across the water (afternoon) =================+export function istanbul(seed = 7) {+ const CX = 860, W0 = AW, H0 = AH, SUN = sunParts(1270, 300, 66);+ const sky2 = new Path2D(); sky2.rect(-BLEED, -BLEED, W0 + 2 * BLEED, 140 + BLEED); sky2.addPath(bandSteps(-BLEED, W0 + 2 * BLEED, 120, 400, 6, 10));+ // far: the opposite shore, low hills with tiny domes, and the water bars below+ const hills = polyPath([[-BLEED, 650], [-BLEED, 600], [180, 584], [420, 596], [640, 572], [900, 590], [1180, 566], [1460, 588], [1700, 574], [W0 + BLEED, 590], [W0 + BLEED, 650]]);+ const farBits = new Path2D(); halfDome(farBits, 1250, 568, 26, 18); farBits.rect(1290, 520, 7, 50); halfDome(farBits, 1560, 578, 20, 14); farBits.rect(1520, 536, 6, 44);+ const water = waterBars(-BLEED, W0 + BLEED, 760, 1100, 12, seed + 3);+ // mid: the building mass (rose stone) and the four minaret shafts+ const body = unionPath([rectPath(CX - 300, 556, 600, 150), rectPath(CX - 430, 616, 130, 90), rectPath(CX + 300, 616, 130, 90),+ rectPath(CX - 266, 470, 70, 88), rectPath(CX + 196, 470, 70, 88), rectPath(CX - 172, 420, 344, 52)]);+ const mins = new Path2D();+ for (const [x, top] of [[CX - 520, 250], [CX - 450, 300], [CX + 450, 300], [CX + 520, 250]]) {+ mins.rect(x - 11, top, 22, 706 - top); mins.rect(x - 17, top + 90, 34, 10); mins.rect(x - 17, top + 220, 34, 10);+ mins.addPath(polyPath([[x - 13, top + 2], [x, top - 70], [x + 13, top + 2]]));+ }+ // near: domes, windows, the quay, a ferry, gulls+ const domes = new Path2D(); halfDome(domes, CX, 424, 196, 128); halfDome(domes, CX - 212, 558, 112, 70); halfDome(domes, CX + 212, 558, 112, 70);+ halfDome(domes, CX - 366, 618, 62, 40); halfDome(domes, CX + 366, 618, 62, 40);+ const win = new Path2D();+ for (let i = -6; i <= 6; i++) win.rect(CX + i * 24 - 6, 434, 12, 26);+ for (let i = -5; i <= 5; i++) win.rect(CX + i * 46 - 9, 600, 18, 34);+ for (let i = -5; i <= 5; i++) win.rect(CX + i * 46 - 8, 652, 16, 30);+ const quay = rectPath(-BLEED, 704, W0 + 2 * BLEED, 52);+ const ferry = new Path2D(); ferry.addPath(polyPath([[150, 892], [520, 892], [490, 940], [190, 940]])); ferry.rect(230, 852, 220, 42); ferry.rect(300, 818, 60, 36); ferry.rect(318, 790, 22, 30);+ const ferryWin = new Path2D(); for (let i = 0; i < 7; i++) ferryWin.rect(244 + i * 29, 862, 16, 16);+ const birds = new Path2D(); bird(birds, 1180, 360, .9); bird(birds, 1240, 320, .7); bird(birds, 1120, 300, .6); bird(birds, 640, 820, .8);+ // lit faces (sun from the right): right halves of the domes, the right side of each minaret+ const lit = new Path2D();+ for (const [cx, cy, rx, ry] of [[CX, 424, 196, 128], [CX - 212, 558, 112, 70], [CX + 212, 558, 112, 70], [CX + 366, 618, 62, 40]]) { lit.moveTo(cx + rx * .15, cy); lit.ellipse(cx, cy, rx, ry, 0, -Math.PI * .42, 0); lit.lineTo(cx + rx * .15, cy); lit.closePath(); }+ const finials = new Path2D(); for (const [x, top] of [[CX - 520, 250], [CX - 450, 300], [CX + 450, 300], [CX + 520, 250]]) finials.addPath(circlePath(x, top - 76, 6)); finials.addPath(circlePath(CX, 288, 8));return {- planes: [- skyPlane(sun.knock, 110, 270),- { id: 'sun', depth: .15, parts: [{ ink: 'sun', path: sun.disc, sub: 0 }] },- { id: 'far', depth: .35, parts: [{ ink: 'sky2', path: R.path, sub: 0 }, { ink: 'sky1', path: facets(peaks, -1, 70, seed + 12, 10), sub: 1 }] },- { id: 'mid', depth: .7, parts: [{ ink: 'far', path: cliff, knock: fall, sub: 0 }, { ink: 'near', path: shadows, sub: 1 }, { ink: 'sky1', path: lit, sub: 1 }, { ink: 'sky1', path: streaks, sub: 1 }, { ink: 'sky2', path: pool, knock: foam, sub: 0 }, { ink: 'near', path: topForest, sub: 0 }, { ink: 'mid', path: slopeForest, sub: 0 }] },- { id: 'near', depth: 1.5, parts: [{ ink: 'near', path: near, sub: 0 }, { ink: 'mid', path: ferns, sub: 1 }] },- ], trail, dark: [920, 700],+ w: W0, h: H0, header: { x: 104, y: 214, size: 150 },+ depth: { sky: 0, far: .25, mid: .55, near: .85, acc: .55, lit: .55 },+ parts: [+ { pull: 'sky', ink: 'sky1', path: rectPath(-BLEED, -BLEED, W0 + 2 * BLEED, H0 + 2 * BLEED), knock: SUN.knock },+ { pull: 'sky', ink: 'sky2', path: sky2 },+ { pull: 'far', ink: 'far', path: unionPath([hills, farBits]) },+ { pull: 'far', ink: 'far', path: water, lit: 1 },+ { pull: 'mid', ink: 'mid', path: unionPath([body, mins]) },+ { pull: 'near', ink: 'near', path: unionPath([domes, win, quay, ferry, birds]), cut: ferryWin },+ { pull: 'acc', ink: 'sun', path: unionPath([SUN.disc, finials]) },+ { pull: 'lit', ink: 'glow', path: lit, lit: 1 },+ ],};}-// ================= RIDGE (deep, many layers, used for the signature shot) =================-function ridge(seed) {- const sun = sunParts(735, 400, 105, 2);- const farPeaks = [[80, 400], [250, 350], [420, 420], [900, 390]];- const FR = range(0, PW, 800, farPeaks, seed + 2, 18);- const summit = [470, 250];- const main = polyPath([[-60, 620], [90, 540], [200, 470], [300, 380], [380, 330], summit, [520, 285], [560, 300], [610, 350], [680, 395], [760, 470], [860, 520], [1060, 600], [1060, 1600], [-60, 1600]]);- const mainLit = polyPath([summit, [520, 285], [560, 300], [610, 350], [680, 395], [760, 470], [860, 520], [1060, 600], [1060, 660], [820, 610], [700, 540], [600, 470], [540, 400], [490, 320]]);- const rim = polyPath([[380, 330], summit, [520, 285], [560, 300], [556, 309], [518, 296], [472, 262], [384, 339]]);- const spurA = polyPath([[-60, 700], [80, 640], [200, 600], [300, 590], [420, 630], [540, 690], [650, 760], [700, 800], [700, 1600], [-60, 1600]]);- const spurALit = polyPath([[200, 600], [300, 590], [420, 630], [540, 690], [650, 760], [560, 745], [440, 690], [330, 640]]);- const spurB = polyPath([[1060, 760], [930, 720], [820, 700], [700, 730], [600, 790], [500, 870], [460, 920], [460, 1600], [1060, 1600]]);- const spurBLit = polyPath([[820, 700], [700, 730], [600, 790], [500, 870], [560, 850], [660, 790], [760, 750]]);- const spurC = polyPath([[-60, 900], [60, 860], [180, 850], [300, 880], [420, 950], [520, 1010], [560, 1060], [560, 1600], [-60, 1600]]);- const spurCLit = polyPath([[60, 860], [180, 850], [300, 880], [420, 950], [340, 935], [200, 890]]);- const valley = forest(-60, 1060, 1060, 60, 130, seed + 8, 1.2, 1700);- const near = new Path2D(); pine(near, 60, 1300, 820, 260, 7); pine(near, -40, 1300, 1000, 300, 7); pine(near, 950, 1300, 760, 250, 6); pine(near, 1050, 1300, 980, 300, 7);- near.addPath(valley);- // trail: zigzags from the valley floor to the summit, segmented by layer- const T = [[500, 1200, 'near'], [470, 1130, 'near'], [520, 1060, 'near'], [440, 1020, 'spurC'], [360, 960, 'spurC'], [470, 930, 'spurB'], [560, 860, 'spurB'], [640, 800, 'spurB'], [560, 760, 'spurA'], [430, 700, 'spurA'], [330, 650, 'spurA'], [380, 610, 'main'], [440, 540, 'main'], [400, 470, 'main'], [455, 400, 'main'], [430, 330, 'main'], summit.concat('main')];- const trail = T.map(q => ({ x: q[0], y: q[1], plane: q[2] }));+// ================= PARIS · the Eiffel Tower (morning), a tall print for a crane move =================+export function paris(seed = 9) {+ const W0 = AW, H0 = 1620, CX = 960, BASE = 1560, SUN = sunParts(520, 600, 72);+ const sky2 = new Path2D(); sky2.rect(-BLEED, -BLEED, W0 + 2 * BLEED, 240 + BLEED); sky2.addPath(bandSteps(-BLEED, W0 + 2 * BLEED, 220, 720, 7, 12));+ // the tower: one outline, then its openings knocked out to whatever is behind+ const prof = [[420, BASE], [330, 1430], [232, 1330], [226, 1292], [150, 1150], [104, 1022], [118, 1004], [70, 860], [42, 680], [26, 470], [30, 452], [18, 400], [12, 330], [3, 250], [2, 130]];+ const tower = polyPath([...prof.map(([x, y]) => [CX - x, y]), ...prof.slice().reverse().map(([x, y]) => [CX + x, y])]);+ const open = new Path2D();+ open.moveTo(CX - 262, BASE + 2); open.ellipse(CX, BASE + 2, 262, 228, 0, Math.PI, Math.PI * 2); open.closePath(); // the big arch+ open.addPath(polyPath([[CX - 150, 1286], [CX + 150, 1286], [CX + 56, 1030], [CX - 56, 1030]]));+ open.addPath(polyPath([[CX - 34, 996], [CX + 34, 996], [CX + 12, 600], [CX - 12, 600]]));+ for (let k = 0; k < 6; k++) { // lattice: diamonds down each leg+ const y = 1060 + k * 40, w = lerp(108, 205, k / 5);+ for (const s of [-1, 1]) { const x = CX + s * (w - 22); open.addPath(polyPath([[x, y - 14], [x + 9, y], [x, y + 14], [x - 9, y]])); }+ }+ // far: distant roofs and chimneys; mid: nearer mansard blocks left and right+ const far = new Path2D(); { const r = mulberry(seed + 2); far.rect(-BLEED, 1400, W0 + 2 * BLEED, 300); for (let x = -BLEED; x < W0 + BLEED; x += 70 + r() * 70) { far.rect(x, 1370 - r() * 50, 50 + r() * 60, 80); far.rect(x + 10, 1340 - r() * 50, 10, 40); } }+ const mid = new Path2D();+ for (const [x0, x1, top] of [[-BLEED, 560, 1300], [1380, W0 + BLEED, 1320]]) {+ mid.addPath(polyPath([[x0, top + 50], [x0 + 30, top], [x1 - 30, top], [x1, top + 50], [x1, H0 + BLEED], [x0, H0 + BLEED]]));+ for (let x = x0 + 60; x < x1 - 40; x += 120) mid.rect(x, top - 34, 24, 36);+ }+ const midWin = new Path2D(); for (const [x0, x1, top] of [[-BLEED, 560, 1300], [1380, W0 + BLEED, 1320]]) for (let x = x0 + 40; x < x1 - 40; x += 70) { midWin.rect(x, top + 20, 24, 22); midWin.rect(x, top + 100, 24, 40); midWin.rect(x, top + 190, 24, 40); }+ const awn = new Path2D(); for (const [x0, x1, top] of [[-BLEED, 560, 1300], [1380, W0 + BLEED, 1320]]) for (let x = x0 + 34; x < x1 - 40; x += 140) awn.addPath(polyPath([[x, top + 262], [x + 40, top + 262], [x + 46, top + 286], [x - 6, top + 286]]));+ // near: the tower, park trees at its foot, lamp posts, birds+ const trees = new Path2D(); { const r = mulberry(seed + 5); for (let x = 520; x < 1420; x += 60 + r() * 40) { const rr = 40 + r() * 30; trees.moveTo(x + rr, 1530); trees.ellipse(x, 1530, rr, rr * .8, 0, 0, Math.PI * 2); trees.closePath(); } trees.rect(500, 1540, 940, 200); }+ const birds = new Path2D(); bird(birds, 1240, 520, .9); bird(birds, 1300, 480, .7); bird(birds, 1190, 456, .6);+ // lit face: the left (sunward) edge of the tower+ const litProf = prof.map(([x, y]) => [CX - x, y]), litIn = prof.map(([x, y]) => [CX - x * .62, y]).reverse();+ const lit = polyPath([...litProf, ...litIn]);return {- planes: [- skyPlane(sun.knock, 120, 300, 200),- { id: 'sun', depth: .1, parts: [{ ink: 'sun', path: sun.disc, sub: 0 }] },- { id: 'far', depth: .25, parts: [{ ink: 'far', path: FR.path, sub: 0 }] },- { id: 'main', depth: .5, parts: [{ ink: 'mid', path: main, sub: 0 }, { ink: 'far', path: mainLit, sub: 1 }, { ink: 'glow', path: rim, sub: 1 }] },- { id: 'spurA', depth: .8, side: -1, parts: [{ ink: 'far', path: spurA, sub: 0 }, { ink: 'glow', path: spurALit, sub: 1 }] },- { id: 'spurB', depth: 1.05, side: 1, parts: [{ ink: 'mid', path: spurB, sub: 0 }, { ink: 'far', path: spurBLit, sub: 1 }] },- { id: 'spurC', depth: 1.3, side: -1, parts: [{ ink: 'far', path: spurC, sub: 0 }, { ink: 'glow', path: spurCLit, sub: 1 }] },- { id: 'near', depth: 1.9, parts: [{ ink: 'near', path: near, sub: 0 }] },- ], trail, summit, sun: [735, 400],+ w: W0, h: H0, header: { x: 104, y: 900, size: 150 },+ depth: { sky: 0, far: .25, mid: .55, near: 1, acc: .4, lit: 1 },+ parts: [+ { pull: 'sky', ink: 'sky1', path: rectPath(-BLEED, -BLEED, W0 + 2 * BLEED, H0 + 2 * BLEED), knock: SUN.knock },+ { pull: 'sky', ink: 'sky2', path: sky2 },+ { pull: 'far', ink: 'far', path: far },+ { pull: 'mid', ink: 'mid', path: mid },+ { pull: 'mid', ink: 'glow', path: midWin, lit: 1 },+ { pull: 'near', ink: 'near', path: tower, knock: open },+ { pull: 'near', ink: 'near', path: unionPath([trees, birds]) },+ { pull: 'acc', ink: 'sun', path: unionPath([SUN.disc, awn]) },+ { pull: 'lit', ink: 'glow', path: lit, cut: open, lit: 1 },+ ],};}-// ================= FOREST =================-function forestScene(seed) {- const sun = sunParts(300, 300, 70, 1);- const peaks = [[150, 420], [420, 380], [700, 430], [900, 400]];- const R = range(0, PW, 800, peaks, seed + 3, 18);- const back = forest(-40, 1040, 640, 80, 170, seed + 4, 1, 900);- const midF = forest(-40, 1040, 820, 150, 300, seed + 5, .9, 1300);- const near = new Path2D(); for (let i = 0; i < 6; i++) { const x = [-10, 150, 330, 690, 850, 1000][i], top = 190 + (i % 3) * 40; near.addPath(polyPath([[x - 20 - i % 2 * 8, top + 120], [x + 20 + i % 2 * 8, top + 120], [x + 30, 1300], [x - 30, 1300]])); pine(near, x, top + 260, 300, 150 + (i % 2) * 40, 4); }- near.addPath(polyPath([[-60, 1060], [300, 1040], [700, 1070], [1060, 1040], [1060, 1600], [-60, 1600]]));- const shafts = new Path2D(); for (let i = 0; i < 4; i++) { const x = 380 + i * 90; shafts.addPath(polyPath([[x, 700], [x + 30, 700], [x + 120, 1060], [x + 60, 1060]])); }- const trail = [[500, 1200], [540, 1130], [480, 1080], [520, 1050]].map(q => ({ x: q[0], y: q[1], plane: 'near' }));+// ================= BUENOS AIRES · La Boca houses and the Obelisco (bright noon), a wide print for a truck =================+export const BOCA_INKS = ['#D9483B', '#F2B63D', '#2F86B5', '#4E9C5E', '#E07B4A', '#8E5BA6'];+export function boca(seed = 13) {+ const W0 = 2600, H0 = AH, SUN = sunParts(2280, 230, 56), OB = 1300;+ const sky2 = new Path2D(); sky2.rect(-BLEED, -BLEED, W0 + 2 * BLEED, 120 + BLEED); sky2.addPath(bandSteps(-BLEED, W0 + 2 * BLEED, 100, 380, 6, 10));+ // the Obelisco is bare paper (knocked out of the sky inks), with its shade side in far ink+ const obel = polyPath([[OB - 34, 640], [OB - 26, 190], [OB, 130], [OB + 26, 190], [OB + 34, 640]]);+ const obShade = polyPath([[OB + 2, 640], [OB + 2, 140], [OB + 26, 190], [OB + 34, 640]]);+ const city = new Path2D(); { const r = mulberry(seed + 2); city.rect(-BLEED, 600, W0 + 2 * BLEED, 500); for (let x = -BLEED; x < W0 + BLEED; x += 80 + r() * 90) city.rect(x, 520 + r() * 60, 60 + r() * 70, 120); }+ // the houses: one silhouette, coloured by a split-fountain bead (segments along x)+ const houses = new Path2D(), r = mulberry(seed + 4), H = [], segs = [];+ let x = -BLEED, k = 0;+ while (x < W0 + BLEED) {+ const w = 170 + r() * 120, top = 470 + r() * 110; H.push([x, w, top]);+ houses.addPath(polyPath([[x, top + 26], [x + w * .5, top - 6], [x + w, top + 26], [x + w, H0 + BLEED], [x, H0 + BLEED]]));+ segs.push({ x0: x, x1: x + w, color: BOCA_INKS[(k * 3 + (k >> 1)) % BOCA_INKS.length] });+ x += w; k++;+ }+ // near: roof caps, corrugation, windows and doors, balconies, laundry, the street, a lamp post+ const det = new Path2D(), win = new Path2D();+ for (const [hx, w, top] of H) {+ det.addPath(polyPath([[hx - 8, top + 30], [hx + w * .5, top - 10], [hx + w + 8, top + 30], [hx + w + 8, top + 40], [hx + w * .5, top + 4], [hx - 8, top + 40]]));+ for (let y = top + 70; y < 1000; y += 16) det.rect(hx + 6, y, w - 12, 3);+ for (let c = 0; c < 2; c++) { win.rect(hx + w * (.2 + .42 * c), top + 120, w * .2, 70); win.rect(hx + w * (.2 + .42 * c), top + 300, w * .2, 110); }+ det.rect(hx + 4, top + 210, w - 8, 10); // balcony slab+ for (let b = 0; b < 8; b++) det.rect(hx + 8 + b * (w - 16) / 7, top + 220, 4, 34);+ det.rect(hx + w * .4, 1000 - 150, w * .2, 150); // door+ }+ det.rect(-BLEED, 1000, W0 + 2 * BLEED, 120);+ det.rect(1880, 560, 12, 440); det.rect(1860, 556, 52, 14);+ const laundry = new Path2D(); for (const [x0, y0] of [[420, 700], [1500, 690], [2200, 720]]) { laundry.rect(x0, y0, 260, 3); for (let i = 0; i < 5; i++) laundry.rect(x0 + 20 + i * 48, y0 + 3, 26, 34 + (i % 2) * 14); }+ const birds = new Path2D(); bird(birds, 900, 300, .8); bird(birds, 960, 270, .6);return {- planes: [- skyPlane(sun.knock, 110, 280),- { id: 'sun', depth: .15, parts: [{ ink: 'sun', path: sun.disc, sub: 0 }] },- { id: 'far', depth: .35, parts: [{ ink: 'far', path: R.path, sub: 0 }, { ink: 'far', path: back, sub: 1 }] },- { id: 'mid', depth: .7, parts: [{ ink: 'mid', path: midF, sub: 0 }, { ink: 'sky1', path: shafts, sub: 1 }] },- { id: 'near', depth: 1.5, parts: [{ ink: 'near', path: near, sub: 0 }] },- ], trail,+ w: W0, h: H0, header: { x: 820, y: 214, size: 124 },+ depth: { sky: 0, far: .3, houses: .7, near: .9, acc: .5 },+ fountain: segs,+ parts: [+ { pull: 'sky', ink: 'sky1', path: rectPath(-BLEED, -BLEED, W0 + 2 * BLEED, H0 + 2 * BLEED), knock: unionPath([SUN.knock, obel]) },+ { pull: 'sky', ink: 'sky2', path: sky2, cut: obel },+ { pull: 'far', ink: 'far', path: city, cut: obel },+ { pull: 'far', ink: 'far', path: obShade },+ { pull: 'houses', ink: 'fountain', path: houses },+ { pull: 'near', ink: 'near', path: unionPath([det, birds]) },+ { pull: 'near', ink: 'glow', path: win, lit: 1 },+ { pull: 'acc', ink: 'sun', path: unionPath([SUN.disc, laundry]) },+ ],};}-// ================= COAST =================-function coast(seed) {- const sun = sunParts(700, 520, 80, 2);- const sea = rectPath(-60, 600, PW + 120, 1000);- const swell = wavesPath(0, 1000, 620, 960, 30, seed + 4, 90);- const stacks = polyPath([[160, 600], [190, 470], [240, 440], [270, 600]]); stacks.addPath(polyPath([[300, 600], [315, 520], [345, 530], [360, 600]]));- const cliffs = polyPath([[-60, 520], [120, 540], [240, 610], [340, 700], [420, 820], [480, 960], [520, 1300], [-60, 1300]]);- const cliffLit = polyPath([[120, 540], [240, 610], [340, 700], [420, 820], [380, 830], [300, 720], [200, 630]]);- const near = polyPath([[-60, 1040], [200, 1010], [500, 1040], [800, 1000], [1060, 1020], [1060, 1600], [-60, 1600]]);- const grass = new Path2D(); const r = mulberry(seed + 9); for (let i = 0; i < 40; i++) { const x = r() * 1000, y = 1000 + r() * 40; grass.addPath(polyPath([[x, y + 20], [x + 4 + r() * 10, y - 40 - r() * 60], [x + 8, y + 20]])); }- const trail = [[600, 1200], [640, 1120], [720, 1060], [820, 1020]].map(q => ({ x: q[0], y: q[1], plane: 'near' }));+// ================= the night sea on the way home: a very wide print for a long truck =================+export function sea(seed = 17) {+ const W0 = 5200, H0 = AH, MOON = sunParts(3700, 300, 64), HOR = 640;+ // stars are bare paper, knocked out of the night sky (one per grid cell, so they never overlap)+ const stars = new Path2D(); { const r = mulberry(seed + 1); for (let gx = 0; gx < W0; gx += 90) for (let gy = 20; gy < 520; gy += 70) { if (r() < .45) continue; const x = gx + r() * 70, y = gy + r() * 50, s = 1.6 + r() * 2.6; if (Math.hypot(x - 3700, y - 300) < 140) continue; stars.moveTo(x + s, y); stars.arc(x, y, s, 0, Math.PI * 2); } }+ const sky2 = new Path2D(); sky2.rect(-BLEED, -BLEED, W0 + 2 * BLEED, 160 + BLEED); sky2.addPath(bandSteps(-BLEED, W0 + 2 * BLEED, 140, 420, 6, 8));+ const clouds = new Path2D(); { const r = mulberry(seed + 3); for (let i = 0; i < 16; i++) { const x = r() * W0, y = 380 + r() * 170, w = 260 + r() * 420, h = 14 + r() * 16; clouds.moveTo(x + h, y); clouds.arc(x + h, y + h, h, -Math.PI / 2, Math.PI / 2, true); clouds.lineTo(x + w - h, y + 2 * h); clouds.arc(x + w - h, y + h, h, Math.PI / 2, -Math.PI / 2, true); clouds.closePath(); } }+ const isles = new Path2D(); for (const [x0, w, h] of [[600, 420, 40], [1900, 260, 26], [2900, 520, 52], [4400, 360, 34]]) isles.addPath(polyPath([[x0, HOR + 2], [x0 + w * .3, HOR - h], [x0 + w * .55, HOR - h * .7], [x0 + w * .8, HOR - h * .9], [x0 + w, HOR + 2]]));+ const water = rectPath(-BLEED, HOR, W0 + 2 * BLEED, H0 - HOR + BLEED);+ const glint = new Path2D(); for (let i = 0; i < 12; i++) { const y = HOR + 14 + i * 30 + i * i * 2, w = 150 - i * 7 + (i % 2) * 20; glint.rect(3700 - w / 2 + ((i * 37) % 23) - 11, y, w, 4 + i * .8); }+ const waves = waterBars(-BLEED, W0 + BLEED, HOR + 30, 1100, 12, seed + 5, 260);+ const crests = new Path2D(); for (let x = -BLEED; x < W0 + BLEED; x += 140) { crests.moveTo(x, 1100); crests.quadraticCurveTo(x + 40, 1000, x + 90, 1010); crests.quadraticCurveTo(x + 60, 1030, x + 140, 1100); crests.closePath(); }return {- planes: [- skyPlane(sun.knock, 140, 330),- { id: 'sun', depth: .15, parts: [{ ink: 'sun', path: sun.disc, sub: 0 }] },- { id: 'far', depth: .35, parts: [{ ink: 'sky2', path: sea, sub: 0 }, { ink: 'sky1', path: swell, sub: 1 }, { ink: 'far', path: stacks, sub: 0 }] },- { id: 'mid', depth: .7, parts: [{ ink: 'mid', path: cliffs, sub: 0 }, { ink: 'far', path: cliffLit, sub: 1 }] },- { id: 'near', depth: 1.5, parts: [{ ink: 'near', path: near, sub: 0 }, { ink: 'near', path: grass, sub: 0 }] },- ], trail,+ w: W0, h: H0, header: null,+ depth: { sky: 0, far: .3, mid: .6, near: .9, acc: .3 },+ parts: [+ { pull: 'sky', ink: 'sky1', path: rectPath(-BLEED, -BLEED, W0 + 2 * BLEED, HOR + BLEED), knock: unionPath([MOON.knock, stars]) },+ { pull: 'sky', ink: 'sky2', path: sky2, cut: stars },+ { pull: 'far', ink: 'far', path: unionPath([clouds, isles]) },+ { pull: 'mid', ink: 'mid', path: water, knock: glint },+ { pull: 'mid', ink: 'glow', path: waves, lit: 1, cut: glint },+ { pull: 'near', ink: 'near', path: crests },+ { pull: 'acc', ink: 'sun', path: MOON.disc },+ ],};}--export const SCENES = { lake, waterfall, ridge, forest: forestScene, coast };-export function buildScene(name, seed = 1) { const f = SCENES[name] || SCENES.lake; return f(seed); }diff --git a/styles/silkscreen-poster/demo/events.json b/styles/silkscreen-poster/demo/events.jsonindex 8e76f95..b90fcf9 100644--- a/styles/silkscreen-poster/demo/events.json+++ b/styles/silkscreen-poster/demo/events.json@@ -1 +1 @@-{"dur":38.4,"ev":[{"t":0,"type":"squeegee","dur":1,"ink":"sky"},{"t":0,"type":"section","kind":"banner","t1":4.8,"time_of_day":null},{"t":1,"type":"lift"},{"t":1.2,"type":"squeegee","dur":0.3,"ink":"title"},{"t":1.35,"type":"squeegee","dur":0.25,"ink":"footer"},{"t":1.5,"type":"title"},{"t":4.8,"type":"tilt","i":0},{"t":4.8,"type":"section","kind":"press","t1":13.2,"time_of_day":"dawn"},{"t":5.4,"type":"pull","i":0,"layer":"sky","n":0,"dur":0.45},{"t":6,"type":"pull","i":0,"layer":"far","n":1,"dur":0.45},{"t":6.6,"type":"pull","i":0,"layer":"mid","n":2,"dur":0.45},{"t":7.2,"type":"pull","i":0,"layer":"near","n":3,"dur":0.45},{"t":7.8,"type":"lift","i":0},{"t":8.4,"type":"band","i":0},{"t":9,"type":"name","i":0},{"t":9.6,"type":"item","i":0,"k":0,"last":0,"climb":0},{"t":9.9,"type":"item","i":0,"k":1,"last":0,"climb":0},{"t":10.2,"type":"item","i":0,"k":2,"last":1,"climb":0},{"t":12.9,"type":"pull","i":1,"layer":"sky","n":0,"dur":0.26,"quick":1},{"t":13.2,"type":"wipe","i":1},{"t":13.2,"type":"section","kind":"quick","t1":19.2,"time_of_day":"noon"},{"t":13.5,"type":"pull","i":1,"layer":"far","n":1,"dur":0.26,"quick":1},{"t":13.8,"type":"pull","i":1,"layer":"mid","n":2,"dur":0.26,"quick":1},{"t":14.1,"type":"pull","i":1,"layer":"near","n":3,"dur":0.26,"quick":1},{"t":14.4,"type":"pullback","i":1},{"t":14.7,"type":"band","i":1},{"t":15,"type":"name","i":1},{"t":15.3,"type":"item","i":1,"k":0,"last":0,"climb":0},{"t":15.6,"type":"item","i":1,"k":1,"last":0,"climb":0},{"t":15.9,"type":"item","i":1,"k":2,"last":1,"climb":0},{"t":18,"type":"silence","dur":1.2,"pre":1},{"t":19.2,"type":"wipe","i":2},{"t":19.2,"type":"ascent","i":2,"dur":4.199999999999999},{"t":19.2,"type":"section","kind":"ascent","t1":29.4,"time_of_day":"dusk"},{"t":19.704,"type":"part","i":2,"layer":"near"},{"t":20.46,"type":"part","i":2,"layer":"spurC"},{"t":20.6,"type":"swap","i":2,"k":1,"dur":0.35},{"t":21.3,"type":"part","i":2,"layer":"spurB"},{"t":22,"type":"swap","i":2,"k":2,"dur":0.35},{"t":22.14,"type":"part","i":2,"layer":"spurA"},{"t":23.4,"type":"silence","dur":0.6000000000000014},{"t":24,"type":"clack","i":2},{"t":24,"type":"tiltdown","i":2},{"t":24.6,"type":"band","i":2},{"t":24.9,"type":"name","i":2},{"t":25.2,"type":"item","i":2,"k":0,"last":0,"climb":0},{"t":25.5,"type":"item","i":2,"k":1,"last":0,"climb":0},{"t":25.8,"type":"item","i":2,"k":2,"last":0,"climb":0},{"t":26.1,"type":"item","i":2,"k":3,"last":1,"climb":1},{"t":29.4,"type":"wallpull"},{"t":29.4,"type":"section","kind":"wall","t1":34.8,"time_of_day":null},{"t":30.6,"type":"land","dur":4.199999999999999},{"t":34.8,"type":"endcard","dur":3.6000000000000014},{"t":34.8,"type":"section","kind":"end","t1":38.4,"time_of_day":null},{"t":35.3,"type":"endpull","dur":0.3}]}\ No newline at end of file+{"dur":50,"ev":[{"t":0,"type":"pull","city":"beijing","layer":"sun","dur":1.5,"ink":"sun"},{"t":0,"type":"shot","n":1,"t1":3.3333},{"t":0.4,"type":"vo","id":"L01"},{"t":1.111,"type":"pull","city":"beijing","layer":"sky1","dur":0.5,"ink":"sky1"},{"t":1.667,"type":"pull","city":"beijing","layer":"sky2","dur":0.5,"ink":"sky2"},{"t":2.222,"type":"pull","city":"beijing","layer":"far","dur":0.45,"ink":"far"},{"t":2.778,"type":"pull","city":"beijing","layer":"mid","dur":0.45,"ink":"mid"},{"t":3.333,"type":"pull","city":"beijing","layer":"near","dur":0.45,"ink":"near"},{"t":3.333,"type":"shot","n":2,"t1":5.5556},{"t":3.611,"type":"pull","city":"beijing","layer":"acc","dur":0.32,"ink":"sun"},{"t":3.889,"type":"pull","city":"beijing","layer":"lit","dur":0.32,"ink":"glow"},{"t":3.944,"type":"wake","place":"beijing"},{"t":4.444,"type":"lift"},{"t":5.556,"type":"stub","dur":0.34},{"t":5.556,"type":"push","dur":4.7},{"t":5.556,"type":"shot","n":3,"t1":10},{"t":5.833,"type":"item","k":0},{"t":5.86,"type":"vo","id":"L02"},{"t":6.111,"type":"header"},{"t":6.389,"type":"item","k":1},{"t":6.667,"type":"item","k":2,"accent":1},{"t":9.7,"type":"wake","place":"istanbul"},{"t":10,"type":"wipe","dur":0.6},{"t":10,"type":"shot","n":4,"t1":14.1667},{"t":10.28,"type":"pull","city":"istanbul","layer":"sky","n":0,"dur":0.26,"quick":1},{"t":10.42,"type":"pull","city":"istanbul","layer":"far","n":1,"dur":0.22,"quick":1},{"t":10.5,"type":"vo","id":"L03"},{"t":10.56,"type":"pull","city":"istanbul","layer":"mid","n":2,"dur":0.22,"quick":1},{"t":10.56,"type":"header","city":"istanbul"},{"t":10.7,"type":"pull","city":"istanbul","layer":"near","n":3,"dur":0.22,"quick":1},{"t":10.7,"type":"stub","dur":0.25,"city":"istanbul"},{"t":10.84,"type":"pull","city":"istanbul","layer":"acc","n":4,"dur":0.18,"quick":1},{"t":10.84,"type":"item","k":0},{"t":10.98,"type":"pull","city":"istanbul","layer":"lit","n":5,"dur":0.18,"quick":1},{"t":10.98,"type":"item","k":2,"accent":1},{"t":11.12,"type":"item","k":1},{"t":13.767,"type":"wake","place":"paris"},{"t":14.167,"type":"sweep","dur":0.5,"to":"paris"},{"t":14.167,"type":"shot","n":5,"t1":17.7778},{"t":14.4,"type":"crane","dur":3.299999999999999},{"t":14.4,"type":"vo","id":"L04"},{"t":14.45,"type":"header","city":"paris"},{"t":14.45,"type":"stub","dur":0.25,"city":"paris"},{"t":14.5,"type":"item","k":0},{"t":14.6,"type":"item","k":2,"accent":1},{"t":14.7,"type":"item","k":1},{"t":17.378,"type":"wake","place":"boca"},{"t":17.778,"type":"sweep","dur":0.6,"to":"boca","fountain":1},{"t":17.778,"type":"shot","n":6,"t1":21.9444},{"t":17.9,"type":"truck","dur":4.300000000000001},{"t":18.2,"type":"vo","id":"L05"},{"t":18.33,"type":"pull","city":"boca","layer":"near","n":4,"dur":0.26,"quick":1},{"t":18.61,"type":"header","city":"boca"},{"t":18.75,"type":"pull","city":"boca","layer":"acc","n":5,"dur":0.2,"quick":1},{"t":19.17,"type":"stub","dur":0.3,"city":"boca"},{"t":19.31,"type":"item","k":0},{"t":19.44,"type":"item","k":2,"accent":1},{"t":19.72,"type":"item","k":1},{"t":21.4,"type":"vo","id":"L06"},{"t":21.944,"type":"bigpush","dur":3.5555999999999983},{"t":21.944,"type":"shot","n":7,"t1":27.7778},{"t":24.4,"type":"meshdown","dur":0.45},{"t":25,"type":"drop"},{"t":26.86,"type":"silence","dur":0.918},{"t":27.778,"type":"clamp"},{"t":27.778,"type":"shot","n":8,"t1":33.3333},{"t":27.948,"type":"sweep","dur":0.5,"to":"sea"},{"t":27.948,"type":"wake","place":"sea"},{"t":28.1,"type":"vo","id":"L07"},{"t":28.2,"type":"pullout","dur":1.1999999999999993},{"t":28.2,"type":"truck","dur":5.129999999999999,"long":1},{"t":28.55,"type":"lift"},{"t":28.6,"type":"count","dur":7.5},{"t":31.8,"type":"vo","id":"L08"},{"t":32.833,"type":"wake","place":"home"},{"t":33.333,"type":"sweep","dur":0.55,"to":"dusk"},{"t":33.333,"type":"shot","n":9,"t1":36.6667},{"t":36.667,"type":"snap"},{"t":36.667,"type":"shot","n":10,"t1":42.2222},{"t":36.9,"type":"push","dur":4.700000000000003},{"t":37,"type":"vo","id":"L09"},{"t":41,"type":"vo","id":"L10"},{"t":41.922,"type":"wake","place":"night"},{"t":42.222,"type":"sweep","dur":0.6,"to":"night"},{"t":42.222,"type":"shot","n":11,"t1":50},{"t":46.2,"type":"endpull","dur":0.4},{"t":46.6,"type":"endpull","dur":0.35,"text":1}]}\ No newline at end of filediff --git a/styles/silkscreen-poster/demo/film.js b/styles/silkscreen-poster/demo/film.jsindex 6e446d0..37ddde8 100644--- a/styles/silkscreen-poster/demo/film.js+++ b/styles/silkscreen-poster/demo/film.js@@ -1,427 +1,412 @@-// film.js · scene demo: an outdoor trail guide (silkscreen travel poster)-// The timeline is derived entirely from content.json (works for 1–4 trails), 100 BPM, one beat = 0.6 s-import { makeTextures, squeegee, screenFrame, wipeFront, wipeRegion, ink, rectPath, polyPath, circlePath, ringPath, clamp, lerp, mix, hash, mulberry, paperSheet, inkFinish } from './engine/silk.js';-import { buildPoster, drawPoster, drawBanner, swapFrontLine, pickInk, BANNER_ART, BANNER_BANDS, PW, PH, ART, BW, BH, readTime } from './engine/poster.js';+// film.js · "The Long Way Home" (silkscreen travel poster). One timeline for the whole 50 s film, full-bleed prints only:+// the camera always stays inside the picture (no table, no paper edge). 108 BPM waltz (3/4): beat 0.5556 s, bar 1.6667 s.+// The ticket stub sits at the same place on screen in every city; from shot 4 on it is drawn in screen space.+import { makeTextures, squeegee, wipeRegion, ink, rectPath, clamp, lerp, hash, inkFinish } from './engine/silk.js';+import { drawPrint, tiltFront, textBoxes, drawArt, headerBoxes, drawStub, stubBoxes, drawEndCard, STUB, AW, AH, FONT_T } from './engine/poster.js';+import { temple, istanbul, paris, boca, sea, BOCA_INKS } from './engine/scenes.js';-export const BPM = 100, B = 60 / BPM;+export const BPM = 108, B = 60 / BPM, BAR = 3 * B, DUR = 50;+const W = 1920, H = 1080;const ss = t => { t = clamp(t); return t * t * (3 - 2 * t); };const eio = t => { t = clamp(t); return t < .5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; };const eo = t => 1 - Math.pow(1 - clamp(t), 3);-const ei = t => Math.pow(clamp(t), 3);const seg = (t, a, b) => clamp((t - a) / (b - a));-const W = 1920, H = 1080;+const bt = (bar, beat = 0) => +(bar * BAR + beat * B).toFixed(4);-let C, T, POS, TL, ctx;-// World coordinates (the print table): banner centred on the origin, posters below it-const BAN = [-900, -220]; // banner top-left (1800×440, centred on the origin)-const PO = [-500, 420]; // poster top-left (on the print table)+// ---------------- palettes (one per print; ≤ 6 inks + a lit-face ink) ----------------+export const PAPER = '#F3EAD8';+const PAL = {+ beijingDawn: { sky1: '#F5C978', sky2: '#E8866A', far: '#9A88AE', mid: '#22447C', near: '#1B1F34', sun: '#D8432B', glow: '#5D86C4' },+ istanbul: { sky1: '#F6DFB2', sky2: '#E9A27A', far: '#8DB9BE', mid: '#C9705A', near: '#1F2D3A', sun: '#F2C14E', glow: '#6E8BA3' },+ paris: { sky1: '#F4E6CC', sky2: '#A9C1DE', far: '#C3B3D2', mid: '#5B6E9C', near: '#252B42', sun: '#E4553F', glow: '#EDC77E' },+ boca: { sky1: '#F8E7B0', sky2: '#82C7D8', far: '#B9A9C6', mid: '#3B5B7A', near: '#232B3A', sun: '#E2543D', glow: '#F7E2A6' },+ sea: { sky1: '#2C3B69', sky2: '#1C2650', far: '#46598A', mid: '#203A63', near: '#111A2F', sun: '#F2D28A', glow: '#3F6395' },+ beijingDusk: { sky1: '#F2A766', sky2: '#A25A84', far: '#6E5C8E', mid: '#26386E', near: '#151A2C', sun: '#E4502F', glow: '#5578B4' },+ beijingNight: { sky1: '#2A3762', sky2: '#18204A', far: '#3A4778', mid: '#1F2D5C', near: '#0F1426', sun: '#F2BE4E', glow: '#3D5A97' },+};+// ---------------- prints ----------------+const PRINTS = {+ beijing: { scene: temple(3), city: 'BEIJING', cityZh: '北京', day: 1, km: '0', landmark: 'TEMPLE OF HEAVEN', built: '1420', seed: 5 },+};-export function setup(content, canvas) {- C = content; ctx = canvas.getContext('2d');- T = makeTextures(C.palette.paper, 7);- POS = C.trails.map((tr, i) => buildPoster(C, tr, i, C.trails.length));- TL = timeline();- return TL;-}-const pal = (key) => C.palette[key] || C.palette.noon;+// ---------------- timeline (whole-film clock) ----------------+const P1 = {+ sun: [-.9, 2.4], sky1: [bt(0, 2), .5], sky2: [bt(1, 0), .5], far: [bt(1, 1), .45], mid: [bt(1, 2), .45],+ near: [bt(2, 0), .45], acc: [bt(2, .5), .32], lit: [bt(2, 1), .32],+ stub: [bt(3, 1), .34], day: [bt(3, 1.5), .2], header: [bt(3, 2), .32], landmark: [bt(3, 2.5), .2], km: [bt(4, 0), .22],+ sign: [4.5 * BAR, .26],+};+const LIFT1 = bt(2, 2); // 4.44 s: the screen hinges up+const INK_OF = { sun: 'sun', sky1: 'sky1', sky2: 'sky2', far: 'far', mid: 'mid', near: 'near', acc: 'sun', lit: 'glow' };+// ---------------- the rest of the journey (whole-film clock) ----------------+const SC = { istanbul: istanbul(7), paris: paris(9), boca: boca(13), sea: sea(17), temple: temple(3) };+// Istanbul is printed on sixteenth notes (faster by subdividing the beat, same tempo); its stub lands early so it can be read+const IST = { cover: 10.3, sky: [10.28, .26], far: [10.42, .22], mid: [10.56, .22], near: [10.70, .22], acc: [10.84, .18], lit: [10.98, .18],+ header: [10.56, .3], panel: [10.70, .25], day: [10.84, .15], big: [10.98, .18], small: [11.12, .18] };+const PAR = { swap: [bt(8, 1.5), .5], crane: [14.4, 17.7], header: [14.45, .32], panel: [14.45, .25], day: [14.5, .15], big: [14.6, .18], small: [14.7, .18] };+const BA = { swap: [bt(10, 2), .6], near: [18.33, .26], header: [18.61, .32], acc: [18.75, .2], panel: [19.17, .3], day: [19.31, .18], big: [19.44, .2], small: [19.72, .2], truck: [17.9, 22.2] };+const PUSH = { t0: bt(13, .5), t1: 25.5, mesh: [24.4, .45], silence: [26.86, bt(16, 2)] };+const CLAMP = bt(16, 2); // 27.78 s+const SEA = { swap: [CLAMP + .17, .5], out: [28.2, 29.4], truck: [28.2, 33.33], lift: [28.55, .45], count: [28.6, 36.1] };+const HOME = { swap: [bt(20), .55], snap: bt(22), push: [36.9, 41.6], night: [bt(25, 1), .6], card1: [46.2, .4], card2: [46.6, .35] };+const TRAV0 = 20360, TRAV1 = 39630, FAR = 19270;-// ---------------- Timeline -----------------function timeline() {- const n = POS.length, secs = [], ev = [];- const E = (t, type, o = {}) => ev.push({ t: +t.toFixed(3), type, ...o });- // S1 banner + title- const s1 = { kind: 'banner', t0: 0, sky: [-.45, 1.0], lift: 1.0, title: [1.2, 1.5], footer: [1.35, 1.6], pull: [1.0, 1.65], t1: 8 * B };- E(0, 'squeegee', { dur: 1.0, ink: 'sky' }); E(1.0, 'lift'); E(1.2, 'squeegee', { dur: .3, ink: 'title' }); E(1.35, 'squeegee', { dur: .25, ink: 'footer' });- E(1.5, 'title'); secs.push(s1);- let s = s1.t1;- POS.forEach((P, i) => {- const mode = i === 0 ? 'press' : (i === n - 1 && n > 1 ? 'ascent' : 'quick');- const statStr = P.items.map(it => it.value).join(' ');- const sec = { kind: mode, P, i, t0: s };- if (mode === 'press') {- sec.tilt = [s, s + B];- sec.pulls = { sky: s + B, far: s + 2 * B, mid: s + 3 * B, near: s + 4 * B };- sec.pullDur = .45; sec.lift = s + 5 * B; sec.push = [s + 5 * B, s + 7 * B];- sec.band = s + 6 * B; sec.name = s + 7 * B;- sec.items = P.items.map((_, k) => s + 8 * B + k * B / 2);- } else if (mode === 'quick') {- sec.pulls = { sky: s - .3, far: s + B / 2, mid: s + B, near: s + 1.5 * B };- sec.pullDur = .26; sec.back = [s + 2 * B, s + 3.2 * B];- sec.band = s + 2.5 * B; sec.name = s + 3 * B;- sec.items = P.items.map((_, k) => s + 3.5 * B + k * B / 2);- } else {- sec.climb = [s, s + 7 * B]; sec.clack = s + 8 * B; sec.down = [s + 8 * B, s + 9.5 * B];- sec.band = s + 9 * B; sec.name = s + 9.5 * B;- sec.items = P.items.map((_, k) => s + 10 * B + k * B / 2);- sec.pals = [...new Set([POS[i - 1] ? POS[i - 1].trail.time_of_day : 'noon', 'golden', P.trail.time_of_day])].filter(k => C.palette[k]);- }- // ---- events (sound-effect and score sync points are all taken from here) ----- if (mode === 'press') { E(sec.tilt[0], 'tilt', { i }); ['sky', 'far', 'mid', 'near'].forEach((k, j) => E(sec.pulls[k], 'pull', { i, layer: k, n: j, dur: sec.pullDur })); E(sec.lift, 'lift', { i }); }- else if (mode === 'quick') { E(s, 'wipe', { i }); ['sky', 'far', 'mid', 'near'].forEach((k, j) => E(sec.pulls[k], 'pull', { i, layer: k, n: j, dur: sec.pullDur, quick: 1 })); E(sec.back[0], 'pullback', { i }); }- else {- E(s, 'wipe', { i }); E(s, 'ascent', { i, dur: sec.climb[1] - sec.climb[0] });- const nS = sec.pals.length - 1; for (let k = 1; k <= nS; k++) E(lerp(sec.climb[0], sec.climb[1], k / (nS + 1)), 'swap', { i, k, dur: .35 });- ['near', 'spurC', 'spurB', 'spurA'].forEach((id, j) => E(lerp(sec.climb[0], sec.climb[1], [.12, .3, .5, .7][j]), 'part', { i, layer: id }));- E(sec.climb[1], 'silence', { dur: sec.clack - sec.climb[1] }); E(sec.clack, 'clack', { i }); E(sec.down[0], 'tiltdown', { i });- }- E(sec.band, 'band', { i }); E(sec.name, 'name', { i });- sec.items.forEach((a, k) => E(a, 'item', { i, k, last: k === sec.items.length - 1 ? 1 : 0, climb: P.items[k].climb ? 1 : 0 }));- const lastItem = sec.items[sec.items.length - 1] ?? sec.name;- const need = Math.max(sec.name + readTime(P.trail.name), lastItem + readTime(statStr));- sec.t1 = Math.ceil((need + .05) / B) * B + (mode === 'ascent' ? 0 : B);- secs.push(sec); s = sec.t1;- });- // S5 posters go up on the wall- const foot = readTime(C.footer);- const wall = { kind: 'wall', t0: s, pull: [s, s + 2 * B], t1: 0 };- wall.hold0 = s + 2 * B; wall.t1 = wall.hold0 + Math.ceil(Math.max(3.6, foot) / B) * B;- secs.push(wall);- const end = { kind: 'end', t0: wall.t1, t1: wall.t1 + 6 * B }; secs.push(end);- // silence at the end of the quick-print section (before the signature section)- const asc = secs.find(q => q.kind === 'ascent'); if (asc) E(asc.t0 - 2 * B, 'silence', { dur: 2 * B, pre: 1 });- E(wall.t0, 'wallpull'); E(wall.hold0, 'land', { dur: wall.t1 - wall.hold0 }); E(end.t0, 'endcard', { dur: end.t1 - end.t0 }); E(end.t0 + .5, 'endpull', { dur: .3 });- secs.forEach(q => E(q.t0, 'section', { kind: q.kind, t1: q.t1, time_of_day: q.P ? q.P.trail.time_of_day : null }));+export const SHOTS = [+ { n: 1, t0: 0, t1: bt(2) }, { n: 2, t0: bt(2), t1: bt(3, 1) }, { n: 3, t0: bt(3, 1), t1: 10 },+ { n: 4, t0: 10, t1: PAR.swap[0] }, { n: 5, t0: PAR.swap[0], t1: BA.swap[0] }, { n: 6, t0: BA.swap[0], t1: PUSH.t0 },+ { n: 7, t0: PUSH.t0, t1: CLAMP }, { n: 8, t0: CLAMP, t1: HOME.swap[0] }, { n: 9, t0: HOME.swap[0], t1: HOME.snap },+ { n: 10, t0: HOME.snap, t1: HOME.night[0] }, { n: 11, t0: HOME.night[0], t1: DUR },+];++let ctx, T, CUES = [], SIGN = false, NOCAP = false;+export function setup(canvas, opts) {+ ctx = canvas.getContext('2d'); T = makeTextures(PAPER, 7); CUES = opts.cues || []; SIGN = !!opts.sign; NOCAP = !!opts.nocap;+ return { dur: DUR, ev: events() };+}+function events() {+ const ev = [], E = (t, type, o = {}) => ev.push({ t: +t.toFixed(3), type, ...o });+ for (const k of Object.keys(INK_OF)) { const [a, d] = P1[k]; E(Math.max(0, a), 'pull', { city: 'beijing', layer: k, dur: +(d - Math.max(0, -a)).toFixed(3), ink: INK_OF[k] }); }+ E(LIFT1, 'lift'); E(LIFT1 - .5, 'wake', { place: 'beijing' });+ E(P1.stub[0], 'stub', { dur: P1.stub[1] }); E(P1.header[0], 'header');+ E(P1.day[0], 'item', { k: 0 }); E(P1.landmark[0], 'item', { k: 1 }); E(P1.km[0], 'item', { k: 2, accent: 1 });+ if (SIGN) E(P1.sign[0], 'sign');+ E(P1.stub[0], 'push', { dur: 4.7 });+ // Istanbul+ E(10.0, 'wipe', { dur: .6 }); E(9.7, 'wake', { place: 'istanbul' });+ ['sky', 'far', 'mid', 'near', 'acc', 'lit'].forEach((k, j) => E(IST[k][0], 'pull', { city: 'istanbul', layer: k, n: j, dur: IST[k][1], quick: 1 }));+ const info = (o, city) => { E(o.header[0], 'header', { city }); E(o.panel[0], 'stub', { dur: o.panel[1], city }); E(o.day[0], 'item', { k: 0 }); E(o.big[0], 'item', { k: 2, accent: 1 }); E(o.small[0], 'item', { k: 1 }); };+ info(IST, 'istanbul');+ // Paris+ E(PAR.swap[0], 'sweep', { dur: PAR.swap[1], to: 'paris' }); E(PAR.swap[0] - .4, 'wake', { place: 'paris' }); E(PAR.crane[0], 'crane', { dur: PAR.crane[1] - PAR.crane[0] }); info(PAR, 'paris');+ // Buenos Aires+ E(BA.swap[0], 'sweep', { dur: BA.swap[1], to: 'boca', fountain: 1 }); E(BA.swap[0] - .4, 'wake', { place: 'boca' });+ E(BA.near[0], 'pull', { city: 'boca', layer: 'near', n: 4, dur: BA.near[1], quick: 1 }); E(BA.acc[0], 'pull', { city: 'boca', layer: 'acc', n: 5, dur: BA.acc[1], quick: 1 });+ E(BA.truck[0], 'truck', { dur: BA.truck[1] - BA.truck[0] }); info(BA, 'boca');+ // the far side: push into the number, silence, clamp+ E(PUSH.t0, 'bigpush', { dur: PUSH.t1 - PUSH.t0 }); E(PUSH.mesh[0], 'meshdown', { dur: PUSH.mesh[1] });+ E(25.0, 'drop'); E(PUSH.silence[0], 'silence', { dur: +(PUSH.silence[1] - PUSH.silence[0]).toFixed(3) }); E(CLAMP, 'clamp');+ // the way home+ E(SEA.swap[0], 'sweep', { dur: SEA.swap[1], to: 'sea' }); E(SEA.lift[0], 'lift'); E(SEA.out[0], 'pullout', { dur: SEA.out[1] - SEA.out[0] }); E(SEA.swap[0], 'wake', { place: 'sea' });+ E(SEA.out[0], 'truck', { dur: SEA.truck[1] - SEA.truck[0], long: 1 }); E(SEA.count[0], 'count', { dur: SEA.count[1] - SEA.count[0] });+ E(HOME.swap[0], 'sweep', { dur: HOME.swap[1], to: 'dusk' }); E(HOME.swap[0] - .5, 'wake', { place: 'home' });+ E(HOME.snap, 'snap'); E(HOME.push[0], 'push', { dur: HOME.push[1] - HOME.push[0] });+ E(HOME.night[0], 'sweep', { dur: HOME.night[1], to: 'night' }); E(HOME.night[0] - .3, 'wake', { place: 'night' });+ E(HOME.card1[0], 'endpull', { dur: HOME.card1[1] }); E(HOME.card2[0], 'endpull', { dur: HOME.card2[1], text: 1 });+ for (const c of CUES) E(c.vo, 'vo', { id: c.id });+ SHOTS.forEach(s => E(s.t0, 'shot', { n: s.n, t1: s.t1 }));ev.sort((a, b) => a.t - b.t);- return { secs, ev, dur: end.t1 };+ return ev;}-// ---------------- Camera -----------------function cam(cx, cy, z, rot = 0) { ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.translate(W / 2, H / 2); if (rot) ctx.rotate(rot); ctx.scale(z, z); ctx.translate(-cx, -cy); }--// ---------------- Print table: old wooden workbench (flat boards + wood grain + dried ink stains + tape marks) -----------------const TABLE = '#6B4E36';-let TABLE_CACHE = null;-function buildTable() {- const r = mulberry(21), planks = [], stains = [], tapes = [];- const x0 = -2200, x1 = 2200, y0 = -1400, y1 = 2600, ph = 170;- const tones = ['#6E5039', '#664A34', '#73553C', '#6A4C35', '#5F4430'];- for (let y = y0, k = 0; y < y1; y += ph, k++) {- const grain = new Path2D(), knots = new Path2D();- for (let g = 0; g < 7; g++) {- const gy = y + 14 + g * 22 + r() * 8, amp = 3 + r() * 5, f = .002 + r() * .003, ph0 = r() * 6;- grain.moveTo(x0, gy); for (let x = x0; x <= x1; x += 40) grain.lineTo(x, gy + amp * Math.sin(x * f + ph0) + 2 * Math.sin(x * f * 3.7));- }- for (let q = 0; q < 3; q++) { const kx = x0 + r() * (x1 - x0), ky = y + 30 + r() * (ph - 60); knots.ellipse(kx, ky, 22 + r() * 18, 7 + r() * 5, 0, 0, 7); }- planks.push({ y, color: tones[k % tones.length], grain, knots });- }- // dried ink stains: irregular flat blobs (ink spilled while printing), colours taken from this film's palette- const pals = Object.keys(C.palette).filter(k => C.palette[k] && C.palette[k].sky2).map(k => C.palette[k]);- const avoid = (x, y) => (x > PO[0] - 60 && x < PO[0] + PW + 60 && y > PO[1] - 60 && y < PO[1] + PH + 60) || (x > BAN[0] - 60 && x < BAN[0] + BW + 60 && y > BAN[1] - 60 && y < BAN[1] + BH + 60);- for (let i = 0; i < 12; i++) {- let x, y, n = 0; do { x = x0 + 300 + r() * (x1 - x0 - 600); y = y0 + 200 + r() * (y1 - y0 - 400); n++; } while (avoid(x, y) && n < 30);- const pp = pals[i % pals.length], col = [pp.sky2, pp.near, pp.sun, pp.mid, pp.far][(r() * 5) | 0];- const R = 50 + r() * 70, pts = [], m = 11;- for (let j = 0; j < m; j++) { const a = j / m * 6.283, rr = R * (.65 + .5 * r()) * (j % 3 === 0 ? 1.3 : 1); pts.push([x + Math.cos(a) * rr * 1.25, y + Math.sin(a) * rr * .8]); }- const path = new Path2D(); pts.forEach((q, j) => { const nq = pts[(j + 1) % m]; if (!j) path.moveTo((q[0] + nq[0]) / 2, (q[1] + nq[1]) / 2); else path.quadraticCurveTo(q[0], q[1], (q[0] + nq[0]) / 2, (q[1] + nq[1]) / 2); });- path.closePath();- if (r() < .45) { const d = new Path2D(); d.arc(x + R * 1.6, y + (r() - .5) * R, 4 + r() * 6, 0, 7); path.addPath(d); } // flicked ink dots- if (r() < .35) { const sm = new Path2D(); const sx = x - R * 2.4; sm.rect(sx, y - 5, R * 1.8, 10 + r() * 6); path.addPath(sm); } // squeegee smear- stains.push({ path, col: mix(col, TABLE, .45), a: .7 });- }- // tape marks: old tape strips left after peeling (light beige, ragged edges)- for (let i = 0; i < 9; i++) {- let x, y, n = 0; do { x = x0 + 300 + r() * (x1 - x0 - 600); y = y0 + 200 + r() * (y1 - y0 - 400); n++; } while (avoid(x, y) && n < 30);- tapes.push({ x, y, w: 60 + r() * 120, h: 22 + r() * 8, a: (r() - .5) * .6, torn: r() < .6, dirty: r() < .5 });+// ---------------- camera: art units, z ≥ 1, the view never leaves the picture ----------------+const K1 = [+ [0, 0, [1240, 452, 3.2]],+ [0, bt(0, 2), [1236, 452, 3.34], 'lin'],+ [bt(0, 2), .55, [1180, 440, 2.25]],+ [bt(1, 0), .55, [1090, 470, 1.62]],+ [bt(1, 1), .5, [1010, 520, 1.3]],+ [bt(1, 2), .5, [975, 535, 1.12]],+ [bt(2, 0), .6, [960, 540, 1.0]],+ [P1.stub[0] - .3, 10 - P1.stub[0] + .3, [985, 532, 1.035], 'eio'],+];+function camAt(keys, t) {+ let s = keys[0][2].slice();+ for (const [t0, d, to, kind] of keys) {+ if (t < t0) break;+ const u = d <= 0 ? 1 : seg(t, t0, t0 + d), e = kind === 'lin' ? u : kind === 'eio' ? eio(u) : eo(u);+ s = [lerp(s[0], to[0], e), lerp(s[1], to[1], e), Math.exp(lerp(Math.log(s[2]), Math.log(to[2]), e))];}- return { planks, stains, tapes, x0, x1, ph };+ const z = Math.max(1, s[2]), hw = W / 2 / z, hh = H / 2 / z; // keep the whole view inside the print+ return [clamp(s[0], hw, AW - hw), clamp(s[1], hh, AH - hh), z];}-function table() {- if (!TABLE_CACHE) TABLE_CACHE = buildTable();- const TB = TABLE_CACHE;- ctx.save(); ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.fillStyle = TABLE; ctx.fillRect(0, 0, W, H); ctx.restore();- for (const p of TB.planks) {- ctx.fillStyle = p.color; ctx.fillRect(TB.x0, p.y, TB.x1 - TB.x0, TB.ph);- ctx.fillStyle = 'rgba(35,22,12,.55)'; ctx.fillRect(TB.x0, p.y, TB.x1 - TB.x0, 5); // board seams- ctx.fillStyle = 'rgba(255,230,190,.07)'; ctx.fillRect(TB.x0, p.y + 5, TB.x1 - TB.x0, 3);- ctx.save(); ctx.strokeStyle = 'rgba(40,24,12,.22)'; ctx.lineWidth = 2; ctx.stroke(p.grain); ctx.fillStyle = 'rgba(40,24,12,.25)'; ctx.fill(p.knots); ctx.restore();- }- for (const s0 of TB.stains) { ctx.save(); ctx.globalAlpha = s0.a; ctx.fillStyle = s0.col; ctx.fill(s0.path); ctx.globalAlpha = s0.a * .5; ctx.translate(-2, -2); ctx.fillStyle = 'rgba(255,255,255,.25)'; ctx.fill(s0.path); ctx.restore(); }- for (const tp of TB.tapes) {- ctx.save(); ctx.translate(tp.x, tp.y); ctx.rotate(tp.a);- ctx.fillStyle = tp.dirty ? 'rgba(205,184,140,.75)' : 'rgba(222,204,160,.8)';- ctx.beginPath(); ctx.moveTo(-tp.w / 2, -tp.h / 2); ctx.lineTo(tp.w / 2, -tp.h / 2);- if (tp.torn) { for (let k = 0; k <= 5; k++) ctx.lineTo(tp.w / 2 + (k % 2 ? -6 : 3), -tp.h / 2 + tp.h * k / 5); } else ctx.lineTo(tp.w / 2, tp.h / 2);- ctx.lineTo(-tp.w / 2, tp.h / 2); ctx.closePath(); ctx.fill();- if (tp.dirty) { ctx.fillStyle = 'rgba(60,40,25,.25)'; ctx.fillRect(-tp.w / 2 + 6, -3, tp.w * .5, 5); }+let CAM = [W / 2, H / 2, 1];+function cam(cx, cy, z) { CAM = [cx, cy, z]; ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.translate(W / 2, H / 2); ctx.scale(z, z); ctx.translate(-cx, -cy); }+const toScreen = (x, y) => [W / 2 + (x - CAM[0]) * CAM[2], H / 2 + (y - CAM[1]) * CAM[2]];++// ---------------- the screen over the print: mesh while printing; lifting = the frame's bottom bar sweeps up and away ----------------+function mesh(lift) {+ if (lift >= 1) return;+ const up = ss(lift) * (AH + 260); // the hinged screen rises: its lower edge travels up the print+ const y1 = AH + 40 - up; // lower edge of the mesh (art units)+ ctx.save();+ ctx.beginPath(); ctx.rect(-100, -100, AW + 200, y1 + 100); ctx.clip();+ ctx.fillStyle = 'rgba(236,214,128,.05)'; ctx.fillRect(-100, -100, AW + 200, AH + 200);+ ctx.strokeStyle = 'rgba(60,52,30,.12)'; ctx.lineWidth = .4; ctx.beginPath();+ for (let x = -60; x < AW + 60; x += 6) { ctx.moveTo(x, -60); ctx.lineTo(x, AH + 60); }+ for (let y = -60; y < AH + 60; y += 6) { ctx.moveTo(-60, y); ctx.lineTo(AW + 60, y); }+ ctx.stroke(); ctx.restore();+ if (lift > 0) { // the frame's bottom bar: aluminium + blue tape, its shadow on the print+ ctx.save();+ ctx.globalAlpha = .22; ctx.fillStyle = '#000'; ctx.fillRect(-100, y1 + 34, AW + 200, 26 + 30 * lift);+ ctx.globalAlpha = 1; ctx.fillStyle = '#B7B2A6'; ctx.fillRect(-100, y1, AW + 200, 34);+ ctx.fillStyle = '#D6D1C4'; ctx.fillRect(-100, y1, AW + 200, 5); ctx.fillStyle = '#8E897E'; ctx.fillRect(-100, y1 + 28, AW + 200, 6);+ ctx.fillStyle = '#3C6E9E'; ctx.fillRect(-100, y1 - 10, AW + 200, 10);ctx.restore();}}-function regTape(x, y, w, h) {- ctx.fillStyle = '#D9C38A';- const L = 60, th = 16;- for (const [px, py, sx, sy] of [[x, y, -1, -1], [x + w, y, 1, -1], [x, y + h, -1, 1], [x + w, y + h, 1, 1]]) {- ctx.fillRect(Math.min(px, px + sx * L), py + (sy < 0 ? -th : 0) - sy * 2, L, th);- ctx.fillRect(px + (sx < 0 ? -th : 0) - sx * 2, Math.min(py, py + sy * L), th, L);- }-}-function sheetShadow(x, y, w, h, a = .3) { ctx.save(); ctx.globalAlpha = a; ctx.fillStyle = '#000'; ctx.fillRect(x + 8, y + 12, w, h); ctx.restore(); }-// ---------------- Sections -----------------function banner(sec, t) {- const p = seg(t, sec.sky[0], sec.sky[1]);- const sqX = wipeFront([BAN[0], BAN[1], BW, BH], 'right', p, 34);- // camera: first tracks sideways with the squeegee (close-up), pulls back to the whole banner once the pull ends, then slowly pushes in- const k = eo(seg(t, sec.pull[0], sec.pull[1]));- const zc = lerp(1.95, 1.8, ss(seg(t, 0, 1.0))), zw = .96; // opening close-up → banner fills the frame width (about 5% margins), about 40% of frame height- const cxClose = sqX - 150, cyClose = 0;- let z = lerp(zc, zw, k), cx = lerp(cxClose, 0, k), cy = lerp(cyClose, 0, k);- z *= 1 + .03 * ss(seg(t, 1.8, sec.t1)); // slow push-in while the title is read- cam(cx, cy, z, lerp(-.03, 0, k));- table();- regTape(BAN[0], BAN[1], BW, BH);- sheetShadow(BAN[0], BAN[1], BW, BH, .25);- ctx.save(); ctx.translate(BAN[0], BAN[1]);- drawBanner(ctx, C, { pal: pal(C.banner_time || 'golden'), T, sky: p, title: seg(t, sec.title[0], sec.title[1]), footer: seg(t, sec.footer[0], sec.footer[1]), reg: 1 });- ctx.restore();- // wet-ink sheen: freshly pulled ink shines for a stretch behind the squeegee, travels with it and slowly goes matte- const wet = 1 - seg(t, sec.sky[1], sec.sky[1] + .8);- if (p > 0 && wet > 0) {- ctx.save(); ctx.globalAlpha = wet; ctx.beginPath(); ctx.rect(BAN[0] + 14, BAN[1] + 14, Math.max(0, sqX - BAN[0] - 14), BANNER_ART[3]); ctx.clip();- const g = ctx.createLinearGradient(sqX - 420, 0, sqX, 0); g.addColorStop(0, 'rgba(255,250,235,0)'); g.addColorStop(.6, 'rgba(255,250,235,.08)'); g.addColorStop(1, 'rgba(255,250,235,.34)');- ctx.fillStyle = g; ctx.fillRect(sqX - 420, BAN[1], 420, BH);- ctx.restore();+// ---------------- Beijing (shots 1–3) ----------------+const prog1 = (t) => (k) => { const v = P1[k]; if (!v) return 0; return seg(t, v[0], v[0] + v[1]); };+const ANG = -.08;+function beijing(t) {+ const [cx, cy, z] = camAt(K1, t);+ cam(cx, cy, z);+ const pal = PAL.beijingDawn, P = PRINTS.beijing, prog = prog1(t);+ drawPrint(ctx, P, { pal, T, prog, angle: ANG, reg: 1, imprint: SIGN });+ // wet sheen behind the blade on the big pulls, dry within ~0.6 s+ for (const k of ['sky1', 'sky2', 'mid', 'near']) {+ const [a, d] = P1[k], u = seg(t, a, a + d), dry = seg(t, a + d, a + d + .6);+ if (u <= 0 || dry >= 1) continue;+ const f = tiltFront(u, ANG), mx = (f.a[0] + f.b[0]) / 2, my = (f.a[1] + f.b[1]) / 2;+ const g = ctx.createLinearGradient(mx - f.lead[0] * 260, my - f.lead[1] * 260, mx, my);+ g.addColorStop(0, 'rgba(255,250,235,0)'); g.addColorStop(.75, `rgba(255,250,235,${.06 * (1 - dry)})`); g.addColorStop(1, `rgba(255,250,235,${.18 * (1 - dry)})`);+ ctx.save(); ctx.fillStyle = g; ctx.translate(mx, my); ctx.rotate(ANG); ctx.fillRect(-1400, -260, 2800, 262); ctx.restore();}- const lift = seg(t, sec.lift, sec.lift + .45);- const box = [BAN[0] - 90, BAN[1] - 90, BW + 180, BH + 180];- const emu = new Path2D(); emu.rect(box[0], box[1], box[2], box[3]); emu.rect(BAN[0] + 14, BAN[1] + 14, BW - 28, BANNER_ART[3]);- if (lift < 1) screenFrame(ctx, box, { lift: ss(lift), frame: 40, mesh: 'rgba(236,214,128,.03)', emulsion: emu, emulsionAlpha: .55, meshStep: 3.4, meshLine: 'rgba(70,60,30,.16)' });- // squeegee (split fountain: the ink bead on the blade is segmented by the sky colour bands)- if (t < sec.lift + .35) {- const bp = pal(C.banner_time || 'golden');- const up = ss(seg(t, sec.lift, sec.lift + .35));- const x = sqX + 14 + up * 120, y0 = BAN[1] - 38, y1 = BAN[1] + BH + 38;- const tt = (yy) => (yy - y0) / (y1 - y0);- ctx.save(); ctx.globalAlpha = 1 - up;- const BB = BANNER_BANDS;- squeegee(ctx, [x, y0], [x, y1], [1, 0], { beads: [['sky2', bp.sky2], ['sky1', bp.sky1], ['far', bp.far]].map(([k, c]) => ({ t0: tt(BAN[1] + BB[k][0] + 16), t1: tt(BAN[1] + BB[k][1]), color: c })), seed: 3, scale: 1.25, roll: sqX / 30 });- ctx.restore();- }- // title squeegee (one quick pull, dark ink)- const tp = seg(t, sec.title[0], sec.title[1]);- if (tp > 0 && tp < 1) {- const x = wipeFront([BAN[0], BAN[1] + 20, BW, 330], 'right', tp, 40) + 12;- squeegee(ctx, [x, BAN[1] - 38], [x, BAN[1] + BH + 38], [1, 0], { color: pal(C.banner_time || 'golden').near, seed: 5, roll: x / 30, scale: 1.25 });+ mesh(seg(t, LIFT1, LIFT1 + .45));+ for (const k of Object.keys(INK_OF)) {+ const [a, d] = P1[k], u = seg(t, a, a + d);+ if (u <= 0 || u >= 1) continue;+ const f = tiltFront(u, ANG), o = 16;+ squeegee(ctx, [f.a[0] + f.lead[0] * o, f.a[1] + f.lead[1] * o], [f.b[0] + f.lead[0] * o, f.b[1] + f.lead[1] * o], f.lead,+ { color: pal[INK_OF[k]], seed: a * 10 + 3, roll: (f.a[1] + f.b[1]) / 60, scale: 1.3, handle: .4, shadow: .18 });}}-// Shared drawing of a poster on the print table-function posterOnTable(P, st) {- regTape(PO[0], PO[1], PW, PH);- sheetShadow(PO[0], PO[1], PW, PH, .22);- ctx.save(); ctx.translate(PO[0], PO[1]); drawPoster(ctx, P, st); ctx.restore();+// ======================================================================================================+// Shots 4–11+// ======================================================================================================+let OZ = [W / 2, H / 2, 1]; // screen-space zoom wrapped around everything (the push into the stub)+function camS(cx, cy, z) { CAM = [cx, cy, z]; ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.translate(W / 2, H / 2); ctx.scale(OZ[2], OZ[2]); ctx.translate(-OZ[0], -OZ[1]); ctx.translate(W / 2, H / 2); ctx.scale(z, z); ctx.translate(-cx, -cy); }+function screenS() { ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.translate(W / 2, H / 2); ctx.scale(OZ[2], OZ[2]); ctx.translate(-OZ[0], -OZ[1]); }+const sp = (t, v) => v ? seg(t, v[0], v[0] + v[1]) : 0;+const fmt = (n) => Math.round(n).toLocaleString('en-US');++// a re-ink sweep in screen space: everything behind the blade is the next print+const SW_BOX = [-500, -500, W + 1000, H + 1000];+function swRegion(p, ang, seed) { const m = new DOMMatrix().translate(W / 2, H / 2).rotate(ang * 180 / Math.PI).translate(-W / 2, -H / 2); const o = new Path2D(); o.addPath(wipeRegion(SW_BOX, 'down', p, seed, 50, 7), m); return o; }+function swFront(p, ang) {+ const y = -500 - 50 + p * (H + 1000 + 100), m = new DOMMatrix().translate(W / 2, H / 2).rotate(ang * 180 / Math.PI).translate(-W / 2, -H / 2);+ const a = m.transformPoint(new DOMPoint(-500, y)), b = m.transformPoint(new DOMPoint(W + 500, y)), d = m.transformPoint(new DOMPoint(0, 1)), o = m.transformPoint(new DOMPoint(0, 0));+ return { a: [a.x, a.y], b: [b.x, b.y], lead: [d.x - o.x, d.y - o.y] };+}+function sweep(p, ang, drawA, drawB, beads, seed = 3) {+ if (p <= 0) { drawA(); return; }+ if (p >= 1) { drawB(); return; }+ drawA();+ ctx.save(); ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clip(swRegion(p, ang, seed)); drawB(); ctx.restore();+ ctx.save(); ctx.setTransform(1, 0, 0, 1, 0, 0);+ const f = swFront(p, ang), o = 22, L = Math.hypot(f.b[0] - f.a[0], f.b[1] - f.a[1]);+ const bd = beads.length === 1 ? [{ t0: 0, t1: 1, color: beads[0] }] : beads.map((c, i) => ({ t0: i / beads.length + .004, t1: (i + 1) / beads.length, color: c }));+ squeegee(ctx, [f.a[0] + f.lead[0] * o, f.a[1] + f.lead[1] * o], [f.b[0] + f.lead[0] * o, f.b[1] + f.lead[1] * o], f.lead, { beads: bd, seed, roll: p * 40, scale: 1.6, handle: .35, shadow: .16 });+ ctx.restore();}-const pullProg = (sec, id, t) => { const k = id === 'sun' ? 'sky' : id; const a = sec.pulls[k] ?? sec.pulls.near; return seg(t, a, a + sec.pullDur); };-function planeGroup(id) { return id === 'sun' ? 'sky' : ['main', 'spurA', 'spurB', 'spurC'].includes(id) ? 'mid' : id; }-function press(sec, t) {- const P = POS[sec.i], pl = pal(P.trail.time_of_day);- // camera: tilts down from the banner to the full poster → pushes in to the info band- const tilt = eio(seg(t, sec.tilt[0], sec.tilt[1]));- const push = eio(seg(t, sec.push[0], sec.push[1]));- const full = [0, PO[1] + PH / 2 - 10, .66];- const bandC = [0, PO[1] + 1290, 1.55];- let cx = lerp(0, full[0], tilt), cy = lerp(0, full[1], tilt), z = lerp(.96 * 1.03, full[2], tilt);- cx = lerp(cx, bandC[0], push); cy = lerp(cy, bandC[1], push); z = lerp(z, bandC[2], push);- z *= 1 + .02 * seg(t, sec.items[0], sec.t1);- cam(cx, cy, z); table();- if (tilt < 1) { ctx.save(); ctx.translate(BAN[0], BAN[1]); sheetShadow(0, 0, BW, BH, .25); drawBanner(ctx, C, { pal: pal(C.banner_time || 'golden'), T }); ctx.restore(); }- const st = { pal: pl, T, prog: id => pullProg(sec, planeGroup(id), t), band: seg(t, sec.band, sec.band + .3), name: seg(t, sec.name, sec.name + .3), header: seg(t, sec.name, sec.name + .3), trail: seg(t, sec.band, sec.band + .6), items: sec.items.map(a => seg(t, a, a + .18)) };- posterOnTable(P, st);- // screen + squeegee- const lift = seg(t, sec.lift, sec.lift + .4);- const box = [PO[0] - 70, PO[1] - 70, PW + 140, PH + 140];- if (lift < 1) screenFrame(ctx, box, { lift: ss(lift), frame: 44 });- for (const k of ['sky', 'far', 'mid', 'near']) {- const a = sec.pulls[k], p = seg(t, a, a + sec.pullDur);- if (p > 0 && p < 1) {- const y = PO[1] + wipeFront([0, ART[1] - 60, PW, ART[3] + 120], 'down', clamp(p * 1.35), 30) - 60 + 14;- const inkKey = k === 'sky' ? 'sky1' : k === 'far' ? P.sc.planes.find(q => q.id === 'far').parts[0].ink : k === 'mid' ? 'mid' : 'near';- squeegee(ctx, [PO[0] - 30, y], [PO[0] + PW + 30, y], [0, 1], { color: pl[inkKey], seed: a * 10, roll: y / 30, scale: 1.3 });- }+// the screen frame bar crossing the frame (art or screen units): y1 = lower edge of the mesh+function meshAt(y1, w = W, h = H, bar = true) {+ ctx.save(); ctx.beginPath(); ctx.rect(-100, -100, w + 200, y1 + 100); ctx.clip();+ ctx.fillStyle = 'rgba(236,214,128,.05)'; ctx.fillRect(-100, -100, w + 200, h + 200);+ ctx.strokeStyle = 'rgba(60,52,30,.14)'; ctx.lineWidth = .4; ctx.beginPath();+ for (let x = -60; x < w + 60; x += 6) { ctx.moveTo(x, -60); ctx.lineTo(x, h + 60); }+ for (let y = -60; y < h + 60; y += 6) { ctx.moveTo(-60, y); ctx.lineTo(w + 60, y); }+ ctx.stroke(); ctx.restore();+ if (bar && y1 < h + 40) {+ ctx.save(); ctx.globalAlpha = .22; ctx.fillStyle = '#000'; ctx.fillRect(-100, y1 + 34, w + 200, 40);+ ctx.globalAlpha = 1; ctx.fillStyle = '#B7B2A6'; ctx.fillRect(-100, y1, w + 200, 34);+ ctx.fillStyle = '#D6D1C4'; ctx.fillRect(-100, y1, w + 200, 5); ctx.fillStyle = '#8E897E'; ctx.fillRect(-100, y1 + 28, w + 200, 6);+ ctx.fillStyle = '#3C6E9E'; ctx.fillRect(-100, y1 - 10, w + 200, 10); ctx.restore();}}-// Transition through foreground tree shadows (screen-space occluder, colour = the previous poster's near-layer ink)+// screen-space foreground silhouette (old cypresses) crossing right to left; it covers the frame for about one frame at t0function treeWipe(t, t0, color) {const u = seg(t, t0 - .3, t0 + .3); if (u <= 0 || u >= 1) return;ctx.save(); ctx.setTransform(1, 0, 0, 1, 0, 0);- const w = W * 1.25, cxw = lerp(W + w / 2 + 120, -w / 2 - 120, ss(u)), x = cxw - w / 2; // at the midpoint it exactly covers the frame (about 1 frame); the next poster swaps in then- const p = new Path2D(); p.moveTo(x, -20);- for (let y = -20; y <= H + 20; y += 40) p.lineTo(x - 50 - 70 * hash(y * .37), y);- for (let y = H + 20; y >= -20; y -= 40) p.lineTo(x + w + 60 + 80 * hash(y * .61 + 3), y);- p.closePath(); ctx.fillStyle = color; ctx.fill(p);- ctx.restore();+ const w = W * 1.25, cx = lerp(W + w / 2 + 160, -w / 2 - 160, ss(u)), x = cx - w / 2;+ const p = new Path2D(); p.moveTo(x, -40);+ for (let y = -40; y <= H + 40; y += 60) { const b = 70 + 90 * hash(y * .37); p.quadraticCurveTo(x - b, y + 30, x - b * .4, y + 60); }+ p.lineTo(x + w, H + 40);+ for (let y = H + 40; y >= -40; y -= 60) { const b = 70 + 110 * hash(y * .61 + 3); p.quadraticCurveTo(x + w + b, y - 30, x + w + b * .3, y - 60); }+ p.closePath(); ctx.fillStyle = color; ctx.fill(p); ctx.restore();}-function quick(sec, t) {- const P = POS[sec.i], pl = pal(P.trail.time_of_day);- const back = eio(seg(t, sec.back[0], sec.back[1]));- const s = seg(t, sec.t0 - .3, sec.back[0]);- const close = [0, PO[1] + 400 + 40 * s, 1.25 + .04 * s]; // the full sheet width and top edge are in frame, so it's clear which poster this is; the poster fills 100% of the frame height- const bandC = [0, PO[1] + 1300, 1.5]; // the info band is fully in frame, ~13% margin each side- const cx = lerp(close[0], bandC[0], back), cy = lerp(close[1], bandC[1], back), z = lerp(close[2], bandC[2], back);- cam(cx, cy, z); table();- posterOnTable(P, { pal: pl, T, prog: id => pullProg(sec, planeGroup(id), t), band: seg(t, sec.band, sec.band + .25), name: seg(t, sec.name, sec.name + .3), header: seg(t, sec.far ?? sec.name, sec.name + .3), trail: seg(t, sec.band, sec.band + .5), items: sec.items.map(a => seg(t, a, a + .18)) });+// stub state for a city at time t+function stubCity(t, o, day, km, label, value) {+ return { panel: sp(t, o.panel), rows: { day: { p: sp(t, o.day), n: day }, big: { p: sp(t, o.big), label: 'FROM HOME', value: km }, small: { p: sp(t, o.small), label, value } } };}+function stubReturn(t, day) {+ const u = ss(seg(t, SEA.count[0], SEA.count[1]));+ const home = Math.round(lerp(FAR, 0, u) / 10) * 10, trav = Math.round(lerp(TRAV0, TRAV1, u) / 10) * 10, live = u > 0 && u < 1;+ return { panel: 1, rows: { day: { p: 1, n: day }, big: { p: 1, label: 'FROM HOME', value: fmt(home), live }, small: { p: 1, label: 'TRAVELLED', value: fmt(trav) + ' KM', live } } };+}+function stubDraw(pal, s, seed) { screenS(); drawStub(ctx, { pal, T, panel: s.panel, rows: s.rows, seed }); }-// ---- Wall (visitor centre): layout -----function wallLayout() {- // banner (4:1) hung centred above the posters; the height budget first guarantees the values are ≥30 px once the posters are on the wall (s ≥ .47)- const n = POS.length, gap = 54, maxW = 1700;- const bw0 = Math.min(1150, W * .62), bh0 = BH * bw0 / BW;- const s = Math.min((maxW - (n - 1) * gap) / n / PW, (H - 44 - bh0 - 26) / PH, .62);- const pw = PW * s, ph = PH * s, total = n * pw + (n - 1) * gap;- const bw = bw0, bs = bw / BW, bh = BH * bs;- const top = Math.max(14, (H - 30 - (bh + 26 + ph)) / 2);- const x0 = (W - total) / 2;- return { s, pw, ph, bs, bh, banner: [(W - bw) / 2, top], posters: POS.map((_, i) => [x0 + i * (pw + gap), top + bh + 26]) };+// ---- one city print, with its own camera ----+function cityIst(t) {+ camS(lerp(960, 900, ss(seg(t, 10.3, 14.2))), lerp(540, 520, ss(seg(t, 10.3, 14.2))), lerp(1, 1.04, ss(seg(t, 10.3, 14.2))));+ const prog = (k) => sp(t, IST[k]);+ drawArt(ctx, SC.istanbul, { pal: PAL.istanbul, T, prog, angle: -.06, seed: 21, header: { text: 'ISTANBUL', zh: '伊斯坦布尔', p: sp(t, IST.header) } });+ for (const k of ['sky', 'far', 'mid', 'near', 'acc', 'lit']) {+ const u = sp(t, IST[k]); if (u <= 0 || u >= 1) continue;+ const f = tiltFrontS(u, -.06, SC.istanbul), o = 16, ink0 = { sky: 'sky2', far: 'far', mid: 'mid', near: 'near', acc: 'sun', lit: 'glow' }[k];+ squeegee(ctx, [f.a[0] + f.lead[0] * o, f.a[1] + f.lead[1] * o], [f.b[0] + f.lead[0] * o, f.b[1] + f.lead[1] * o], f.lead, { color: PAL.istanbul[ink0], seed: IST[k][0] * 10, roll: (f.a[1] + f.b[1]) / 60, scale: 1.3, handle: .4, shadow: .18 });+ }+ stubDraw(PAL.istanbul, stubCity(t, IST, 6, '7,060', 'HAGIA SOPHIA', 'BUILT 537'), 61);}-function wall(t, glint = -1) {- const Lw = wallLayout(), wp = C.palette.wall || { board: '#5E4432', groove: '#3F2C21', rail: '#8A6547' };- ctx.fillStyle = wp.board; ctx.fillRect(-2000, -2000, 6000, 6000);- ctx.fillStyle = wp.groove; for (let x = -1200; x < 3200; x += 96) ctx.fillRect(x, -2000, 5, 6000);- ctx.fillStyle = mix(wp.board, '#ffffff', .07); for (let x = -1200; x < 3200; x += 96) ctx.fillRect(x + 5, -2000, 3, 6000);- ctx.fillStyle = wp.rail; ctx.fillRect(-2000, H - 44, 6000, 18); ctx.fillStyle = wp.groove; ctx.fillRect(-2000, H - 26, 6000, 2000);- // banner- const [bx, by] = Lw.banner;- ctx.save(); ctx.globalAlpha = .35; ctx.fillStyle = '#1a120c'; ctx.fillRect(bx + 10, by + 12, BW * Lw.bs, BH * Lw.bs); ctx.restore();- ctx.save(); ctx.translate(bx, by); ctx.scale(Lw.bs, Lw.bs); drawBanner(ctx, C, { pal: pal(C.banner_time || 'golden'), T }); ctx.restore();- POS.forEach((P, i) => {- const [x, y] = Lw.posters[i];- ctx.save(); ctx.globalAlpha = .35; ctx.fillStyle = '#1a120c'; ctx.fillRect(x + 12, y + 14, Lw.pw, Lw.ph); ctx.restore();- ctx.save(); ctx.translate(x, y); ctx.scale(Lw.s, Lw.s); drawPoster(ctx, P, { pal: pal(P.trail.time_of_day), T }); ctx.restore();- // push pins- ctx.fillStyle = '#C9C2B2'; for (const dx of [18, Lw.pw - 18]) { ctx.beginPath(); ctx.arc(x + dx, y + 16, 5, 0, 7); ctx.fill(); }- });- return Lw;+function tiltFrontS(p, angle, S) {+ const W0 = S.w || AW, H0 = S.h || AH, box = [-300, -300, W0 + 600, H0 + 600], y = -300 - 34 + p * (H0 + 600 + 68);+ const m = new DOMMatrix().translate(W0 / 2, H0 / 2).rotate(angle * 180 / Math.PI).translate(-W0 / 2, -H0 / 2);+ const a = m.transformPoint(new DOMPoint(-300, y)), b = m.transformPoint(new DOMPoint(W0 + 300, y)), d = m.transformPoint(new DOMPoint(0, 1)), o = m.transformPoint(new DOMPoint(0, 0));+ return { a: [a.x, a.y], b: [b.x, b.y], lead: [d.x - o.x, d.y - o.y] };}--function ascent(sec, t) {- const P = POS[sec.i], Lw = wallLayout(), [wx, wy] = Lw.posters[sec.i];- const u = seg(t, sec.climb[0], sec.climb[1]);- const ue = u < .5 ? ss(u * 2) * .5 * .7 + u * .3 : .5 + (1 - Math.pow(1 - (u - .5) * 2, 2)) * .5; // slow start, steady middle, decelerates at the top- // camera (poster units): valley floor → summit (rising within one shot)- const start = [520, 800, 2.3], top = [500, 400, 2.06], band = [500, 1300, 1.72];- let cx = lerp(start[0], top[0], ue), cy = lerp(start[1], top[1], ue), z = lerp(start[2], top[2], ue);- const dn = eio(seg(t, sec.down[0], sec.down[1]));- cx = lerp(cx, band[0], dn); cy = lerp(cy, band[1], dn); z = lerp(z, band[2], dn);- z *= 1 + .025 * ss(seg(t, sec.items[0], sec.t1)); // very slow push-in while the numbers are read- // per-layer parallax: near layers sink faster; each ridge parts to the sides as the camera passes it, and at the top everything returns and clicks into register- const settle = seg(t, sec.climb[1], sec.clack);- const loose = 1 - ss(seg(t, sec.clack - .02, sec.clack + .04));- const pass = { near: .12, spurC: .3, spurB: .5, spurA: .7, main: .95 };- const off = (id, pl) => {- const f = pl.depth, dy = (top[1] - cy) * (f - 1) * .42;- const side = pl.side || 0, pu = pass[id] ?? 1;- const bump = Math.exp(-Math.pow((u - pu) / .16, 2)) * (1 - settle);- const sx = side * 190 * bump * (f - .3);- const jig = loose * 5 * (1 - settle * .6);- return [(sx + jig * Math.sin(f * 9)) * loose, (dy + bump * 40 * (f - .3) + jig * Math.cos(f * 7)) * loose];- };- // colour swap: the same poster is reprinted whole as time passes (noon → afternoon → dusk)- const pals = sec.pals.map(pal); const nS = pals.length - 1;- const swapTimes = pals.slice(1).map((_, k) => lerp(sec.climb[0], sec.climb[1], (k + 1) / (nS + 1)));- let base = pals[0], swap = null;- swapTimes.forEach((st, k) => { const p = seg(t, st, st + .35); if (p >= 1) base = pals[k + 1]; else if (p > 0) swap = { pal: pals[k + 1], p, dir: 'up' }; });- // convert to wall coordinates- cam(wx + cx * Lw.s, wy + cy * Lw.s, z / Lw.s);- wall(t);- ctx.save(); ctx.translate(wx, wy); ctx.scale(Lw.s, Lw.s);- const ANG = -.21;- if (swap) swap.angle = ANG;- const sep = loose * (settle > 0 ? 1 - .5 * settle : 1) * clamp(u * 6);- drawPoster(ctx, P, { pal: base, T, off, reg: .35 + loose * 1.25, sep, swap, trail: clamp(u * 1.08), band: seg(t, sec.band, sec.band + .3), name: seg(t, sec.name, sec.name + .3), header: 1, items: sec.items.map(a => seg(t, a, a + .18)) });- // colour-swap reprint: one big squeegee pushes up across the whole poster- if (swap) { // big diagonal squeegee: shows only the blade, the ink bead and a section of handle- const [a0, a1] = swapFrontLine(swap.p, ANG), dx = a1[0] - a0[0], dy = a1[1] - a0[1], L = Math.hypot(dx, dy);- const nrm = [dy / L, -dx / L]; // direction of travel (biased upward)- const off2 = 26;- squeegee(ctx, [a0[0] + nrm[0] * -off2, a0[1] + nrm[1] * -off2], [a1[0] + nrm[0] * -off2, a1[1] + nrm[1] * -off2], nrm, { color: swap.pal.sky2, scale: 1.1, seed: 11, shadow: .1, handle: .3, roll: t * 40 });+function cityParis(t, stub = true) {+ const u = eio(seg(t, PAR.crane[0], PAR.crane[1])), cy = lerp(1080, 540, u);+ camS(960, cy, 1);+ const loose = lerp(.35, .9, seg(t, PAR.swap[0], BA.swap[0]));+ const off = (pull, d) => [Math.sin(d * 9 + 1) * 6 * loose, (1080 - cy) * (d - .4) * .32 + Math.cos(d * 7) * 5 * loose];+ drawArt(ctx, SC.paris, { pal: PAL.paris, T, angle: -.06, seed: 23, off, sep: loose, reg: 1 + loose, header: { text: 'PARIS', zh: '巴黎', p: sp(t, PAR.header) } });+ if (stub) stubDraw(PAL.paris, stubCity(t, PAR, 11, '8,220', 'EIFFEL TOWER', 'BUILT 1889'), 63);+}+function cityBoca(t, stub = true) {+ const u = ss(seg(t, BA.truck[0], BA.truck[1])), cx = lerp(960, 1640, u);+ camS(cx, 540, 1);+ const loose = lerp(.8, 1.6, seg(t, BA.swap[0], PUSH.t0 + 1));+ const off = (pull, d) => [(cx - 960) * (d - .5) * .22 + Math.sin(d * 11 + t * .7) * 7 * loose, Math.cos(d * 5 + t * .6) * 6 * loose];+ const prog = (k) => k === 'near' ? sp(t, BA.near) : k === 'acc' ? sp(t, BA.acc) : 1;+ drawArt(ctx, SC.boca, { pal: PAL.boca, T, prog, angle: -.05, seed: 25, off, sep: loose * .8, reg: 1 + loose, header: { text: 'BUENOS AIRES', zh: '布宜诺斯艾利斯', p: sp(t, BA.header) } });+ for (const k of ['near', 'acc']) {+ const v = sp(t, BA[k]); if (v <= 0 || v >= 1) continue;+ const f = tiltFrontS(v, -.05, SC.boca), o = 16;+ squeegee(ctx, [f.a[0] + f.lead[0] * o, f.a[1] + f.lead[1] * o], [f.b[0] + f.lead[0] * o, f.b[1] + f.lead[1] * o], f.lead, { color: PAL.boca[k === 'near' ? 'near' : 'sun'], seed: 7, roll: (f.a[1] + f.b[1]) / 60, scale: 1.3, handle: .4, shadow: .18 });}- ctx.restore();+ if (stub) stubDraw(PAL.boca, stubCity(t, BA, 19, '19,270', 'OBELISCO', 'BUILT 1936'), 65);+}+function citySea(t) {+ const cx = lerp(4300, 1100, ss(seg(t, SEA.truck[0], SEA.truck[1])));+ camS(cx, 540, 1);+ const off = (pull, d) => [Math.sin(d * 9 + t) * 5, Math.cos(d * 6 + t * .8) * 6 * d];+ drawArt(ctx, SC.sea, { pal: PAL.sea, T, angle: -.05, seed: 27, off, sep: .9, reg: 1.8 });+ stubDraw(PAL.sea, stubReturn(t, 24), 67);+}+function cityHome(t, pal, night) {+ const snapped = t >= HOME.snap, k = 1 - ss(seg(t, HOME.snap - .02, HOME.snap + .05));+ const loose = snapped ? k : 1;+ const off = (pull, d) => [Math.sin(d * 9 + t * .9 + 1) * 36 * d * loose, (Math.cos(d * 6 + t * .7) * 26 * d - 18 * d) * loose];+ const pu = eio(seg(t, HOME.push[0], HOME.push[1]));+ camS(960, 540, 1);+ drawArt(ctx, SC.temple, { pal, T, angle: -.08, seed: 29, off, sep: loose, reg: snapped ? 0.35 * (1 - k) + 1 * k : 1.6, header: { text: 'BEIJING', zh: '北京', p: 1 } });+ stubDraw(pal, stubReturn(t, 30), 69);}-function wallShot(sec, t) {- const Lw = wallLayout(), last = POS.length - 1, [wx, wy] = Lw.posters[last];- const k = eio(seg(t, sec.pull[0], sec.pull[1]));- const from = [wx + 500 * Lw.s, wy + 1300 * Lw.s, 1.72 * 1.025 / Lw.s];- const cx = lerp(from[0], W / 2, k), cy = lerp(from[1], H / 2, k), z = Math.exp(lerp(Math.log(from[2]), 0, k));- cam(cx, cy, z * (1 + .012 * seg(t, sec.hold0, sec.t1)));- wall(t);- // ink-film sheen: a diagonal glint slowly sweeps across the three posters (only on inked areas, very faint)- const g = seg(t, sec.hold0 + .6, sec.hold0 + 3.2);- if (g > 0 && g < 1) {- ctx.save(); ctx.beginPath(); Lw.posters.forEach(([x, y]) => ctx.rect(x, y, Lw.pw, Lw.ph)); ctx.rect(Lw.banner[0], Lw.banner[1], BW * Lw.bs, BH * Lw.bs); ctx.clip();- const gx = lerp(-300, W + 300, ss(g)), gr = ctx.createLinearGradient(gx - 220, 0, gx + 220, 0);- gr.addColorStop(0, 'rgba(255,248,230,0)'); gr.addColorStop(.5, 'rgba(255,248,230,.10)'); gr.addColorStop(1, 'rgba(255,248,230,0)');- ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.transform(1, 0, -.35, 1, 190, 0); ctx.fillStyle = gr; ctx.fillRect(-400, 0, W + 800, H);- ctx.restore();+function shotsLater(t, s) {+ OZ = [W / 2, H / 2, 1];+ if (s.n === 4) {+ if (t < IST.cover) beijing(t); else cityIst(t);+ treeWipe(t, IST.cover, PAL.beijingDawn.near);+ } else if (s.n === 5) {+ const p = sp(t, PAR.swap);+ sweep(p, -.32, () => cityIst(t), () => cityParis(t), [PAL.paris.sky2, PAL.paris.sky1, PAL.paris.far, PAL.paris.near], 5);+ } else if (s.n === 6) {+ const p = sp(t, BA.swap);+ sweep(p, -.28, () => cityParis(t), () => cityBoca(t), BOCA_INKS, 9);+ } else if (s.n === 7) {+ const u = eio(seg(t, PUSH.t0, PUSH.t1)), u2 = seg(t, PUSH.t1, CLAMP);+ OZ = [lerp(W / 2, 1655, u), lerp(H / 2, 498, u), Math.exp(lerp(0, Math.log(5.2), u)) * (1 + .13 * u2)];+ cityBoca(t);+ screenS(); meshAt(lerp(-260, H + 60, ss(sp(t, PUSH.mesh))));+ } else if (s.n === 8) {+ const jolt = t < CLAMP + .12 ? Math.sin((t - CLAMP) * 90) * 3 * (1 - (t - CLAMP) / .12) : 0;+ const z0 = 5.2 * 1.13, u = eo(seg(t, SEA.out[0], SEA.out[1]));+ OZ = [lerp(1655, W / 2, u), lerp(498, H / 2, u) + jolt, Math.exp(lerp(Math.log(z0), 0, u))];+ const p = sp(t, SEA.swap);+ sweep(p, -.3, () => cityBoca(t), () => citySea(t), [PAL.sea.sky2, PAL.sea.sky1, PAL.sea.mid, PAL.sea.near], 11);+ const lift = sp(t, SEA.lift);+ if (lift < 1) { screenS(); meshAt(lerp(H + 60, -300, ss(lift))); }+ } else if (s.n === 9) {+ const p = sp(t, HOME.swap);+ sweep(p, -.3, () => citySea(t), () => cityHome(t, PAL.beijingDusk), [PAL.beijingDusk.sky1, PAL.beijingDusk.sky2, PAL.beijingDusk.mid, PAL.beijingDusk.near], 13);+ } else {+ const pu = eio(seg(t, HOME.push[0], HOME.push[1]));+ OZ = [lerp(W / 2, 1010, pu), lerp(H / 2, 520, pu), lerp(1, 1.035, pu)];+ const p = sp(t, HOME.night);+ sweep(p, -.3, () => cityHome(t, PAL.beijingDusk), () => cityHome(t, PAL.beijingNight), [PAL.beijingNight.sky1, PAL.beijingNight.sky2, PAL.beijingNight.sun, PAL.beijingNight.near], 15);+ const c1 = sp(t, HOME.card1), c2 = sp(t, HOME.card2);+ if (c1 > 0) {+ screenS(); drawEndCard(ctx, PAL.beijingNight, T, c1, c2);+ for (const [v, pal, k] of [[c1, PAL.beijingNight.near, 'down'], [c2, PAL.beijingNight.sun, 'right']]) {+ if (v <= 0 || v >= 1) continue;+ if (k === 'down') { const y = 236 - 20 - 40 + v * (600 + 40 + 80); squeegee(ctx, [1270, y + 12], [1890, y + 12], [0, 1], { color: pal, seed: 3, roll: y / 30, scale: 1.2, handle: .35, shadow: .16 }); }+ else { const x = 1300 - 50 + v * (560 + 100); squeegee(ctx, [x + 12, 200], [x + 12, 870], [1, 0], { color: pal, seed: 4, roll: x / 30, scale: 1.2, handle: .35, shadow: .16 }); }+ }+ }}+ OZ = [W / 2, H / 2, 1];}-// Ending: the last pull — the closing information is printed as a small landscape poster (a split-fountain pull prints the picture, a second pull prints the info band)-let END_CACHE = null;-function endShapes() {- if (END_CACHE) return END_CACHE;- const far = [[-20, 600]]; for (let x = 0; x <= W + 40; x += 40) far.push([x, 470 - 70 * Math.abs(Math.sin(x * .0042 + .4)) - 30 * Math.abs(Math.sin(x * .013))]); far.push([W + 20, 600]);- const mid = [[-20, 620], [0, 540], [260, 470], [520, 520], [760, 430], [900, 360], [1010, 410], [1180, 500], [1420, 470], [1660, 530], [1940, 500], [1940, 620]];- const lit = [[900, 360], [1010, 410], [1180, 500], [1080, 505], [960, 430]];- const trail = []; for (let k = 0; k < 9; k++) trail.push([640 + k * 30 + (k % 2) * 12, 560 - k * 22]);- return (END_CACHE = { far: polyPath(far), mid: polyPath(mid), lit: polyPath(lit), trail });-}-function endCard(sec, t) {- cam(W / 2, H / 2, 1); wall(t);- const pl = pal(POS[POS.length - 1].trail.time_of_day), E0 = endShapes();- const p1 = seg(t, sec.t0, sec.t0 + .55), p2 = seg(t, sec.t0 + .5, sec.t0 + .8);- const M = 36, ART_B = 610;+// ---------------- subtitles: a printed strip (near ink, paper-coloured type), pulled on with each line ----------------+const SUB_INK = '#1B1F34';+function subtitle(t) {+ if (NOCAP) return;+ const c = CUES.find(q => t >= q.t0 && t < q.t1); if (!c) return;+ const pIn = seg(t, c.t0, c.t0 + .12), pOut = seg(t, c.t1 - .1, c.t1);ctx.setTransform(1, 0, 0, 1, 0, 0);- // paper (a whole fresh sheet, appearing with the first pull)- const c1 = wipeRegion([0, 0, W, H], 'right', p1, 3, 60, 8);- ctx.save(); ctx.clip(c1); paperSheet(ctx, T, 0, 0, W, H, 1.1);- ctx.save(); ctx.beginPath(); ctx.rect(M, M, W - 2 * M, ART_B - M); ctx.clip();- ink(ctx, { path: rectPath(0, 0, W, H), knock: ringPath(1660, 350, 128, 146) }, { color: pl.sky1, sheen: 1 });- const top = new Path2D(); top.rect(0, 0, W, 120); for (let i = 0; i < 5; i++) { const cell = 26, th = cell * (1 - (i + .5) / 5) * .95 + 2; top.rect(0, 120 + i * cell, W, th); }- ink(ctx, { path: top }, { color: pl.sky2, reg: [1.5, .8], sheen: 1, trap: .4 });- ink(ctx, { path: circlePath(1660, 350, 108) }, { color: pl.sun, reg: [3, 1.5], sheen: 1 });- ink(ctx, { path: E0.far }, { color: pl.far, reg: [-1, 1], sheen: 1, trap: 1 });- ink(ctx, { path: E0.mid }, { color: pl.mid, reg: [1.2, -.8], sheen: 1, trap: 1 });- ink(ctx, { path: E0.lit }, { color: pl.glow || pl.sky2, reg: [1.2, -.8], sheen: 1 });- ctx.strokeStyle = pl.sun; ctx.lineWidth = 7; E0.trail.forEach(([x, y]) => { ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x + 16, y - 11); ctx.stroke(); });- ctx.restore();- ink(ctx, { paint: (c) => { c.font = '900 118px BigShoulders'; c.letterSpacing = '3px'; c.textAlign = 'center'; c.fillText(C.title.toUpperCase(), W / 2 - 60, 300); } }, { color: pickInk([pl.sky1, pl.sky2], [pl.near, pl.mid], 3), reg: [2, -1] });- ctx.restore();- // second pull: info band + credit- if (p2 > 0) {- const c2 = p2 < 1 ? wipeRegion([0, ART_B, W, H - ART_B], 'right', p2, 9, 50, 8) : null;- ink(ctx, { path: rectPath(M, ART_B + 12, W - 2 * M, H - ART_B - 12 - M) }, { color: pl.near, clip: c2, sheen: 1 });- const hi = pickInk(pl.near, [pl.sky1, pl.sun], 4.5), lo = pickInk(pl.near, [pl.sky2, pl.glow, pl.sky1], 3.5);- ink(ctx, { paint: (c) => { c.textAlign = 'center';- c.font = '700 40px Outfit'; c.letterSpacing = '14px'; c.fillStyle = pl.sun; c.fillText('SILKSCREEN TRAVEL POSTER', W / 2, ART_B + 100);- c.fillStyle = pl.sun; c.fillRect(W / 2 - 420, ART_B + 128, 840, 5);- c.fillStyle = hi; c.font = '600 38px Outfit'; c.letterSpacing = '9px'; c.fillText('LEMO-OPUSCAR', W / 2, ART_B + 196); c.fillText('LEMOLAB × CLAUDE OPUS 5.5', W / 2, ART_B + 248);- c.fillStyle = lo; c.font = '500 24px Outfit'; c.letterSpacing = '3px';- c.fillText('FONTS: BIG SHOULDERS DISPLAY, OUTFIT (SIL OFL)', W / 2, ART_B + 322);- c.fillText('SAMPLES: VCSL, VSCO 2 CE, KARORYFER (CC0) · ARTWORK, GUITARS & SOUND MADE IN CODE', W / 2, ART_B + 360);- } }, { color: hi, clip: c2, reg: [1.2, .6] });- }- inkFinish(ctx, T, 0, 0, W, H, 1.1, p1 >= 1 ? 1 : 0);- // squeegee- if (p1 > 0 && p1 < 1) { const x = wipeFront([0, 0, W, H], 'right', p1, 60); const BB = [[pl.sky2, 0, .28], [pl.sky1, .28, .5], [pl.far, .5, .6]];- squeegee(ctx, [x + 10, -40], [x + 10, H + 40], [1, 0], { beads: BB.map(([c, a, b]) => ({ t0: a + .04, t1: b, color: c })), scale: 1.6, seed: 9, roll: x / 30 }); }- if (p2 > 0 && p2 < 1) { const x = wipeFront([0, ART_B, W, H - ART_B], 'right', p2, 50); squeegee(ctx, [x + 10, ART_B - 10], [x + 10, H + 40], [1, 0], { color: pl.near, scale: 1.4, seed: 4, roll: x / 30 }); }+ ctx.font = `600 40px NotoSC`; ctx.letterSpacing = '2px'; const wz = ctx.measureText(c.zh).width;+ ctx.font = `500 28px ${FONT_T}`; ctx.letterSpacing = '.6px'; const we = ctx.measureText(c.en).width;+ const w = Math.max(wz, we) + 76, h = 118, x = (W - w) / 2, y = H - 46 - h;+ ctx.save();+ if (pIn < 1) ctx.clip(wipeRegion([x, y, w, h], 'right', pIn, 7 + c.id.length, 26, 5));+ if (pOut > 0) { const r = new Path2D(); r.rect(x + w * pOut, y - 10, w, h + 20); ctx.clip(r); }+ ink(ctx, { path: rectPath(x, y, w, h) }, { color: SUB_INK, sheen: .6 });+ ink(ctx, { paint: (g) => {+ g.textAlign = 'center'; g.textBaseline = 'alphabetic';+ g.font = `600 40px NotoSC`; g.letterSpacing = '2px'; g.fillText(c.zh, W / 2, y + 54);+ g.font = `500 28px ${FONT_T}`; g.letterSpacing = '.6px'; g.fillText(c.en, W / 2, y + 96);+ } }, { color: PAPER, reg: [1.2, -.8] });+ inkFinish(ctx, T, x, y, w, h, .7, .8);+ ctx.restore(); ctx.letterSpacing = '0px';}export function render(t) {- const sec = TL.secs.find(s => t >= s.t0 && t < s.t1) || TL.secs[TL.secs.length - 1];- ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.fillStyle = TABLE; ctx.fillRect(0, 0, W, H);- if (sec.kind === 'banner') banner(sec, t);- else if (sec.kind === 'press') press(sec, t);- else if (sec.kind === 'quick') quick(sec, t);- else if (sec.kind === 'ascent') ascent(sec, t);- else if (sec.kind === 'wall') wallShot(sec, t);- else endCard(sec, t);- // tree-shadow transitions between sections- TL.secs.forEach((s, k) => { if ((s.kind === 'quick' || s.kind === 'ascent') && Math.abs(t - s.t0) < .3) { const prev = TL.secs[k - 1]; treeWipe(t, s.t0, pal(prev.P.trail.time_of_day).near); } });+ ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.fillStyle = PAPER; ctx.fillRect(0, 0, W, H);+ const s = SHOTS.find(q => t >= q.t0 && t < q.t1) || SHOTS[SHOTS.length - 1];+ if (s.n <= 3) beijing(t); else shotsLater(t, s);+ subtitle(t);ctx.setTransform(1, 0, 0, 1, 0, 0);}-export const getTL = () => TL;++// every on-screen text at t (pixels), for readcheck; live counters are left out until they stop+export function texts(t) {+ const out = [], s = SHOTS.find(q => t >= q.t0 && t < q.t1) || SHOTS[SHOTS.length - 1];+ const push = (id, text, b) => { if (b[0] < 0 || b[1] < 0 || b[2] > W || b[3] > H) return; out.push({ id, text, x0: b[0], y0: b[1], x1: b[2], y1: b[3] }); };+ const z = (b) => { const f = (x, y) => [W / 2 + (x - OZ[0]) * OZ[2], H / 2 + (y - OZ[1]) * OZ[2]]; const [a, c] = f(b[0], b[1]), [d, e] = f(b[2], b[3]); return [a, c, d, e]; };+ const world = (b) => { const [x0, y0] = toScreen(b[0], b[1]), [x1, y1] = toScreen(b[2], b[3]); return z([x0, y0, x1, y1]); };+ if (s.n <= 3) {+ const [cx, cy, zz] = camAt(K1, t); CAM = [cx, cy, zz]; OZ = [W / 2, H / 2, 1];+ const prog = prog1(t);+ for (const b of textBoxes(PRINTS.beijing)) if (prog(b.pull) >= 1) push(b.id, b.text, world(b.box));+ return out;+ }+ // replay the camera of the current shot without drawing+ shotsLaterCam(t, s);+ const city = s.n === 4 ? (t >= IST.cover ? ['istanbul', IST, 'ISTANBUL', '伊斯坦布尔', stubCity(t, IST, 6, '7,060', 'HAGIA SOPHIA', 'BUILT 537')] : null)+ : s.n === 5 ? ['paris', PAR, 'PARIS', '巴黎', stubCity(t, PAR, 11, '8,220', 'EIFFEL TOWER', 'BUILT 1889')]+ : s.n === 6 || s.n === 7 ? ['boca', BA, 'BUENOS AIRES', '布宜诺斯艾利斯', stubCity(t, BA, 19, '19,270', 'OBELISCO', 'BUILT 1936')]+ : s.n === 8 ? ['sea', null, null, null, stubReturn(t, 24)] : ['temple', null, 'BEIJING', '北京', stubReturn(t, 30)];+ if (!city) return out;+ const [key, o, en, zh, st] = city;+ if (en && (!o || sp(t, o.header) >= 1) && !(s.n >= 10 && t >= HOME.card1[0])) for (const b of headerBoxes(SC[key], { text: en, zh })) push(b.id, b.text, world(b.box));+ if (!(t >= HOME.card1[0])) for (const b of stubBoxes(st.rows)) if (b.p >= 1 && !b.live) push(b.id, b.text, z(b.box));+ if (t >= HOME.card2[0] + HOME.card2[1]) for (const [id, text, y0, y1] of [['card-title', 'THE LONG WAY HOME', 260, 450], ['card-zh', '绕远路回家', 460, 510], ['card-style', 'SILKSCREEN TRAVEL POSTER', 580, 616], ['card-style-zh', '丝印旅行海报', 626, 662], ['card-sign', 'LemoLab × Claude Opus 5.5', 730, 762]]) push(id, text, z([1340, y0, 1830, y1]));+ return out;+}+// camera only (for texts): same maths as shotsLater, no drawing+function shotsLaterCam(t, s) {+ OZ = [W / 2, H / 2, 1];+ if (s.n === 4) { const u = ss(seg(t, 10.3, 14.2)); CAM = [lerp(960, 900, u), lerp(540, 520, u), lerp(1, 1.04, u)]; }+ else if (s.n === 5) { const u = eio(seg(t, PAR.crane[0], PAR.crane[1])); CAM = [960, lerp(1080, 540, u), 1]; }+ else if (s.n === 6 || s.n === 7) {+ CAM = [lerp(960, 1640, ss(seg(t, BA.truck[0], BA.truck[1]))), 540, 1];+ if (s.n === 7) { const u = eio(seg(t, PUSH.t0, PUSH.t1)), u2 = seg(t, PUSH.t1, CLAMP); OZ = [lerp(W / 2, 1655, u), lerp(H / 2, 498, u), Math.exp(lerp(0, Math.log(5.2), u)) * (1 + .13 * u2)]; }+ } else if (s.n === 8) { const u = eo(seg(t, SEA.out[0], SEA.out[1])); OZ = [lerp(1655, W / 2, u), lerp(498, H / 2, u), Math.exp(lerp(Math.log(5.2 * 1.13), 0, u))]; CAM = [lerp(4300, 1100, ss(seg(t, SEA.truck[0], SEA.truck[1]))), 540, 1]; }+ else { CAM = [960, 540, 1]; if (s.n >= 10) { const pu = eio(seg(t, HOME.push[0], HOME.push[1])); OZ = [lerp(W / 2, 1010, pu), lerp(H / 2, 520, pu), lerp(1, 1.035, pu)]; } }+}+diff --git a/styles/silkscreen-poster/demo/fonts/OFL-LeagueGothic.txt b/styles/silkscreen-poster/demo/fonts/OFL-NotoSansSC.txtsimilarity index 97%rename from styles/silkscreen-poster/demo/fonts/OFL-LeagueGothic.txtrename to styles/silkscreen-poster/demo/fonts/OFL-NotoSansSC.txtindex 06b467d..1c9f432 100644--- a/styles/silkscreen-poster/demo/fonts/OFL-LeagueGothic.txt+++ b/styles/silkscreen-poster/demo/fonts/OFL-NotoSansSC.txt@@ -1,4 +1,4 @@-Copyright 2010 The League Gothic Project Authors (https://github.com/theleagueof/league-gothic)+Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'This Font Software is licensed under the SIL Open Font License, Version 1.1.This license is copied below, and is also available with a FAQ at:diff --git a/styles/silkscreen-poster/demo/fonts/fonts.css b/styles/silkscreen-poster/demo/fonts/fonts.cssindex 1042069..6b260a1 100644--- a/styles/silkscreen-poster/demo/fonts/fonts.css+++ b/styles/silkscreen-poster/demo/fonts/fonts.css@@ -1,3 +1,3 @@-@font-face { font-family: 'BigShoulders'; src: url(BigShouldersDisplay.ttf) format('truetype'); font-weight: 100 900; font-display: block; }-@font-face { font-family: 'Outfit'; src: url(Outfit.ttf) format('truetype'); font-weight: 100 900; font-display: block; }-@font-face { font-family: 'LeagueGothic'; src: url(LeagueGothic.ttf) format('truetype'); font-weight: 400; font-display: block; }+@font-face { font-family: 'BigShoulders'; src: url(BigShouldersDisplaywght.ttf) format('truetype'); font-weight: 100 900; font-display: block; }+@font-face { font-family: 'Outfit'; src: url(Outfitwght.ttf) format('truetype'); font-weight: 100 900; font-display: block; }+@font-face { font-family: 'NotoSC'; src: url(NotoSansSCwght.ttf) format('truetype'); font-weight: 100 900; font-display: block; }diff --git a/styles/silkscreen-poster/demo/index.html b/styles/silkscreen-poster/demo/index.htmlindex c7771ed..6b24ffe 100644--- a/styles/silkscreen-poster/demo/index.html+++ b/styles/silkscreen-poster/demo/index.html@@ -1,5 +1,5 @@<!doctype html>-<html><head><meta charset="utf-8"><title>Three Trails</title>+<html><head><meta charset="utf-8"><title>The Long Way Home</title><link rel="stylesheet" href="fonts/fonts.css"><style>html,body{margin:0;background:#000;overflow:hidden}canvas{display:block}</style></head><body><canvas id="c" width="1920" height="1080"></canvas>diff --git a/styles/silkscreen-poster/demo/main.js b/styles/silkscreen-poster/demo/main.jsindex 02a813b..20d214c 100644--- a/styles/silkscreen-poster/demo/main.js+++ b/styles/silkscreen-poster/demo/main.js@@ -1,8 +1,12 @@-import { setup, render } from './film.js';+// Page contract: ?a=&b= renders the [a, b) stretch of the film clock (seconds); &sign=1 prints an optional imprint in the corner; &nocap=1 leaves the subtitles out (stills).+import { setup, render, texts } from './film.js';const Q = new URLSearchParams(location.search);-await Promise.all(['900 40px BigShoulders', '800 40px BigShoulders', '500 40px Outfit', '600 40px Outfit', '700 40px Outfit', '800 40px Outfit'].map(f => document.fonts.load(f)));-const content = await (await fetch(Q.get('content') || 'content.json')).json();-const TL = setup(content, document.getElementById('c'));-window.DUR = TL.dur; window.EV = TL.ev; window.TL = TL.secs.map(s => ({ kind: s.kind, t0: s.t0, t1: s.t1 }));-window.render = t => render(t);+await Promise.all(['900 40px BigShoulders', '800 40px BigShoulders', '500 40px Outfit', '600 40px Outfit', '700 40px Outfit', '600 40px NotoSC'].map(f => document.fonts.load(f, f.includes('NotoSC') ? '外公' : 'A')));+const cues = await (await fetch('voice/cues.json')).json();+const TL = setup(document.getElementById('c'), { cues, sign: Q.get('sign') === '1', nocap: Q.get('nocap') === '1' });+const A = +(Q.get('a') ?? 0), Bn = +(Q.get('b') ?? TL.dur);+window.DUR = +(Bn - A).toFixed(3);+window.EV = TL.ev.filter(e => e.t >= A - 1e-6 && e.t < Bn).map(e => ({ ...e, t: +(e.t - A).toFixed(3) }));+window.render = t => render(t + A);+window.TEXTS = t => texts(t + A);window.READY = true;diff --git a/styles/silkscreen-poster/demo/mix.py b/styles/silkscreen-poster/demo/mix.pyindex fe6e693..71d7dfb 100644--- a/styles/silkscreen-poster/demo/mix.py+++ b/styles/silkscreen-poster/demo/mix.py@@ -1,185 +1,183 @@-"""mix.py · silkscreen travel poster: ambience bed + foley + score → mix.wav-Run from the repo root: .venv/bin/python styles/silkscreen-poster/demo/mix.py-All sync points come from demo/events.json (exported by node core/render/events.mjs); the score comes from music/score.wav (music/compose.py).-Materials: squeegee = rubber blade on nylon mesh (a mid-high "hiss" with mesh grain); ink = a wet, sticky low "gloop"; screen = aluminium frame + hinge spring; paper = short, dry mids.-"""+"""mix.py · voice + score + foley + ambience → out/mix.wav, for the [a, b) stretch of the whole-film clock.+ .venv/bin/python styles/silkscreen-poster/demo/mix.py [a b] (default 0 50)+Sync points come from events.json (node core/render/events.mjs, whole film), the score from music/score.wav,+the voice from out/voice/*.wav (Kokoro, made by build.sh) at the times in voice/cues.json.+Foley by material: squeegee = rubber blade over nylon mesh (band-passed noise with a ~250 Hz mesh grain, faster = brighter);+ink = a wet low squelch; screen = aluminium frame clack + hinge creak; stats = paper stamps + ticks.+Balance: voice compressed, then set ~10 dB (RMS) over the music; music dips 300 Hz–4 kHz and ducks under the voice."""import json, os, sys-import numpy as np-import soundfile as sf-ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..'))+import numpy as np, soundfile as sf+D = os.path.dirname(os.path.abspath(__file__))+ROOT = os.environ.get('LIB') or os.path.abspath(os.path.join(D, '../../..'))sys.path.insert(0, os.path.join(ROOT, 'core/audio'))from sfx import SR, t_, env_exp, bp, lp, hp, noise, norm, brown, clack, creak, thump, whoosh, compress, limit, add+from scipy.ndimage import maximum_filter1d, uniform_filter1d+from scipy.signal import resample_poly-D = os.path.dirname(os.path.abspath(__file__))-E = json.load(open(os.path.join(D, 'events.json')))-DUR = E['dur'] + 1.5-N = int(DUR * SR)+A = float(sys.argv[1]) if len(sys.argv) > 2 else 0.0+Bt = float(sys.argv[2]) if len(sys.argv) > 2 else 50.0+EVJ = json.load(open(os.path.join(D, 'events.json')))+EV = EVJ['ev']+TOT = 50.0 + 2+N = int(TOT * SR)rng = np.random.default_rng(11)-amb = np.zeros((N, 2)); fol = np.zeros((N, 2))-ev = [e for e in E['ev']]-def evs(tp): return [e for e in ev if e['type'] == tp]-def first(tp, **kw):- for e in ev:- if e['type'] == tp and all(e.get(k) == v for k, v in kw.items()): return e-def fade(x, a=.01, b=.05):- n1, n2 = int(a * SR), int(b * SR); x = x.copy()- if n1: x[:n1] *= np.linspace(0, 1, n1)- if n2: x[-n2:] *= np.linspace(1, 0, n2)- return x+amb = np.zeros((N, 2)); fol = np.zeros((N, 2)); vox = np.zeros((N, 2))+tt = np.arange(N) / SR+def evs(tp, **kw): return [e for e in EV if e['type'] == tp and all(e.get(k) == v for k, v in kw.items())]# ---------------- foley building blocks -----------------def scrape(d, v=1.0, bright=1.0, heavy=0.0, attack=.02):- """Squeegee across the mesh: broadband noise → band-pass; mesh grain = 180–320 Hz amplitude modulation; faster = brighter"""- n = noise(d); tt = t_(d)- grain = .65 + .35 * np.abs(np.sin(2 * np.pi * (220 + 60 * bright) * tt + rng.random() * 6)) ** 2- x = bp(n, 700 * bright, min(9000, 5200 * bright), 2) * grain- x += lp(noise(d), 380) * (.5 + heavy) * .6 # low end of the blade pressing the paper- e = np.minimum(1, tt / max(attack, 1e-3)) * np.minimum(1, (d - tt) / .06) * (1 - .25 * tt / d)- return norm(x * e) * v-def squelch(v=1.0, f=140):- """Wet "gloop" of the ink bead squeezing: falling low sine + viscous noise"""- d = .16; tt = t_(d)- x = np.sin(2 * np.pi * f * tt * (1 - .9 * tt)) * env_exp(d, .05) + lp(noise(d), 900) * env_exp(d, .03) * .5- return norm(x) * v-def tick(v=1.0, f=3200):- d = .03; tt = t_(d)- return norm(hp(noise(d), 2500) * env_exp(d, .003) + np.sin(2 * np.pi * f * tt) * env_exp(d, .004) * .4) * v-def stamp(v=1.0):- """Data block lands: dull thud on paper + a touch of scrape"""- d = .14; tt = t_(d)- x = lp(noise(d), 1200) * env_exp(d, .012) + np.sin(2 * np.pi * 160 * tt) * env_exp(d, .03) * .7 + bp(noise(d), 2500, 6000) * env_exp(d, .006) * .4- return norm(x) * v-def rustle(d=.6, v=1.0):- """Pine needles brushing past: crumbly high-frequency noise + grain"""- tt = t_(d); crack = (rng.random(len(tt)) > .993) * rng.standard_normal(len(tt)) * 4- x = bp(noise(d), 2000, 8000) * .6 + hp(crack, 3000)- return norm(x * np.sin(np.pi * tt / d) ** 1.5) * v-def paperslide(d=.35, v=1.0):- tt = t_(d); x = bp(noise(d), 900, 4200) * (.7 + .3 * np.sin(2 * np.pi * 31 * tt))- return norm(x * np.sin(np.pi * tt / d) ** 2) * v-def regclack(v=1.0):- """Registration clamp closes: wood knock + short metallic ring (the most important sound in the film)"""- d = .6; tt = t_(d)- wood = sum(a * np.sin(2 * np.pi * f * tt) * env_exp(d, tau) for f, a, tau in [(520, 1, .03), (1180, .6, .02), (240, .8, .05)])- metal = sum(a * np.sin(2 * np.pi * f * tt + p) * env_exp(d, tau) for f, a, tau in [(2410, .5, .18), (3890, .3, .12), (5230, .18, .08)] for p in [0])- tr = hp(noise(d), 3000) * env_exp(d, .002) * 1.2- return norm(wood + metal + tr) * v+def scrape(d, bright=1.0, heavy=0.0, attack=.02):+ n = noise(d); x_t = t_(d)+ grain = .65 + .35 * np.abs(np.sin(2 * np.pi * (230 + 50 * bright) * x_t + rng.random() * 6)) ** 2+ x = bp(n, 700 * bright, min(9000, 5200 * bright), 2) * grain + lp(noise(d), 380) * (.5 + heavy) * .6+ e = np.minimum(1, x_t / max(attack, 1e-3)) * np.minimum(1, (d - x_t) / .06) * (1 - .25 * x_t / d)+ return norm(x * e)+def squelch(f=140):+ d = .16; x_t = t_(d)+ return norm(np.sin(2 * np.pi * f * x_t * (1 - .9 * x_t)) * env_exp(d, .05) + lp(noise(d), 900) * env_exp(d, .03) * .5)+def tick(f=3200):+ d = .03; x_t = t_(d)+ return norm(hp(noise(d), 2500) * env_exp(d, .003) + np.sin(2 * np.pi * f * x_t) * env_exp(d, .004) * .4)+def stamp():+ d = .14; x_t = t_(d)+ return norm(lp(noise(d), 1200) * env_exp(d, .012) + np.sin(2 * np.pi * 160 * x_t) * env_exp(d, .03) * .7 + bp(noise(d), 2500, 6000) * env_exp(d, .006) * .4)+def gull(d=.5):+ x_t = t_(d); f = np.interp(x_t, [0, .08, .3, d], [1500, 2300, 1900, 1400])+ tone = np.sin(2 * np.pi * np.cumsum(f) / SR) + .4 * np.sin(4 * np.pi * np.cumsum(f) / SR)+ return norm(bp(tone * (1 + .4 * np.sin(2 * np.pi * 28 * x_t)), 900, 5000) * np.sin(np.pi * x_t / d) ** 1.5)++# ---------------- ambience ----------------+def seg_env(a, b, fi, fo): return np.clip(np.minimum((tt - a) / max(fi, 1e-3), (b - tt) / max(fo, 1e-3)), 0, 1)+room = lp(brown(TOT), 240) * .5 + bp(noise(TOT), 150, 900) * .07 # print-shop room tone, the whole film+amb[:, 0] += room * .045; amb[:, 1] += room * .043+wake = evs('wake')[0]['t'] # Beijing wakes up inside the print (J-cut, 0.5 s before the lift):+wind = (lp(noise(TOT), 900) * .6 + bp(noise(TOT), 1500, 5000) * .08) * (.55 + .45 * np.sin(2 * np.pi * .13 * tt + .7) ** 2) # morning air in old cypresses+wenv = seg_env(wake, 10.6, .9, .4) * (1 - .4 * np.clip((tt - evs('push')[0]['t']) / 1.2, 0, 1))+amb[:, 0] += wind * wenv * .035; amb[:, 1] += np.roll(wind, 900) * wenv * .035+def chirp(d=.09, f0=3800, f1=5200):+ x_t = t_(d); f = np.linspace(f0, f1, len(x_t)); return norm(np.sin(2 * np.pi * np.cumsum(f) / SR) * np.sin(np.pi * x_t / d) ** 2)+r2 = np.random.default_rng(4)+for k in range(14): # sparrows and magpie chatter in the park, panned wide+ t0 = wake + .6 + k * .38 + r2.random() * .2+ for j in range(1 + int(r2.random() * 3)): add(amb, chirp(.06 + .05 * r2.random(), 3000 + 1800 * r2.random(), 3600 + 2200 * r2.random()), t0 + j * .09, .006 + .004 * r2.random(), r2.uniform(-.8, .8))-# ---------------- ambience beds -----------------def seg_env(a, b, fi, fo):- tt = np.arange(N) / SR- return np.clip(np.minimum((tt - a) / max(fi, 1e-3), (b - tt) / max(fo, 1e-3)), 0, 1)-tt_all = np.arange(N) / SR-# Print studio: low room tone + distant birds outside the window (0 → 13.2, more audible in the banner section)-room = lp(brown(DUR), 260) * .5 + bp(noise(DUR), 150, 900) * .08-lift1 = first('lift', i=0)['t']; wipe1 = first('wipe', i=1)['t']-studio = room * seg_env(-1, wipe1 + .1, .01, .4) * .05-amb[:, 0] += studio; amb[:, 1] += studio * .95-for t0 in [2.3, 3.6, 6.4]: # little birds outside the window (very quiet, panned right)- d = .22; x = np.sin(2 * np.pi * np.cumsum(3200 + 900 * np.sin(2 * np.pi * 14 * t_(d))) / SR) * env_exp(d, .08)- add(amb, x, t0, .012, .6)-# Early-morning lakeside inside the picture: fades in as the screen lifts (water lapping + one loon call), until the transition ends-w = lp(noise(DUR), 500) * (.6 + .4 * np.sin(2 * np.pi * .7 * tt_all) ** 2)-lake = w * seg_env(lift1, wipe1 + .2, .6, .3) * .05-amb[:, 0] += lake * .9; amb[:, 1] += lake-d = 1.4; loon = np.sin(2 * np.pi * np.cumsum(np.interp(t_(d), [0, .3, 1.1, 1.4], [760, 1020, 980, 900])) / SR) * np.sin(np.pi * t_(d) / d) * (1 + .15 * np.sin(2 * np.pi * 6 * t_(d)))-add(amb, lp(loon, 2500), lift1 + .5, .02, -.4)-# Waterfall: J-cut, swells up from below 0.9 s before the end of poster 1, cut before the silence-sil_pre = first('silence', pre=1)-fall = (bp(noise(DUR), 250, 5000) * .7 + lp(brown(DUR), 180) * .6)-fenv = seg_env(wipe1 - .9, sil_pre['t'] + .15, .9, .5)-amb[:, 0] += fall * fenv * .07; amb[:, 1] += fall * fenv * .075-# Mountain wind: J-cut (enters 0.6 s early during the silence), gets stronger and brighter with altitude; L-cut carries it past the pull-out to the wall-asc = first('ascent'); wallp = first('wallpull'); land = first('land')-g = lp(noise(DUR), 900) * .6 + bp(noise(DUR), 900, 3500) * .25-gust = .55 + .45 * np.sin(2 * np.pi * .23 * tt_all + 1) * np.sin(2 * np.pi * .11 * tt_all)-height = np.clip((tt_all - asc['t']) / asc['dur'], 0, 1)-wind = g * gust * (.5 + .7 * height) * seg_env(asc['t'] - .6, land['t'] + .9, .6, 1.1) * .06-amb[:, 0] += wind; amb[:, 1] += np.roll(wind, 900)-# Visitor-centre interior: takes over from the mountain wind at the pull-out to the wall; light crowd walla (band-passed noise with syllable modulation), a distant door, footsteps on wooden floor-mur = bp(noise(DUR), 250, 1800) * (.5 + .5 * np.abs(np.sin(2 * np.pi * 3.1 * tt_all + np.sin(2 * np.pi * .7 * tt_all) * 3)))-mur = mur * seg_env(wallp['t'] + .5, DUR, .9, 1.5) * .022-amb[:, 0] += mur; amb[:, 1] += np.roll(mur, 2400)-add(amb, thump(.5, 80), land['t'] + 1.7, .06, -.7) # distant door-for k in range(4): add(amb, bp(noise(.06), 300, 2000) * env_exp(.06, .012), land['t'] + 2.2 + k * .52, .05, .6 - k * .15)++# each city wakes up inside its print (J-cut a beat before it is printed) and hands over to the next one+WK = {e['place']: e['t'] for e in evs('wake')}+def bed(x, a, b, g, fi=.6, fo=.4, roll=700):+ en = seg_env(a, b, fi, fo); amb[:, 0] += x * en * g; amb[:, 1] += np.roll(x, roll) * en * g+swell = .55 + .45 * np.sin(2 * np.pi * .16 * tt + 1.2) ** 2+water = (lp(noise(TOT), 650) * .7 + bp(noise(TOT), 1200, 4500) * .12) * swell+bed(water, WK['istanbul'], WK['paris'] + .5, .045) # Istanbul: the strait, gulls, a ferry horn+for t0, pan, gn in [(WK['istanbul'] + .9, .5, .02), (WK['istanbul'] + 1.7, .3, .014), (WK['istanbul'] + 3.0, -.4, .012)]: add(amb, gull(.45 + .1 * pan), t0, gn, pan)+d = 1.3; x_t = t_(d); horn = (np.sin(2 * np.pi * 146 * x_t) + .5 * np.sin(2 * np.pi * 292 * x_t) + .25 * np.sin(2 * np.pi * 438 * x_t)) * np.minimum(1, x_t / .08) * np.minimum(1, (d - x_t) / .4)+add(amb, lp(horn, 1500), WK['istanbul'] + 1.9, .03, -.5)+street = bp(noise(TOT), 250, 1800) * (.5 + .5 * np.abs(np.sin(2 * np.pi * 2.7 * tt + np.sin(2 * np.pi * .6 * tt) * 3)))+bed(street, WK['paris'], WK['boca'] + .5, .018, roll=2400) # Paris: a street murmur, a bicycle bell+d = .5; x_t = t_(d); bell = (np.sin(2 * np.pi * 2350 * x_t) + .6 * np.sin(2 * np.pi * 3720 * x_t)) * np.exp(-x_t / .12)+add(amb, bell, WK['paris'] + 1.6, .02, .4); add(amb, bell, WK['paris'] + 1.78, .016, .4)+breeze = (lp(noise(TOT), 1000) * .6 + bp(noise(TOT), 1500, 5000) * .1) * (.5 + .5 * np.sin(2 * np.pi * .21 * tt) ** 2)+bed(street * .8 + breeze * .5, WK['boca'], evs('silence')[0]['t'] + .2, .02, roll=1800) # Buenos Aires: street and harbour wind, thinning into the silence+bed(breeze, evs('silence')[0]['t'] - .1, WK['sea'] + .2, .012) # the silence: only wind+bed(water * .9 + breeze * .3, WK['sea'], WK['home'] + .6, .05) # the night sea+crick = bp(noise(TOT), 4200, 6500) * (np.sin(2 * np.pi * 24 * tt) > .2) * (.5 + .5 * np.sin(2 * np.pi * 1.6 * tt) ** 8)+bed(wind * .7, WK['home'], 52, .03) # home: evening air in the cypresses, then crickets at night+bed(crick, WK['night'], 52, .012, fi=1.2)# ---------------- foley -----------------for e in ev:+for e in EV:t, tp = e['t'], e['type']- if tp == 'squeegee':- dd = e['dur']- if e['ink'] == 'sky': # opening squeegee: already mid-pull (no attack), left to right- x = scrape(dd, .8, 1.0, .3, attack=.003)- n = len(x); pan = np.linspace(-.3, .5, n)- s0 = int(t * SR); fol[s0:s0 + n, 0] += x * np.cos((pan + 1) * np.pi / 4) * 1.2; fol[s0:s0 + n, 1] += x * np.sin((pan + 1) * np.pi / 4) * 1.2- add(fol, squelch(.8, 120), t + .03, .35, 0)+ if tp == 'pull':+ d = e['dur']; L = e['layer']+ if L == 'sun': # already mid-pull at frame 0: no attack, slower (close-up), bright+ add(fol, scrape(d, 1.0, .3, attack=.003), t, .5, -.1); add(fol, squelch(120), t + .03, .25, 0)else:- add(fol, scrape(dd, .75, 1.25, .1), t, .7 if e['ink'] == 'title' else .45, .1)+ n = ['sky1', 'sky2', 'far', 'mid', 'near', 'acc', 'lit', 'sky'].index(L) % 7+ add(fol, scrape(d, 1.0 + .1 * n, .2), t, .42 if L not in ('acc', 'lit') else .3, -.25 + .08 * n)+ add(fol, squelch(150 + 15 * n), t, .18, 0)elif tp == 'lift':- add(fol, clack(.65, 1), t, .35, 0); add(fol, creak(1), t + .05, .18, .2); add(fol, whoosh(.3, 1), t + .02, .12, 0)- add(fol, tick(.8, 1800), t + .32, .15, .25) # spring- elif tp == 'pull':- dd = e['dur']; q = e.get('quick', 0)- add(fol, scrape(dd, 1, 1.1 + .15 * e['n'] + (.25 if q else 0), .2), t, .55 if not q else .45, -.2 + .15 * e['n'])- add(fol, squelch(1, 150 + 20 * e['n']), t, .22, 0)- elif tp == 'band':- add(fol, scrape(.34, 1, .9, .6), t, .6, -.2); add(fol, squelch(1, 110), t, .3, 0)- elif tp == 'name':- add(fol, scrape(.3, 1, 1.2, .3, attack=.004), t, .5, -.1); add(fol, squelch(1, 170), t, .35, 0); add(fol, thump(1, 95), t + .28, .22, 0)+ add(fol, clack(.65, 1), t, .3, 0); add(fol, creak(1), t + .04, .16, .2); add(fol, whoosh(.3, 1), t + .02, .1, 0); add(fol, tick(1800), t + .32, .12, .25)+ elif tp == 'stub':+ add(fol, scrape(e['dur'], .9, .6), t, .42, .5); add(fol, squelch(110), t, .2, .5)+ elif tp == 'header':+ add(fol, scrape(.3, 1.2, .3, attack=.004), t, .36, -.5); add(fol, squelch(170), t, .22, -.5); add(fol, thump(1, 95), t + .28, .14, -.4)elif tp == 'item':- add(fol, stamp(1), t, .8 if not e.get('climb') else .95, -.35 + .25 * e['k']); add(fol, tick(1, 2400), t, .25, -.35 + .25 * e['k'])+ add(fol, stamp(), t, .55 if not e.get('accent') else .7, .5); add(fol, tick(2400), t, .18, .5)+ elif tp == 'sign':+ add(fol, scrape(.24, 1.3, .2, attack=.004), t, .25, .4); add(fol, stamp(), t + .22, .3, .4)elif tp == 'wipe':- if e['i'] != 2: add(fol, rustle(.6, 1), t - .3, .32, .3); add(fol, whoosh(.55, 1), t - .28, .25, -.2)- elif tp in ('tilt', 'pullback', 'tiltdown'):- add(fol, whoosh(.5, 1), t, .07, 0)- elif tp == 'part':- add(fol, paperslide(.4, 1), t - .12, .22, -.5 if e['layer'] in ('spurA', 'spurC') else .5)- elif tp == 'swap':- add(fol, scrape(e['dur'] + .1, 1, .85, .8), t, .8 if e['k'] > 1 else .65, 0); add(fol, squelch(1, 95), t, .45, 0)- elif tp == 'clack':- add(fol, regclack(1), t, 1.0, 0); add(fol, thump(1, 60), t, .5, 0)- elif tp == 'wallpull':- add(fol, whoosh(1.1, 1), t, .1, 0)- elif tp == 'land':- add(fol, tick(1, 2600), t - .05, .12, .6) # push pin+ add(fol, whoosh(.6, 1), t, .2, 0); add(fol, bp(noise(.5), 1500, 7000) * np.sin(np.pi * t_(.5) / .5) ** 1.5, t + .05, .05, .3)+ elif tp == 'sweep':+ add(fol, scrape(e['dur'] + .1, .85, .8), t, .62, 0); add(fol, squelch(95), t, .35, 0)+ if e.get('fountain'): add(fol, squelch(130), t + .08, .25, -.3); add(fol, squelch(160), t + .16, .2, .3)+ elif tp == 'crane':+ add(fol, whoosh(1.6, 1), t + .2, .05, 0)+ for k in range(5): add(fol, bp(noise(.35), 900, 4200) * np.sin(np.pi * t_(.35) / .35) ** 2, t + .4 + k * .6, .06, -.4 + .2 * k)+ elif tp == 'truck':+ add(fol, whoosh(min(2.4, e['dur']), 1), t + .2, .045, 0)+ elif tp == 'bigpush':+ add(fol, whoosh(1.4, 1), t + .3, .05, 0)+ elif tp == 'meshdown':+ add(fol, creak(1), t, .14, .2); add(fol, clack(.6, 1), t + e['dur'], .22, 0)+ elif tp == 'clamp':+ d = .6; x_t = t_(d)+ wood = sum(a * np.sin(2 * np.pi * f * x_t) * env_exp(d, tau) for f, a, tau in [(520, 1, .03), (1180, .6, .02), (240, .8, .05)])+ metal = sum(a * np.sin(2 * np.pi * f * x_t) * env_exp(d, tau) for f, a, tau in [(2410, .5, .18), (3890, .3, .12), (5230, .18, .08)])+ add(fol, norm(wood + metal + hp(noise(d), 3000) * env_exp(d, .002) * 1.2), t, 1.0, 0); add(fol, thump(1, 60), t, .5, 0)+ elif tp == 'snap':+ d = .6; x_t = t_(d)+ wood = sum(a * np.sin(2 * np.pi * f * x_t) * env_exp(d, tau) for f, a, tau in [(480, 1, .03), (1100, .6, .02), (220, .9, .06)])+ add(fol, norm(wood + hp(noise(d), 3000) * env_exp(d, .002)), t, 1.0, 0); add(fol, thump(1, 55), t, .6, 0)+ elif tp == 'count':+ n = int(e['dur'] / .09)+ for k in range(n): u = k / n; add(fol, tick(2600 + 600 * u), t + e['dur'] * (1 - (1 - u) ** 1.0) , .05 + .02 * u, .55)+ elif tp == 'pullout':+ add(fol, whoosh(1.0, 1), t, .07, 0)elif tp == 'endpull':- add(fol, scrape(e['dur'], 1, 1.2, .4), t, .45, .1); add(fol, squelch(1, 120), t, .2, 0)- elif tp == 'endcard':- add(fol, scrape(.5, 1, 1.0, .4), t, .5, 0); add(fol, squelch(1, 100), t, .25, 0)-# Trail dashes printing one by one: while poster 1's info band prints + throughout the climb, a tiny "tick" every sixteenth note-B = .6-b0 = first('band', i=0)['t']-for k in range(4): add(fol, tick(1, 3600 + 200 * k), b0 + k * B / 4, .08, .3)-for k in range(int(asc['dur'] / (B / 2))): add(fol, tick(1, 3000 + 60 * (k % 5)), asc['t'] + .2 + k * B / 2, .07, -.2 + .03 * (k % 8))+ add(fol, scrape(e['dur'], 1.1, .4), t, .45, .5); add(fol, squelch(120), t, .22, .5)+ elif tp == 'push':+ add(fol, whoosh(.9, 1), t + .05, .06, 0)++# ---------------- voice ----------------+cues = json.load(open(os.path.join(D, 'voice/cues.json')))+for c in cues:+ x, sr = sf.read(os.path.join(D, 'out', 'voice', c['id'] + '.wav'))+ if x.ndim > 1: x = x.mean(1)+ x = resample_poly(x, SR, sr) if sr != SR else x+ x = hp(x, 80)+ x = compress(x / (np.abs(x).max() + 1e-9) * .9, thr=.22, ratio=3.0, att=.003, rel=.09)+ add(vox, x, c['vo'], 1.0, 0)-# ---------------- score + ducking ----------------+# ---------------- music ----------------mus, sr = sf.read(os.path.join(D, 'music/score.wav'), always_2d=True)-assert sr == SRm = np.zeros((N, 2)); L = min(N, len(mus)); m[:L] = mus[:L]-# Ducking: foley envelope → score down 2.5 dB (fast attack, slow release)-fe = np.abs(fol).max(axis=1)-from scipy.ndimage import maximum_filter1d, uniform_filter1d-fe = uniform_filter1d(maximum_filter1d(fe, int(.12 * SR)), int(.05 * SR))-duck = 1 - .25 * np.clip(fe / (fe.max() + 1e-9) * 3, 0, 1)+# make room for the voice: dip 300 Hz–4 kHz by ~4 dB all the time+mid = np.stack([bp(m[:, c], 300, 4000) for c in range(2)], 1)+m = m - mid * .37+# duck a further ~3 dB under speech+ve = np.abs(vox).max(1); ve = uniform_filter1d(maximum_filter1d(ve, int(.25 * SR)), int(.12 * SR))+duck = 1 - .3 * np.clip(ve / (ve.max() + 1e-9) * 4, 0, 1)m *= duck[:, None]-# Crescendo through the climb (a +3 dB envelope, as specified for the score)-ramp = 1 + .4 * np.clip((tt_all - asc['t']) / asc['dur'], 0, 1) * (tt_all < asc['t'] + asc['dur'])-m *= ramp[:, None]--# Silence windows: in the two silences, score and foley must be zero; ambience keeps only what is specified (waterfall tail / mountain wind)-for s in evs('silence'):- a, b = int((s['t'] + .03) * SR), int((s['t'] + s['dur'] - .005) * SR)- m[a:b] = 0; fol[a:b] *= 0- if s.get('pre'): amb[a:b] *= np.linspace(1, .35, b - a)[:, None]-# Inside the silence, keep only one very quiet pine-needle brush (the tree-shadow transition into the signature section)-w2 = [e for e in evs('wipe')][-1]-add(fol, rustle(.6, 1), w2['t'] - .3, .07, .3)-mix = m * .62 + fol * .55 + amb * 1.0-for c in range(2): mix[:, c] = limit(mix[:, c], .92)-assert np.isfinite(mix).all()-sf.write(os.path.join(D, 'mix.wav'), mix.astype(np.float32), SR, subtype='FLOAT')-print('mix.wav', f'{DUR:.2f}s', 'peak', f'{20*np.log10(np.abs(mix).max()):.1f} dBFS')-for s in evs('silence'):- a, b = int((s['t'] + .06) * SR), int((s['t'] + s['dur'] - .02) * SR)- print(f"silence {s['t']:.2f}-{s['t']+s['dur']:.2f} rms {20*np.log10(np.sqrt((mix[a:b]**2).mean())+1e-12):.1f} dBFS")+# balance: voice RMS (where speaking) ~10 dB above music RMS (where music plays) in this stretch+a0, b0 = int(A * SR), int(Bt * SR)+def rms(x, mask): return np.sqrt((x[mask] ** 2).mean() + 1e-12)+vmask = np.zeros(N, bool)+for c in cues:+ s0, s1 = int(c['vo'] * SR), int((c['vo'] + c['speech']) * SR); vmask[max(s0, a0):min(s1, b0)] = True+mmask = np.zeros(N, bool); mmask[a0:b0] = True; mmask &= np.abs(m).max(1) > 1e-4+vr, mr = rms(vox.mean(1), vmask), rms(m.mean(1), mmask)+mg = (vr / mr) / (10 ** (10 / 20))+m *= mg+for e in evs('silence'):+ a_, b_ = int((e['t'] + .02) * SR), int((e['t'] + e['dur'] - .005) * SR)+ m[a_:b_] = 0; fol[a_:b_] = 0+mix = m + fol * .55 + amb + vox+seg = mix[a0:b0 + int(.05 * SR)].copy()[:b0 - a0]+fo = int(.35 * SR); seg[-fo:] *= np.linspace(1, 0, fo)[:, None] ** 1.5 # a short fade at the very end of the span+for c in range(2): seg[:, c] = limit(seg[:, c], .92)+assert np.isfinite(seg).all()+os.makedirs(os.path.join(D, 'out'), exist_ok=True)+sf.write(os.path.join(D, 'out/mix.wav'), seg.astype(np.float32), SR, subtype='FLOAT')+vr2 = 20 * np.log10(rms(vox.mean(1), vmask)); mr2 = 20 * np.log10(rms(m.mean(1), mmask))+print(f'mix.wav {A}-{Bt}s voice rms {vr2:.1f} dB music rms {mr2:.1f} dB (gap {vr2 - mr2:.1f} dB) peak {20*np.log10(np.abs(seg).max()):.1f} dBFS')diff --git a/styles/silkscreen-poster/demo/music/compose.py b/styles/silkscreen-poster/demo/music/compose.pyindex fe695e1..8944170 100644--- a/styles/silkscreen-poster/demo/music/compose.py+++ b/styles/silkscreen-poster/demo/music/compose.py@@ -1,294 +1,115 @@-# compose.py · score for "Three Trails": American outdoor folk, 100 BPM, D major, open D tuning (DADF#AD)-# All sync points are read from ../events.json (if picture timing changes, rerun this script to realign).-#-# Instrumentation and sources (all CC0 or synthesized in code):-# - steel-string folk guitar: core/audio/pluck.py `acoustic_guitar` physical model (strums / rakes / arpeggios / single open-string notes)-# - slide guitar: synthesized in numpy in this file (phase integration for continuous slides, steel-string harmonics, body-resonance filter, slide friction noise, vibrato)-# - harmonica: core/audio/sampler.py `harmonica` (VCSL, CC0 1.0)-# - bass: sampler `jazz_bass` (Karoryfer Sneakybass, CC0 1.0)-# - drums: sampler `cajon` (VCSL, CC0 1.0) as the kick; `snare2:taps` (VCSL, CC0) + `shaker` (VCSL, CC0) as the brush groove;-# `sus_cymbal` (VSCO 2 CE, CC0 1.0) for the cymbal swell on reprint 2 and the cymbal at the peak-# - reverb: sampler.room()-# Run from the repo root: .venv/bin/python styles/silkscreen-poster/demo/music/compose.py+"""compose.py · original score for "The Long Way Home": a 108 BPM waltz in F major (3/4, bar = 1.6667 s), 30 bars = 50 s.+Each ink pull lands on a beat (events.json); the glockenspiel answers only the bright accent ink.++Shape: Beijing (bars 0-5, guitar waltz) → Istanbul (6-8, darbuka joins) → Paris (8-10, accordion musette tune)+→ Buenos Aires (10-12, the bass turns syncopated) → the push into the number (13-15: instruments leave one by one, nothing after 25.0 s)+→ silence → the clamp (bar 16 beat 3, 27.78 s) → the way home (17-21, guitar in eighths, harmonica joins) → the snap (bar 22, 36.67 s,+the loudest downbeat) → home (22-29, harmonica tune, the last F chord rings out).++Instruments (all CC0): guitar_nylon, accordion, world_perc (FreePats); jazz_bass (Karoryfer Sneakybass);+glockenspiel, harmonica, snare2 taps, shaker, cajon (VCSL); sus_cymbal (VSCO 2 CE).+Run from the library root: .venv/bin/python styles/silkscreen-poster/demo/music/compose.py → music/score.wav (+ music/stems/)."""import sys, os, json-ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..'))+HERE = os.path.dirname(os.path.abspath(__file__)); D = os.path.dirname(HERE)+ROOT = os.environ.get('LIB') or os.path.abspath(os.path.join(D, '../../..'))sys.path.insert(0, ROOT)import numpy as np, soundfile as sf-from scipy.signal import butter, sosfilt-from core.audio import sampler as S, pluck as P+from core.audio import sampler as Sfrom core.audio.sfx import SR, add-HERE = os.path.dirname(os.path.abspath(__file__))-EVJ = json.load(open(os.path.join(HERE, '..', 'events.json')))-DUR = EVJ['dur']; EV = EVJ['ev']; TOT = DUR + 1.5-BEAT = .6; E8 = .3-S.seed(7); rng = np.random.default_rng(7)--def evs(tp, **kw): return [e for e in EV if e['type'] == tp and all(e.get(k) == v for k, v in kw.items())]+BPM = 108; B = 60 / BPM; BAR = 3 * B+def bt(bar, beat=0.): return bar * BAR + beat * B+EV = json.load(open(os.path.join(D, 'events.json')))['ev']def ev1(tp, **kw):- r = evs(tp, **kw); return r[0] if r else None-+ for e in EV:+ if e['type'] == tp and all(e.get(k) == v for k, v in kw.items()): return e+TOT = 50 + 3.0N = int(TOT * SR)-stem = {k: np.zeros((N, 2), np.float32) for k in ['guitar', 'slide', 'harmonica', 'drums', 'bass']}--# ---------------- chords (real fingerings in open D tuning) -----------------CH = {- 'D': ['D2', 'A2', 'D3', 'F#3', 'A3', 'D4'],- 'D/F#': ['F#2', 'A2', 'D3', 'F#3', 'A3', 'D4'],- 'G': ['G2', 'D3', 'G3', 'B3', 'D4', 'G4'], # barre at fret 5- 'A': ['A2', 'E3', 'A3', 'C#4', 'E4', 'A4'], # barre at fret 7- 'Bm': ['B2', 'F#3', 'B3', 'D4', 'F#4', 'B4'],- 'Dhi': ['D3', 'A3', 'D4', 'F#4', 'A4', 'D5'], # fret 12-}-_cache = {}-def strum(ch, at, vel=.7, dur=1.2, up=False, spread=.018, gain=1., pan=0., top=6, mute=False):- key = (ch, round(vel, 2), round(dur, 2), up, round(spread, 3), top, mute)- if key not in _cache:- ps = CH[ch][-top:] if not up else CH[ch][-top:]- kw = dict(damp=.85, t60=.08) if mute else {}- _cache[key] = P.strum('acoustic_guitar', ps, dur, vel, spread=spread, up=up, **kw)- add(stem['guitar'], _cache[key], at, gain, pan)--def pick(p, at, vel=.7, dur=2., gain=1., pan=0.):- add(stem['guitar'], P.pluck('acoustic_guitar', p, dur, vel), at, gain, pan)--def harm(p, at, dur, vel=.6, gain=1., pan=.15, attack=.04):- ps = p if isinstance(p, (list, tuple)) else [p]- # the harmonica samples' breathy attack takes 30–60 ms to reach 30–50%, so trigger 35 ms early to make the perceived attack land on the sync point- for q in ps: add(stem['harmonica'], S.note('harmonica', q, dur, vel, attack=attack, release=.25), at - .035, gain / np.sqrt(len(ps)), pan)--def bass(p, at, dur=.55, vel=.75, gain=1.):- add(stem['bass'], S.note('jazz_bass', p, dur, vel), at, gain, 0)--def kick(at, vel=.8, gain=1.): add(stem['drums'], S.hit('cajon', 'bass', vel), at, gain * 1.2, 0)-def slap(at, vel=.55, gain=1.): add(stem['drums'], S.hit('cajon', 'slap', vel), at, gain * .7, .1)-def brush(at, vel=.5, gain=1.):- add(stem['drums'], S.hit('snare2', 'taps', vel), at, gain * .55, -.15)- n = rng.standard_normal(int(.16 * SR)).astype(np.float32)- n = sosfilt(butter(2, [1800, 7000], 'band', fs=SR, output='sos'), n).astype(np.float32)- n *= np.exp(-np.arange(len(n)) / SR / .05).astype(np.float32)- add(stem['drums'], n * .12, at, gain, -.2)-def shake(at, vel=.4, gain=1., up=False): add(stem['drums'], S.hit('shaker', 'up' if up else 'down', vel), at, gain * .5, .3)-def cymbal(at, var='hit', vel=.6, gain=1., dur=None): add(stem['drums'], S.hit('sus_cymbal', var, vel, dur), at, gain, -.25)--# ---------------- slide guitar (numpy synthesis) -----------------def hz(p): return S.hz(p)-def slide(at, path, dur, vel=.7, gain=1., pan=-.2, vib=(5.2, .12, .45), t60=3.2):- """path = [(t, note name or midi), ...] piecewise-linear slides (in semitones); returns and places it"""- n = int(dur * SR); t = np.arange(n) / SR- ts = [a for a, _ in path]; ms = [S.midi(b) for _, b in path]- m = np.interp(t, ts, ms)- vd = np.clip((t - vib[2]) / .3, 0, 1) * vib[1] * np.sin(2 * np.pi * vib[0] * t)- f = 440 * 2 ** ((m + vd - 69) / 12)- ph = 2 * np.pi * np.cumsum(f) / SR- y = np.zeros(n)- bright = np.exp(-t / .9)- for k in range(1, 16):- amp = (1 / k) * (0.35 + 0.65 * bright ** (k / 4))- y += amp * np.sin(k * ph + k * .3) * (f * k < 9000)- env = np.minimum(1, t / .008) * np.exp(-t * 6.9 / t60)- y *= env- # body resonance + steel-string brightness- body = sosfilt(butter(2, [90, 260], 'band', fs=SR, output='sos'), y) * .6- y = y + body + sosfilt(butter(2, [2200, 3800], 'band', fs=SR, output='sos'), y) * .5- # slide friction: follows slide speed- speed = np.abs(np.gradient(m) * SR)- fr = sosfilt(butter(2, [1500, 5000], 'band', fs=SR, output='sos'), rng.standard_normal(n)) * np.clip(speed / 12, 0, 1) * .05- y = (y + fr) * env ** 0- y = y / (np.abs(y).max() + 1e-9) * .5 * vel- k = min(n, 960); y[-k:] *= np.linspace(1, 0, k)- add(stem['slide'], y.astype(np.float32), at, gain, pan)--# ================= Arrangement =================-def T(tp, **kw):- e = ev1(tp, **kw); return e['t'] if e else None--# ---- Intro: an open-D tremolo strum already under way at 0 s -----lift0 = T('lift') # 1.0-t = 0.0; i = 0-while t < lift0 - .05:- strum('D', t, .38 + .12 * (t / lift0), dur=.35, up=bool(i % 2), spread=.008, gain=.8, top=5)- t += .15; i += 1-strum('D', lift0, .6, dur=.08, mute=True, gain=1.1) # screen lifts: muted "chk"-title = [e for e in evs('squeegee') if e.get('ink') == 'title'][0]['t'] # 1.2-kick(title, .9); strum('D', title, .85, dur=3.2, spread=.02, gain=1.2); bass('D2', title, 2.2, .7, .9)-ht = T('title') # 1.5-harm(['D4', 'F#4', 'A4'], ht, 3.1, .62, 1.0, attack=.03)-tilt = T('tilt', i=0)-strum('G', ht + 4 * BEAT - .3, .5, dur=1.2, spread=.02, gain=.7) # light strum around 3.6-strum('A', tilt - E8, .5, dur=.5, up=True, spread=.012, gain=.7) # upward rake before the tilt down--# ---- Section A: poster 1, one strum per layer, chords climbing layer by layer -----pulls0 = sorted(evs('pull', i=0), key=lambda e: e['t'])-for e, ch in zip(pulls0, ['D', 'D/F#', 'G', 'A']):- strum(ch, e['t'], .72 + .05 * e['n'], dur=1.4, spread=.022, gain=1.05)- if e['n'] == 0: kick(e['t'], .55, .7)-lift1 = T('lift', i=0) # 7.8-kick(lift1, .9); bass('D2', lift1, .55, .8)-band0 = T('band', i=0); name0 = T('name', i=0)-strum('D', band0, .8, dur=2.0, spread=.05, gain=1.0) # long downstrum-harm('A4', name0, .28, .7); harm('B4', name0 + .3, .28, .7); harm('D5', name0 + .6, 1.2, .72)-for e, p in zip(sorted(evs('item', i=0), key=lambda e: e['t']), ['D4', 'F#4', 'A4', 'D5']):- pick(p, e['t'], .8, 1.6, 1.1, .2)-# Groove: from lift1 to the transition, bass on beats 1 and 3, cajon on 1 and 3, brushes on 2 and 4, guitar light eighth-note strums-w1 = T('wipe', i=1) # 13.2-prog = ['D', 'D', 'G', 'G', 'D', 'D', 'A', 'A']-t = lift1 + BEAT; k = 0-while t < w1 - .35:- beat = int(round(t / BEAT)) % 4- if beat in (0, 2): kick(t, .6, .75); bass(['D2', 'G2', 'D2', 'A2'][(k // 4) % 4], t, .5, .7, .9)- else: brush(t, .5)- if t >= name0 + 1.4:- ch = prog[(k // 2) % len(prog)]- strum(ch, t, .42, dur=.5, spread=.012, gain=.55, top=4); strum(ch, t + E8, .32, dur=.3, up=True, spread=.01, gain=.45, top=4)- t += BEAT; k += 1-strum('A', w1 - E8, .8, dur=.6, up=True, spread=.03, gain=1.0) # upward rake half a beat before the transition (also poster 2's sky pull)--# ---- Section B: poster 2, eighth-note strums + four-on-the-floor (picking up speed) -----pulls1 = sorted(evs('pull', i=1), key=lambda e: e['t'])-for e, ch in zip(pulls1[1:], ['G', 'A', 'D']):- strum(ch, e['t'], .85, dur=.5, spread=.012, gain=1.1)-sil1 = [e for e in evs('silence') if e.get('pre')][0]; s1a, s1b = sil1['t'], sil1['t'] + sil1['dur']-band1 = T('band', i=1); name1 = T('name', i=1)-t = w1; k = 0; progB = ['D', 'G', 'A', 'D', 'Bm', 'G', 'A', 'A']-while t < s1a - .01:- kick(t, .75, .85)- if k % 2 == 1: brush(t, .55)- shake(t + E8, .35); shake(t, .25, up=True)- bass(['D2', 'G2', 'A2', 'D2', 'B1', 'G2', 'A2', 'A2'][(k // 2) % 8], t, .28, .75, .85)- ch = progB[(k // 2) % 8]- if not any(abs(t - e['t']) < .05 for e in pulls1):- strum(ch, t, .5, dur=.3, spread=.01, gain=.6, top=5)- strum(ch, t + E8, .38, dur=.25, up=True, spread=.008, gain=.5, top=4)- t += BEAT; k += 1-strum('D', band1, .82, dur=1.6, spread=.045, gain=.95)-slide(name1, [(0, 'A3'), (.08, 'A3'), (.42, 'D4')], 1.6, .8, 1.0)-for e, p in zip(sorted(evs('item', i=1), key=lambda e: e['t']), ['A4', 'D5', 'F#5', 'A5']):- pick(p, e['t'], .8, 1.4, 1.0, .2)--# ---- Section C: the signature climb -----asc = ev1('ascent'); a0 = asc['t']; a1 = a0 + asc['dur']-sil2 = [e for e in evs('silence') if not e.get('pre')][0]; s2a, s2b = sil2['t'], sil2['t'] + sil2['dur']-slide(a0, [(0, 'D3'), (.1, 'D3'), (.9, 'A3'), (1.3, 'A3'), (1.8, 'D4')], 3.2, .95, .7, vib=(5.0, .15, 1.9), t60=4.5)-t = a0 + BEAT; k = 1-while t < s2a - .01:- g = .35 + .8 * (t - a0) / (a1 - a0) # crescendo (about +9 dB at the top)- kick(t, .5 + .35 * g, .8 * g + .2)- if t >= a0 + 2 * BEAT: bass(['D2', 'D2', 'G2', 'A2'][(k // 2) % 4], t, .5, .75, g)- if t >= a0 + 3 * BEAT:- ch = ['D', 'D', 'G', 'A', 'Bm', 'G', 'A', 'A'][(k // 2) % 8]- strum(ch, t, .45 + .3 * g, dur=.5, spread=.012, gain=1.0 * g, top=5)- strum(ch, t + E8, .35 + .2 * g, dur=.3, up=True, spread=.01, gain=.6 * g, top=4)- if t >= a0 + 4 * BEAT and k % 2 == 1: brush(t, .5 * g + .2)- if t >= a0 + 4 * BEAT and (k % 4 == 0): harm(['D4', 'F#4', 'A4'] if (k // 4) % 2 == 0 else ['D4', 'G4', 'B4'], t, 4 * BEAT * .95, .45 + .25 * g, .7 * g, attack=.08)- t += BEAT; k += 1-for e in evs('swap'):- big = e['k'] >= 2- strum('Dhi' if big else 'A', e['t'], .95, dur=1.6, up=True, spread=.03 if big else .025, gain=1.3 if big else 1.1)- if big: cymbal(e['t'], 'cresc', .7, .9)-for j, e in enumerate(sorted(evs('part'), key=lambda e: e['t'])):- tgt = ['A3', 'B3', 'D4', 'E4'][j % 4]- slide(e['t'], [(0, S.midi(tgt) - 2), (.12, tgt)], .9, .8, 1.25, pan=-.35, vib=(5.5, .1, .3), t60=1.4)--# ---- Peak: the click = full-band downbeat -----cl = T('clack')-kick(cl, 1.0, 1.4); add(stem['drums'], S.hit('snare2', 'on', .8), cl, .7, 0); cymbal(cl, 'hit', .9, 1.0)-strum('D', cl, 1.0, dur=2.6, spread=.015, gain=1.5); strum('Dhi', cl + .01, .9, dur=2.4, spread=.012, gain=1.0, pan=.3)-bass('D2', cl, 1.2, .95, 1.2); harm(['D4', 'F#4', 'A4', 'D5'], cl, .75, .75, 1.2, attack=.01)-slide(cl, [(0, 'D4'), (.3, 'D4'), (.9, 'F#4')], 2.4, .8, .9, pan=-.3)--# ---- Section D: reading the numbers (one bar of groove → guitar + harmonica) -----wp = T('wallpull'); land = T('land'); endc = T('endcard')-band2 = T('band', i=2); name2 = T('name', i=2)-items2 = sorted(evs('item', i=2), key=lambda e: e['t'])-t = cl + BEAT; k = 1-while t < wp - .05:- full = t < cl + 4 * BEAT- if full:- kick(t, .75 if k % 2 == 0 else .6, .9)- if k % 2 == 1: brush(t, .55)- bass(['D2', 'D2', 'G2', 'A2'][k % 4], t, .5, .75, .9)- ch = ['D', 'D', 'G', 'G', 'D', 'D', 'A', 'A'][(k // 2) % 8]- if not any(abs(t - x) < .05 for x in [band2, name2] + [e['t'] for e in items2]):- strum(ch, t, .45 if full else .35, dur=.5, spread=.012, gain=.65 if full else .5, top=5)- t += BEAT; k += 1-strum('D', band2, .85, dur=2.0, spread=.035, gain=1.05)-harm('A4', name2, .28, .8, 1.3, attack=.01); harm('B4', name2 + .3, .28, .75, 1.2); harm('F#5', name2 + .6, 1.1, .75, 1.2)-base = ['D4', 'F#4', 'A4', 'D4']-for j, e in enumerate(items2):- p = base[j % 4]- if e.get('climb'): p = S.midi(p) + 12- pick(p, e['t'], .85, 1.8, 1.15, .2)--# ---- Tail: breathing room, arpeggios + a closing harmonica phrase, resolving on D -----arp = [('G', wp), ('A', wp + 2 * BEAT)]-for ch, t0 in arp:- for j, p in enumerate(CH[ch][1:]):- pick(p, t0 + j * E8 * .5, .5, 1.6, .7, -.1 + .05 * j)-harm('B4', wp, .55, .55); harm('A4', wp + .6, .55, .55); harm('E4', wp + 1.2 - .01, .3, .5)-strum('D', land, .6, dur=4.0, spread=.06, gain=.95)-harm(['D4', 'F#4', 'A4'], land, 3.9, .5, .9, attack=.3)-bass('D2', land, 3.8, .6, .8)-for j, p in enumerate(['A3', 'D4', 'F#4', 'A4', 'D5', 'A4', 'F#4', 'D4']):- pick(p, land + BEAT * (1 + j * .75), .35, 1.5, .55, .2 * np.sin(j))-# ---- End card -----strum('Dhi', endc, .45, dur=4.5, spread=.05, gain=.8)-harm('A4', endc + .2, 3.8, .45, .75, attack=.6)--# ================= Silence gate, reverb, output =================-def gate(x):- g = np.ones(len(x), np.float32); tt = np.arange(len(x)) / SR- for a, b in [(s1a, s1b), (s2a, s2b)]:- g *= np.where(tt < a, 1, np.where(tt >= b, 1, np.clip(1 - (tt - a) / .06, 0, 1))).astype(np.float32)- return x * g[:, None]-gains = {'guitar': .95, 'slide': .8, 'harmonica': .7, 'drums': .9, 'bass': .95}-wet = {'guitar': .16, 'slide': .22, 'harmonica': .2, 'drums': .08, 'bass': .03}+S.seed(5); rng = np.random.default_rng(5)+stem = {k: np.zeros((N, 2), np.float32) for k in ['guitar', 'melody', 'bass', 'glock', 'perc', 'squeeze', 'harp']}++def g(p, at, dur=1.6, vel=.6, gain=1., pan=0., st='guitar'):+ add(stem[st], S.note('guitar_nylon', p, dur, vel), at + rng.normal(0, .004), gain, pan)+def chord(ps, at, vel=.42, dur=.5, spread=.012, gain=1., pan=.15):+ for i, p in enumerate(ps): g(p, at + i * spread, dur, vel * (1 - .06 * i), gain, pan + .05 * i)+def bass(p, at, dur=1.0, vel=.6, gain=1.): add(stem['bass'], S.note('jazz_bass', p, dur, vel), at, gain, 0)+def glock(p, at, vel=.5, gain=1., pan=.3): add(stem['glock'], S.note('glockenspiel', p, 2.5, vel), at, gain, pan)+def brush(at, vel=.35, gain=1.): add(stem['perc'], S.hit('snare2', 'taps', vel), at, gain * .5, -.2)+def shake(at, vel=.3, up=False, gain=1.): add(stem['perc'], S.hit('shaker', 'up' if up else 'down', vel), at, gain * .35, .35)+def drum(at, var, vel=.5, gain=1., pan=-.25): add(stem['perc'], S.hit('world_perc', var, vel), at, gain, pan)+def cajon(at, vel=.6, gain=1.): add(stem['perc'], S.hit('cajon', 'bass', vel), at, gain * 1.1, 0)+def acc(p, at, dur, vel=.45, gain=1., pan=-.15): add(stem['squeeze'], S.note('accordion', p, dur, vel, attack=.03, release=.2), at - .02, gain, pan)+def harm(p, at, dur, vel=.55, gain=1., pan=.1): add(stem['harp'], S.note('harmonica', p, dur, vel, attack=.04, release=.25), at - .035, gain, pan)++# ---------------- harmony: (guitar bass, double bass, chord) per bar ----------------+F = ('F2', 'F1', ['A3', 'C4', 'F4']); Am = ('A2', 'A1', ['A3', 'C4', 'E4']); Dm = ('D3', 'D2', ['A3', 'D4', 'F4'])+Bb = ('Bb2', 'Bb1', ['Bb3', 'D4', 'F4']); C = ('C3', 'C2', ['G3', 'C4', 'E4']); A7 = ('A2', 'A1', ['G3', 'C#4', 'E4'])+Gm = ('G2', 'G1', ['G3', 'Bb3', 'D4']); C7 = ('C3', 'C2', ['G3', 'Bb3', 'E4'])+HARM = [F, Am, Dm, Bb, C, F, Dm, A7, Gm, C7, F, Dm, Bb, Gm, C, C, C, F, Dm, Bb, C, C7, F, Am, Bb, F, Dm, Bb, C, F]+CLAMP = ev1('clamp')['t']; SNAP = ev1('snap')['t']; DROP = ev1('drop')['t']+for bar, (gb, bb, ch) in enumerate(HARM):+ t0 = bt(bar)+ if 13 <= bar <= 16: # the push into the number: the band leaves, one part at a time+ if bar == 13: g(gb, t0, 1.6, .55); chord(ch, t0 + B, .32); chord(ch, t0 + 2 * B, .26); bass(bb, t0, 1.2, .5)+ if bar == 14: g(gb, t0, 1.8, .45); chord(ch, t0 + B, .22); bass(bb, t0, 1.6, .42)+ if bar == 15 and t0 < DROP: g(ch[1], t0, 2.0, .3)+ if bar == 16: # after the silence: the clamp, then everything comes back on beat 3+ bass('F1', CLAMP, 1.0, .85); g('F2', CLAMP, 1.2, .7); chord(['A3', 'C4', 'F4'], CLAMP + .01, .55, .5); cajon(CLAMP, .85)+ continue+ last = bar == 29+ g(gb, t0, 3.4 if last else 1.6, .62)+ if last: chord(ch, t0 + B * .5, .36, dur=3.0, spread=.06)+ elif 17 <= bar <= 21: # the way home: eighth-note arpeggios (faster by subdivision, same tempo)+ arp = [ch[0], ch[1], ch[2], ch[1], ch[2], ch[1]]+ for k, p in enumerate(arp[1:], 1): g(p, t0 + k * B / 2, .45, .36 + .02 * (bar - 17))+ else:+ chord(ch, t0 + B, .40); chord(ch, t0 + 2 * B, .34)+ if bar >= 1:+ if 10 <= bar <= 12: # Buenos Aires: the bass leans on the "and" of two+ bass(bb, t0, .5, .6); bass(bb, t0 + 1.5 * B, .45, .5); bass(bb, t0 + 2.5 * B, .3, .35)+ else:+ bass(bb, t0, 2.6 if last else 1.2, .6 if bar != 22 else .8)+ if bar >= 2 and not last:+ brush(t0 + B, .28 + .02 * min(bar, 6)); brush(t0 + 2 * B, .24 + .02 * min(bar, 6))+ if (3 <= bar <= 12 or 17 <= bar <= 28):+ for k in range(6): shake(t0 + k * B / 2, .2 + (.06 if k % 2 == 0 else 0), up=k % 2 == 1)+ if 6 <= bar <= 8: # Istanbul: darbuka+ drum(t0, 'darbuka_doom', .55); drum(t0 + B, 'darbuka_tak', .4); drum(t0 + 1.5 * B, 'darbuka_tak', .28); drum(t0 + 2 * B, 'darbuka_tak', .4)+ if 17 <= bar <= 21: cajon(t0, .45)+ if bar >= 22 and not last: cajon(t0, .4)++# ---------------- melodies ----------------+for bar, beat, p, n in [(2, 0, 'A4', 1), (2, 1, 'F4', 1), (2, 2, 'D4', 1), (3, 0, 'D5', 2), (3, 2, 'C5', 1),+ (4, 0, 'Bb4', 1), (4, 1, 'A4', 1), (4, 2, 'G4', 1), (5, 0, 'A4', 3),+ (6, 0, 'A4', 1), (6, 1, 'Bb4', 1), (6, 2, 'A4', 1), (7, 0, 'G4', 1), (7, 1, 'F4', 1), (7, 2, 'E4', 1)]:+ g(p, bt(bar, beat), n * B + .4, .48, .9, -.2, st='melody')+for bar, beat, p, n in [(8, 1, 'D5', 1), (8, 2, 'Bb4', 1), (9, 0, 'E5', 2), (9, 2, 'C5', 1), (10, 0, 'F5', 2), (10, 2, 'C5', 1),+ (11, 0, 'D5', 1), (11, 1, 'F5', 1), (11, 2, 'A5', 1), (12, 0, 'F5', 3)]:+ acc(p, bt(bar, beat), n * B * .95, .5)+for bar in (10, 11, 12): acc('A3', bt(bar), BAR * .95, .22, pan=.2); acc('F3', bt(bar), BAR * .95, .2, pan=.2)+for bar, beat, p, n in [(19, 0, 'C5', 2), (19, 2, 'D5', 1), (20, 0, 'E5', 2), (20, 2, 'G5', 1), (21, 0, 'E5', 3),+ (22, 0, 'F5', 2), (22, 2, 'C5', 1), (23, 0, 'E5', 1), (23, 1, 'C5', 1), (23, 2, 'A4', 1),+ (24, 0, 'D5', 2), (24, 2, 'Bb4', 1), (25, 0, 'A4', 3), (26, 0, 'F4', 1), (26, 1, 'A4', 1), (26, 2, 'D5', 1),+ (27, 0, 'D5', 2), (27, 2, 'C5', 1), (28, 0, 'Bb4', 1), (28, 1, 'A4', 1), (28, 2, 'G4', 1), (29, 0, 'F4', 5)]:+ harm(p, bt(bar, beat), n * B * .95, .5 if bar < 22 else .58)+for bar in range(22, 29): acc(HARM[bar][2][0][:-1] + '3', bt(bar), BAR * .95, .16, pan=-.3)++# ---------------- accents ----------------+glock('F6', 0.0, .55); glock('C6', 0.0, .35) # the first sound: the sun+for e in EV:+ if e['type'] == 'pull' and e.get('layer') == 'acc': glock('A5', e['t'], .32)+ if e['type'] == 'item' and e.get('accent'): glock('F6', e['t'], .42); glock('A5', e['t'] + .01, .22)+add(stem['perc'], S.hit('sus_cymbal', 'hit', .55), SNAP, .7, -.2); cajon(SNAP, .95); glock('F6', SNAP, .55); glock('C6', SNAP, .4)+glock('F5', bt(29), .4); glock('A5', bt(29) + .12, .3); glock('C6', bt(29) + .24, .3)++mix = stem['guitar'] * 1.0 + stem['melody'] * .8 + stem['bass'] * .9 + stem['glock'] * .55 + stem['perc'] * .8 + stem['squeeze'] * .7 + stem['harp'] * .75+# hard silence before the clamp (nothing may ring into it)+a, b = int((DROP + .9) * SR), int(CLAMP * SR); mix[a:b] = 0+fo = int(.9 * SR); mix[a - fo:a] *= np.linspace(1, 0, fo)[:, None]+mix = S.room(mix, size=.35, mix=.16)+mix[int((DROP + 1.6) * SR):b] = 0+pk = np.abs(mix).max(); mix = mix / pk * .8os.makedirs(os.path.join(HERE, 'stems'), exist_ok=True)-out = {}-for k, x in stem.items():- y = S.room(x * gains[k], size=.42, mix=wet[k])- y = gate(y) # reverb tails are cut in the silence zones too- out[k] = y.astype(np.float32)-mix = sum(out.values())-pk = np.abs(mix).max(); sc = 10 ** (-1.5 / 20) / pk-mix *= sc-for k in out: out[k] *= sc; sf.write(os.path.join(HERE, 'stems', k + '.wav'), out[k], SR, subtype='FLOAT')-sf.write(os.path.join(HERE, 'score.wav'), mix, SR, subtype='FLOAT')--# ================= Self-check =================-assert np.isfinite(mix).all()-print(f'dur {len(mix)/SR:.2f}s peak {20*np.log10(np.abs(mix).max()):.2f} dBFS')-def rms_db(a, b):- x = mix[int(a * SR):int(b * SR)]; return 20 * np.log10(np.sqrt((x ** 2).mean()) + 1e-12)-print(f'silence1 {s1a:.2f}-{s1b:.2f}: {rms_db(s1a + .08, s1b - .005):.1f} dBFS silence2 {s2a:.2f}-{s2b:.2f}: {rms_db(s2a + .08, s2b - .005):.1f} dBFS')-import librosa-mono = mix.mean(1)-# Onset detection: hop 64 (1.3 ms), onset_detect + backtrack to where energy starts rising (removes onset_strength's inherent lag)-hop = 64-of = librosa.onset.onset_strength(y=mono, sr=SR, hop_length=hop)-ons = librosa.onset.onset_detect(onset_envelope=of, sr=SR, hop_length=hop, backtrack=True, units='time', delta=.02, wait=4)-tt = librosa.times_like(of, sr=SR, hop_length=hop)-hm = out['harmonica'].mean(1)-hof = librosa.onset.onset_strength(y=hm, sr=SR, hop_length=hop)-hons = librosa.onset.onset_detect(onset_envelope=hof, sr=SR, hop_length=hop, backtrack=False, units='time', delta=.02, wait=4)-def onset_near(t0, w=.04, src=None):- src = ons if src is None else src- c = src[(src >= t0 - w) & (src <= t0 + w)]- if not len(c): return None- d = c[np.argmin(np.abs(c - t0))]; j = np.searchsorted(tt, d + .01)- return d - t0, of[min(j, len(of) - 1)] / (np.median(of) + 1e-9)-chk = [('lift', lift0), ('title', title), ('harm', ht)] + [(f'pull0.{e["n"]}', e['t']) for e in pulls0] + [('lift1', lift1), ('band0', band0), ('name0', name0)] \- + [(f'item0.{e["k"]}', e['t']) for e in evs('item', i=0)] + [(f'pull1.{e["n"]}', e['t']) for e in pulls1] + [('band1', band1), ('name1', name1)] \- + [(f'item1.{e["k"]}', e['t']) for e in evs('item', i=1)] + [('ascent', a0)] + [(f'swap{e["k"]}', e['t']) for e in evs('swap')] \- + [(f'part.{e["layer"]}', e['t']) for e in evs('part')] + [('clack', cl), ('band2', band2), ('name2', name2)] \- + [(f'item2.{e["k"]}', e['t']) for e in items2] + [('wallpull', wp), ('land', land), ('endcard', endc)]-print(f'{"cue":14s} {"t":>7s} {"Δms":>6s} {"strength":>8s}')-bad = 0-for nm, t0 in chk:- r = onset_near(t0)- if r is None and nm in ('harm', 'name0', 'name2'): r = onset_near(t0, src=hons); nm += '(口琴分轨)'- if r is None: print(nm, 'none'); bad += 1; continue- d, s = r; flag = '' if abs(d) <= .010 else ' <-- >10ms'- bad += abs(d) > .010- print(f'{nm:14s} {t0:7.2f} {d*1000:6.1f} {s:8.1f}{flag}')-print('cues >10ms:', bad)+for k, v in stem.items(): sf.write(os.path.join(HERE, 'stems', k + '.wav'), v, SR)+sf.write(os.path.join(HERE, 'score.wav'), mix.astype(np.float32), SR)+print('score.wav', f'{TOT:.2f}s')diff --git a/styles/silkscreen-poster/demo/stills/alt_1_title.jpg b/styles/silkscreen-poster/demo/stills/alt_1_title.jpgdeleted file mode 100644index e615141..0000000Binary files a/styles/silkscreen-poster/demo/stills/alt_1_title.jpg and /dev/null differdiff --git a/styles/silkscreen-poster/demo/stills/alt_2_band.jpg b/styles/silkscreen-poster/demo/stills/alt_2_band.jpgdeleted file mode 100644index bfe8156..0000000Binary files a/styles/silkscreen-poster/demo/stills/alt_2_band.jpg and /dev/null differdiff --git a/styles/silkscreen-poster/demo/stills/alt_3_ascent_night.jpg b/styles/silkscreen-poster/demo/stills/alt_3_ascent_night.jpgdeleted file mode 100644index 71a8db4..0000000Binary files a/styles/silkscreen-poster/demo/stills/alt_3_ascent_night.jpg and /dev/null differdiff --git a/styles/silkscreen-poster/demo/stills/alt_4_wall.jpg b/styles/silkscreen-poster/demo/stills/alt_4_wall.jpgdeleted file mode 100644index d03b2bc..0000000Binary files a/styles/silkscreen-poster/demo/stills/alt_4_wall.jpg and /dev/null differdiff --git a/styles/silkscreen-poster/demo/stills/styleframe.jpg b/styles/silkscreen-poster/demo/stills/styleframe.jpgindex 6f900aa..c714688 100644Binary files a/styles/silkscreen-poster/demo/stills/styleframe.jpg and b/styles/silkscreen-poster/demo/stills/styleframe.jpg differdiff --git a/styles/silkscreen-poster/demo/tools/cuecheck.py b/styles/silkscreen-poster/demo/tools/cuecheck.pydeleted file mode 100644index f23ebd4..0000000--- a/styles/silkscreen-poster/demo/tools/cuecheck.py+++ /dev/null@@ -1,15 +0,0 @@-"""Sync-point self-check: for each picture event, find the nearest onset in mix.wav (within ±80 ms) and compare with the event time.-Run from the repo root: .venv/bin/python styles/silkscreen-poster/demo/tools/cuecheck.py"""-import json, os, numpy as np, soundfile as sf, librosa-D = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')-E = json.load(open(os.path.join(D, 'events.json')))-y, sr = sf.read(os.path.join(D, 'mix.wav'), always_2d=True); y = y.mean(1)-on = librosa.onset.onset_detect(y=y, sr=sr, hop_length=128, backtrack=True, units='time')-keep = ('pull', 'lift', 'band', 'name', 'item', 'swap', 'clack', 'endcard', 'squeegee')-bad, n, ds = 0, 0, []-for e in E['ev']:- if e['type'] not in keep: continue- n += 1; d = on[np.argmin(np.abs(on - e['t']))] - e['t']; ds.append(d)- flag = '' if abs(d) <= 1 / 24 else ' <-- 超过 1 帧'- bad += bool(flag); print(f"{e['t']:6.2f} {e['type']:9s} {d*1000:+6.1f} ms{flag}")-print(f'{n} 个卡点,{n-bad} 个在 1 帧(41.7 ms)以内,中位 |误差| {np.median(np.abs(ds))*1000:.1f} ms')diff --git a/styles/silkscreen-poster/demo/tools/cues.py b/styles/silkscreen-poster/demo/tools/cues.pynew file mode 100644index 0000000..c883b1e--- /dev/null+++ b/styles/silkscreen-poster/demo/tools/cues.py@@ -0,0 +1,25 @@+"""cues.py · subtitle cues from voice/subs.json (start times) + out/voice/dur.json (spoken lengths, written by core/tts/tts.py).+Writes voice/cues.json (read by the page) and an .srt for the chosen range.+ python tools/cues.py [a b out.srt] (default: whole film → ../silkscreen-poster.srt)+Rule: a cue opens 0.1 s before its line and stays ≥ 1.8 s and ≥ speech + 0.6 s, but closes 0.04 s before the next one."""+import json, os, sys+D = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+S = json.load(open(os.path.join(D, 'voice/subs.json'))); dur = json.load(open(os.path.join(D, 'out/voice/dur.json')))+cues = []+for i, s in enumerate(S):+ vo = s['t']; t0 = round(vo - .1, 3); t1 = max(t0 + 1.8, vo + dur[s['id']] + .6)+ if i + 1 < len(S): t1 = min(t1, S[i + 1]['t'] - .1 - .04)+ short = t1 - t0 < max(1.8, dur[s['id']] + .6) - 1e-6+ cues.append({'id': s['id'], 'vo': vo, 't0': t0, 't1': round(t1, 3), 'zh': s['zh'], 'en': s['en'], 'speech': dur[s['id']]})+ if short: print('WARNING: cue too short', s['id'], round(t1 - t0, 2))+json.dump(cues, open(os.path.join(D, 'voice/cues.json'), 'w'), ensure_ascii=False, indent=1)+a, b = (float(sys.argv[1]), float(sys.argv[2])) if len(sys.argv) > 2 else (0, 1e9)+out = sys.argv[3] if len(sys.argv) > 3 else os.path.join(os.path.dirname(D), 'silkscreen-poster.srt')+def ts(x): x = max(0, x); h = int(x // 3600); m = int(x % 3600 // 60); s = x % 60; return f'{h:02d}:{m:02d}:{int(s):02d},{int(round((s - int(s)) * 1000)):03d}'+lines = []; n = 0+for c in cues:+ if c['t1'] <= a or c['t0'] >= b: continue+ n += 1; lines += [str(n), f"{ts(c['t0'] - a)} --> {ts(min(c['t1'], b) - a)}", c['zh'], c['en'], '']+open(out, 'w').write('\n'.join(lines))+for c in cues: print(f"{c['id']} {c['t0']:6.2f}–{c['t1']:6.2f} hold {c['t1']-c['t0']:.2f}s speech {c['speech']:.2f}s")+print('srt →', out)diff --git a/styles/silkscreen-poster/demo/tools/fetch_fonts.sh b/styles/silkscreen-poster/demo/tools/fetch_fonts.shnew file mode 100755index 0000000..22d8b19--- /dev/null+++ b/styles/silkscreen-poster/demo/tools/fetch_fonts.sh@@ -0,0 +1,8 @@+#!/bin/sh+# Downloads the three OFL fonts the film uses into demo/fonts/ when they are missing (Google Fonts repository).+set -e+F=$(cd "$(dirname "$0")/.." && pwd)/fonts+get() { [ -s "$F/$1" ] || { echo "fetching $1"; curl -fsSL --retry 3 -o "$F/$1" "https://github.com/google/fonts/raw/main/ofl/$2"; }; }+get BigShouldersDisplaywght.ttf 'bigshouldersdisplay/BigShouldersDisplay%5Bwght%5D.ttf'+get Outfitwght.ttf 'outfit/Outfit%5Bwght%5D.ttf'+get NotoSansSCwght.ttf 'notosanssc/NotoSansSC%5Bwght%5D.ttf'diff --git a/styles/silkscreen-poster/demo/tools/timeline.mjs b/styles/silkscreen-poster/demo/tools/timeline.mjsdeleted file mode 100644index 8c52277..0000000--- a/styles/silkscreen-poster/demo/tools/timeline.mjs+++ /dev/null@@ -1,9 +0,0 @@-// Print the timeline (content can be swapped): node styles/silkscreen-poster/demo/tools/timeline.mjs [content_alt.json]-import { openDemo, closeServer } from '../../../../core/render/page.mjs';-import path from 'path'; import { fileURLToPath } from 'url';-const dir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');-const c = process.argv[2];-const { browser, page } = await openDemo(path.relative(process.cwd(), dir), { q: c ? 'content=' + c : '' });-const r = await page.evaluate(() => ({ dur: window.DUR, tl: window.TL }));-console.log('dur', r.dur.toFixed(2)); r.tl.forEach(s => console.log(s.kind.padEnd(7), s.t0.toFixed(2), '→', s.t1.toFixed(2)));-await browser.close(); closeServer();diff --git a/styles/silkscreen-poster/demo/voice/cues.json b/styles/silkscreen-poster/demo/voice/cues.jsonnew file mode 100644index 0000000..60008e2--- /dev/null+++ b/styles/silkscreen-poster/demo/voice/cues.json@@ -0,0 +1,92 @@+[+ {+ "id": "L01",+ "vo": 0.4,+ "t0": 0.3,+ "t1": 5.685,+ "zh": "我想走到这个世界允许的最远。",+ "en": "I wanted to get as far from home as the world allows.",+ "speech": 4.685+ },+ {+ "id": "L02",+ "vo": 5.86,+ "t0": 5.76,+ "t1": 8.785,+ "zh": "第 1 天,北京,0 公里。",+ "en": "Day 1. Beijing. 0 kilometres.",+ "speech": 2.325+ },+ {+ "id": "L03",+ "vo": 10.5,+ "t0": 10.4,+ "t1": 13.391,+ "zh": "伊斯坦布尔,7000 公里。",+ "en": "Istanbul. 7,000 kilometres.",+ "speech": 2.291+ },+ {+ "id": "L04",+ "vo": 14.4,+ "t0": 14.3,+ "t1": 18.04,+ "zh": "巴黎,8200。还不够远。",+ "en": "Paris. 8,200. Not far enough.",+ "speech": 3.04+ },+ {+ "id": "L05",+ "vo": 18.2,+ "t0": 18.1,+ "t1": 21.26,+ "zh": "然后是布宜诺斯艾利斯,19000。",+ "en": "Then Buenos Aires. 19,000.",+ "speech": 2.475+ },+ {+ "id": "L06",+ "vo": 21.4,+ "t0": 21.3,+ "t1": 27.463,+ "zh": "在一个圆的世界上,差不多已经走到头了。",+ "en": "On a round world, that is almost as far as you can go.",+ "speech": 5.463+ },+ {+ "id": "L07",+ "vo": 28.1,+ "t0": 28.0,+ "t1": 31.536,+ "zh": "从那儿起,哪条路都通向家。",+ "en": "And from there, every road leads home.",+ "speech": 2.836+ },+ {+ "id": "L08",+ "vo": 31.8,+ "t0": 31.7,+ "t1": 35.238,+ "zh": "39600 公里之后,",+ "en": "39,600 kilometres later,",+ "speech": 2.838+ },+ {+ "id": "L09",+ "vo": 37.0,+ "t0": 36.9,+ "t1": 39.796,+ "zh": "又是北京,0 公里。",+ "en": "Beijing again. 0 kilometres.",+ "speech": 2.196+ },+ {+ "id": "L10",+ "vo": 41.0,+ "t0": 40.9,+ "t1": 47.456,+ "zh": "原来世界的另一头,只是绕远路回家。",+ "en": "It turns out, the far side of the world is just the long way home.",+ "speech": 5.856+ }+]\ No newline at end of filediff --git a/styles/silkscreen-poster/demo/voice/lines.json b/styles/silkscreen-poster/demo/voice/lines.jsonnew file mode 100644index 0000000..fadcb21--- /dev/null+++ b/styles/silkscreen-poster/demo/voice/lines.json@@ -0,0 +1,78 @@+[+ {+ "id": "L01",+ "text": "I wanted to get as far from home as the world allows.",+ "voice": "bf_emma",+ "speed": 0.58,+ "lang": "en-gb"+ },+ {+ "id": "L02",+ "text": "Day one. Beijing. Zero kilometres.",+ "voice": "bf_emma",+ "speed": 1.05,+ "lang": "en-gb",+ "asr": "day one Beijing zero kilometers"+ },+ {+ "id": "L03",+ "text": "Istanbul. Seven thousand kilometres.",+ "voice": "bf_emma",+ "speed": 1.05,+ "lang": "en-gb",+ "asr": "Istanbul 7000 kilometers"+ },+ {+ "id": "L04",+ "text": "Paris. Eight thousand two hundred. Not far enough.",+ "voice": "bf_emma",+ "speed": 0.83,+ "lang": "en-gb",+ "asr": "Paris 8200, not far enough."+ },+ {+ "id": "L05",+ "text": "Then Buenos Aires. Nineteen thousand.",+ "voice": "bf_emma",+ "speed": 1.05,+ "lang": "en-gb",+ "asr": "Then Buenos Aires, 19,000."+ },+ {+ "id": "L06",+ "text": "On a round world, that is almost as far as you can go.",+ "voice": "bf_emma",+ "speed": 0.55,+ "lang": "en-gb"+ },+ {+ "id": "L07",+ "text": "And from there, every road leads home.",+ "voice": "bf_emma",+ "speed": 0.77,+ "lang": "en-gb"+ },+ {+ "id": "L08",+ "text": "Thirty-nine thousand six hundred kilometres later,",+ "voice": "bf_emma",+ "speed": 0.99,+ "lang": "en-gb",+ "asr": "39,600 km later."+ },+ {+ "id": "L09",+ "text": "Beijing again. Zero kilometres.",+ "voice": "bf_emma",+ "speed": 1.05,+ "lang": "en-gb",+ "asr": "Beijing again, 0 km."+ },+ {+ "id": "L10",+ "text": "It turns out, the far side of the world is just the long way home.",+ "voice": "bf_emma",+ "speed": 0.58,+ "lang": "en-gb"+ }+]\ No newline at end of filediff --git a/styles/silkscreen-poster/demo/voice/subs.json b/styles/silkscreen-poster/demo/voice/subs.jsonnew file mode 100644index 0000000..7c68b50--- /dev/null+++ b/styles/silkscreen-poster/demo/voice/subs.json@@ -0,0 +1,62 @@+[+ {+ "id": "L01",+ "t": 0.4,+ "en": "I wanted to get as far from home as the world allows.",+ "zh": "我想走到这个世界允许的最远。"+ },+ {+ "id": "L02",+ "t": 5.86,+ "en": "Day 1. Beijing. 0 kilometres.",+ "zh": "第 1 天,北京,0 公里。"+ },+ {+ "id": "L03",+ "t": 10.5,+ "en": "Istanbul. 7,000 kilometres.",+ "zh": "伊斯坦布尔,7000 公里。"+ },+ {+ "id": "L04",+ "t": 14.4,+ "en": "Paris. 8,200. Not far enough.",+ "zh": "巴黎,8200。还不够远。"+ },+ {+ "id": "L05",+ "t": 18.2,+ "en": "Then Buenos Aires. 19,000.",+ "zh": "然后是布宜诺斯艾利斯,19000。"+ },+ {+ "id": "L06",+ "t": 21.4,+ "en": "On a round world, that is almost as far as you can go.",+ "zh": "在一个圆的世界上,差不多已经走到头了。"+ },+ {+ "id": "L07",+ "t": 28.1,+ "en": "And from there, every road leads home.",+ "zh": "从那儿起,哪条路都通向家。"+ },+ {+ "id": "L08",+ "t": 31.8,+ "en": "39,600 kilometres later,",+ "zh": "39600 公里之后,"+ },+ {+ "id": "L09",+ "t": 37.0,+ "en": "Beijing again. 0 kilometres.",+ "zh": "又是北京,0 公里。"+ },+ {+ "id": "L10",+ "t": 41.0,+ "en": "It turns out, the far side of the world is just the long way home.",+ "zh": "原来世界的另一头,只是绕远路回家。"+ }+]\ No newline at end of filediff --git a/styles/silkscreen-poster/poster.jpg b/styles/silkscreen-poster/poster.jpgindex 6f900aa..c714688 100644Binary files a/styles/silkscreen-poster/poster.jpg and b/styles/silkscreen-poster/poster.jpg differdiff --git a/styles/silkscreen-poster/silkscreen-poster.srt b/styles/silkscreen-poster/silkscreen-poster.srtnew file mode 100644index 0000000..0c1747f--- /dev/null+++ b/styles/silkscreen-poster/silkscreen-poster.srt@@ -0,0 +1,49 @@+1+00:00:00,300 --> 00:00:05,685+我想走到这个世界允许的最远。+I wanted to get as far from home as the world allows.++2+00:00:05,760 --> 00:00:08,785+第 1 天,北京,0 公里。+Day 1. Beijing. 0 kilometres.++3+00:00:10,400 --> 00:00:13,391+伊斯坦布尔,7000 公里。+Istanbul. 7,000 kilometres.++4+00:00:14,300 --> 00:00:18,040+巴黎,8200。还不够远。+Paris. 8,200. Not far enough.++5+00:00:18,100 --> 00:00:21,260+然后是布宜诺斯艾利斯,19000。+Then Buenos Aires. 19,000.++6+00:00:21,300 --> 00:00:27,463+在一个圆的世界上,差不多已经走到头了。+On a round world, that is almost as far as you can go.++7+00:00:28,000 --> 00:00:31,536+从那儿起,哪条路都通向家。+And from there, every road leads home.++8+00:00:31,700 --> 00:00:35,238+39600 公里之后,+39,600 kilometres later,++9+00:00:36,900 --> 00:00:39,796+又是北京,0 公里。+Beijing again. 0 kilometres.++10+00:00:40,900 --> 00:00:47,456+原来世界的另一头,只是绕远路回家。+It turns out, the far side of the world is just the long way home.diff --git a/styles/silkscreen-poster/style.json b/styles/silkscreen-poster/style.jsonindex cb0e0e0..db2897c 100644--- a/styles/silkscreen-poster/style.json+++ b/styles/silkscreen-poster/style.json@@ -5,14 +5,14 @@"cn": "丝印旅行海报","category_en": "Print & Printmaking","category_cn": "印刷与版画",- "film": "Three Trails",- "line": "Three trail posters are screen-printed one ink at a time, then climbed in one long take from noon to dusk.",- "line_cn": "三条步道各一张丝印海报,一色一刮印出来,再沿山脊一镜到底从正午爬到黄昏。",+ "film": "The Long Way Home",+ "line": "A traveller crosses the world one full-bleed screen print at a time, a ticket stub counting the distance from home, until the far side turns into the way back.",+ "line_cn": "一张满屏丝印海报一座城,票根数着离家的公里数,走到世界的另一头,才发现那是回家的路。","uses": ["Destination guides","Tourism","Event posters"],- "frame_sec": 34.0,- "dur": 38.4+ "frame_sec": 44.5,+ "dur": 50.0}