Skip to content

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 种现成风格,也能做出你自己的

Transit Map: content moves out of the engine into net.js and timeline.js; water bodies, bus and ferry lines that read at a distance, walking links

lemomo-aiedf4c12c14e0
diff --git a/styles/transit-map/DEMO.md b/styles/transit-map/DEMO.md
index 251da81..a5be2a0 100644
--- a/styles/transit-map/DEMO.md
+++ b/styles/transit-map/DEMO.md
@@ -68,10 +68,13 @@ In the sheet's lower-right corner, inked at the end: a red line runs to a termin
demo/
build.sh one command: fonts, events, score + mix, picture, master, reading-time check, poster and style frame
index.html two canvases (WebGL plane, 2D overlay), fonts, scripts
- net.js the network as data + expand() (octilinear bends)
+ net.js the Shanghai network as data: stations, 21 lines (colours, bullets, ink-on-light flags, the Maglev
+ as mode 'light'), the Huangpu and Suzhou Creek as WATER bands, expand() (octilinear bends)
gl.js makePlane(): paper, light, sheet edge, depth of field, vignette
- film.js geometry, phases, labels, camera, inked region, map drawing, events, window.TEXTS
- timeline.js facts (FX), WARP, phases, camera keys, annotations, time-line panel, counter, tunnel, plate, cues
+ film.js the generic engine (no network, no story): geometry, water, line forms, phases, labels, bullets,
+ the falling interchange, camera, inked region, map drawing, events, window.TEXTS
+ timeline.js this film: facts (FX), WARP, phases, camera keys, the hooks below, annotations, time-line panel,
+ counter, tunnel, plate, cues
audio.py score + effects + loudness loop -> mix.wav (reads events.json)
tools/ subset.py (Noto Sans SC subset from the characters in the JS), sheet.sh (contact sheet for review)
fonts/ Inter, the Noto Sans SC subset, OFL texts
@@ -79,6 +82,8 @@ demo/
```
- Build: `sh styles/transit-map/demo/build.sh` from the library root. It downloads Inter and Noto Sans SC when missing (OFL, github.com/google/fonts) and the vcsl, freepats and vsco2ce sample packs (`sh tools/fetch.sh instruments <lib>`), subsets the CJK font, exports `events.json`, writes `mix.wav`, renders at 30 fps with three workers, masters with `core/render/mux.sh` (grain 1), runs `readcheck.mjs` and takes the poster and `demo/stills/styleframe.jpg` at 36.2 s. The picture renders in well under a minute on an Apple-silicon Mac; the whole build takes a few minutes.
+- Hooks this film defines in `timeline.js` (the full list is in STYLE.md §10): `LABEL_PREF` (eight stations), `nameAt` (新龙华 before 1999), `labelOnly` (names per shot), `drops` + `dropRing` (People's Square, rings in the Line 1 and Line 2 colours), `roundelPos` / `roundelAlpha` (bullet places, and bullets that leave when their chapter is over), `veil` / `stationDim` / `highlight` (the ending), `riverLabels`, `furniture` (cartouche, time-line axis, end card), `annotations` (callout, Expo star, time lines, "you are here"), `trains` (the 1993 shuttle and every line now), `overlay` (tunnel, match flash, plate, counter), `tunnelOnly`, `cues`, `init`. Everything Shanghai-specific is in `net.js` and `timeline.js`; the demo uses no bus, ferry or walking-link lines.
+- `WARP` maps film time to story time because one beat is slowed and one hold lengthened after the picture was written. A film written directly in film time needs no `WARP` (leave it out).
- Reading time: `window.TEXTS(t)` reports every line meant to be read (callout, station names, counter rows, the time-line panel, caption, end card) with its screen box; `readcheck.mjs` passes on all 76 pieces. Map labels show by shot (an allow-list in `timeline.js`, `labelOnly`) so no name flashes past too briefly.
- Order when editing: `net.js` / `timeline.js` → `tools/subset.py` when text changes → `node core/render/events.mjs styles/transit-map/demo` → `.venv/bin/python styles/transit-map/demo/audio.py` → render. `sh styles/transit-map/demo/tools/sheet.sh` makes a 0.5 s contact sheet in `demo/out/`.
- 1080p frames take 30–250 ms (most 35–60 ms); the inked region is redrawn every frame at up to 4096². Needs WebGL2 with `EXT_color_buffer_float` (the depth-of-field pass reads a half-float buffer).
diff --git a/styles/transit-map/STYLE.md b/styles/transit-map/STYLE.md
index 578b559..54b46a7 100644
--- a/styles/transit-map/STYLE.md
+++ b/styles/transit-map/STYLE.md
@@ -20,17 +20,18 @@ Not Data Storytelling (even a time chart is drawn as two lines with stops), not
| Mark | Geometry (G) |
|---|---|
| Line | 0.15 wide, round caps; corner fillet radius 0.34 |
-| Thin line (a second rail mode) | 0.07 wide; fillet 0.30 |
+| Thin line (a second rail mode; ferry thread) | 0.07 wide; fillet 0.30 |
| Parallel lines sharing a corridor | each offset ±0.10 from the shared axis (0.20 centre to centre, 0.05 of paper between); three or more: 0.20 steps |
| Stop | white disc r 0.085, ring 0.046 in the line colour |
| Terminus | an ordinary stop; when the end of a line matters (a destination, an end card) a white ring r 0.15 with a 0.06 ink outline |
| Minor stop (generated tick) | white disc r 0.065, ring 0.036; at most one per 0.78 G of track |
| Interchange capsule | the bounding box of every line point at the station, padded 0.13 on all sides; corner radius = half the shorter side (a stadium); white fill; ink outline 0.055 (0.07 for a major hub) |
-| Water | river band 0.76 with a darker edge 0.025 each side; creeks 0.15 with 0.02 edges; round joins |
+| River | a band 0.76 wide (0.70–1.0 for a big river) with a darker edge 0.025 each side, round joins; creeks 0.15 with 0.02 edges |
+| Sea, bay, harbour, lake | a closed outline on the eight directions, any size, filled with the water colour; the same darker edge, 0.025 outside the fill. Where a ferry runs, at least 0.5 G of open water so its lane keeps water on both sides |
| Tunnel under water | the line dashed 0.16 on / 0.11 off, plus two ink casing lines 0.02 at 55 % opacity, 0.05 outside each edge of the line |
| Pen tip | white core r 0.11, ring 0.05 in the line colour, soft halo r 0.8 in the line colour (45 % at the centre) |
-| Line bullet | disc r 0.25 in the line colour; numeral 800 weight, 0.27 (one figure), 0.22 (two), 0.15 (a short word); opening year 0.17 bold ink, centred 0.30 below |
-| Train | white capsule 0.40 × 0.14, ink outline 0.026, three windows 0.064 × 0.056 in the line colour |
+| Line bullet | rail: disc r 0.25 in the line colour; bus and ferry: rounded square 0.48 with corner radius 0.12. Numeral 800 weight, 0.27 (one figure), 0.22 (two), 0.15 (a short word); opening year 0.17 bold ink, centred 0.30 below |
+| Vehicle | white capsule 0.40 × 0.14, ink outline 0.026, three windows 0.064 × 0.056 in the line colour; trains and buses at about 2 G/s, boats at 0.85 size and about 1.2 G/s |
- **Interchange shape follows the station.** Points side by side make a horizontal stadium, stacked points a vertical one; lines that cross at one point make a circle r 0.13 with the ink outline, which reads as an interchange next to the 0.085 stop because of its black edge. A capsule never rotates to 45°; a diagonal spread becomes a rounded square.
- **Two passes.** A 2D canvas inks only the region the camera sees into a texture (about 1.35× the screen density at the focus, capped at 4096², mipmapped, anisotropic filtering), limited in depth to a few camera distances so low views don't starve; a WebGL pass intersects each pixel's ray with the sheet plane, prints the ink onto procedural paper and computes depth of field from the plane's known depth.
@@ -49,14 +50,16 @@ Not Data Storytelling (even a time chart is drawn as two lines with stops), not
| Mode | Line | Stops | Bullet |
|---|---|---|---|
| Metro, suburban rail | solid 0.15 G | stop disc | disc with a figure |
-| Another rail mode (tram, light rail, maglev, people mover) | solid thin 0.07 G | minor-stop disc | disc with a short word |
-| Bus, BRT | hollow 0.15 G: the colour as two 0.04 G edges, paper between | named stops only, as minor-stop discs | rounded square |
-| Ferry, boat | thin 0.07 G with a 0.03 G paper casing, drawn on top of the water band, solid | pier: white rounded square 0.17 G with a ring in the line colour | rounded square |
+| Another rail mode (tram, light rail, maglev, people mover) | solid thin 0.07 G | stop disc; no generated ticks | disc with a short word |
+| Bus, BRT | hollow: 0.15 G wide, the colour as two edges of max(0.04 G, 2.5 px), a paper core of at least 2.5 px; in wide shots the line widens on screen to keep that. Colours lighter than 0.4 relative luminance (yellow, sand, light green) get an ink rim of max(0.015 G, 1 px) | named stops only, stop discs | rounded square |
+| Ferry, boat | a 0.07 G thread in the line colour on a paper lane 0.25 G wide (at least 10 px on screen), solid, over open water; it starts at a pier on the water's edge, with at most 0.5 G over land | pier: white rounded square 0.17 G, ring 0.04 G in the line colour | rounded square |
| Under water or underground | the line's own form, dashed, with the ink casing (§2) | none inside the tunnel | — |
-| Walking transfer | two capsules joined by a 0.06 G white bar with the same ink outline; out of station: an ink dotted line, dots 0.03 G every 0.08 G | — | — |
+| Walking transfer, in a station complex | a white bar 0.06 G wide with a 0.055 G ink outline outside it (0.17 G overall) from capsule centre to capsule centre, under the capsules; each station keeps its own capsule (one line: the r 0.13 circle) | — | — |
+| Walking transfer, through the street | ink dots of radius 0.015 G every 0.08 G between the two stations' own markers, no capsule added; the shared name is printed once, at the station the story arrives at | — | — |
- Dashes mean "below": a ferry is never dashed, a tunnel always is.
-- **Red (or the oldest line's colour) is the story's accent**: the first section, the "you are here" dot, the stamp of a verdict. A second, dark neutral (navy) stands for anything compared against.
+ Dashes mean "below": a ferry is never dashed, a tunnel always is. The ferry's paper lane is what tells it from a tram at any distance (10 px of paper on blue in a wide shot); a tram never runs on water without a bridge, which is drawn as ordinary track.
+- **Paper inside a line is never painted.** The paper of a bus core or a ferry lane is erased out of the ink layer (canvas `destination-out`), so the procedural paper of the print pass shows through with its own tooth and light; a paper-coloured stroke never matches it. Erasing removes every ink beneath, so order the ink: water → surface lines (bus, ferry) → rail lines → stops and capsules → labels. A bus core over water then shows paper (correct for a printed map), and a rail line crossing a bus line stays whole on top.
+- **Red (or the oldest line's colour) is the story's accent**: the first section, the "you are here" dot, the stamp of a verdict. When the accent sits on a line of the same colour, the dot is r 0.17 G (more than twice the line's width) with a 0.04 G white outline and a pulsing ring, so it never melts into the line. A second, dark neutral (navy) stands for anything compared against.
- Light colours (yellow, lilac, aqua, light green, sand) carry ink inside bullets; deep colours carry white.
- A paper wash (veil, 60 % paper over the sheet) fades the network back when one part must lead; stations under it keep about 20 %; never a dark overlay.
@@ -67,7 +70,7 @@ Example (our demo): paper #F2EEE5, ink #1B1C1E, secondary text #4A4740, river #B
- **Faces**: a neutral grotesk for Latin and figures (Inter in the demo) and a CJK sans of matching weight (Noto Sans SC, subset to the characters used). OFL, self-hosted. Native language above, second language below, one line each, never wrapped.
- **Sizes on the sheet**, in G (native / second language): hub label 0.30 / 0.17 bold; interchange 0.23 / 0.14 semibold; named stop 0.20 / 0.14 semibold; the second line in warm grey, 0.03 G below. Callout: date figures 0.58 heavy, native line 0.34, second line 0.24. Printed panel titles 0.58–0.60 / 0.36–0.38. Cartouche title 0.64 / 0.30, its note 0.24 in grey. Water names 0.22 / 0.17, set along the band.
- **Labels**: a paper-coloured halo (0.05 G stroke at 92 %) under every label. Placement is automatic: eight candidates around the station's edge (in order of preference: east, west, north-east and south-east, north and south, north-west and south-west), each scored against every line of the **finished** network and against labels already placed, hubs and interchanges first. It runs once, before the first frame, so a label never jumps while lines are drawn and lines that arrive later never cross it. A hand preference may override the score for a few stations.
-- **Levels of detail by zoom**: minor stops fade in between 55 and 85 px per G, interchange names between 62 and 90, named-stop names between 100 and 130; hubs keep their names at every scale and grow when pulled out (× (85 / zoom)^0.6, at most 1.75), anchored to the station edge so they grow away from it without changing side. Which names show may also be chosen by shot, never flashed by time.
+- **Levels of detail by zoom**: minor stops fade in between 55 and 85 px per G, interchange names between 62 and 90, named-stop names between 100 and 130; hubs keep their names at every scale and grow when pulled out (× (85 / zoom)^0.6, at most 1.75), anchored to the station edge so they grow away from it without changing side. Which names show may also be chosen by shot, never flashed by time. While the camera rides a tip, names leave the frame before they can be read: show them in the held shots that follow, not during the ride.
- **Legibility is measured where the text lands**: font size on the sheet × the zoom at that point, foreshortened by the tilt. Text the viewer must read keeps the native line ≥ 20 px at 1080p and the second line ≥ 12 px (≥ 16 px on the counter); a two-line label counts only when its block is ≥ 26 px tall on screen. Below that, hide it by level of detail or move the camera.
- **Callouts** are printed on the paper: a bar 0.10 G wide in the accent (or the line being drawn), then the date in heavy figures, one native line, one second-language line; they wipe on from the bar in about 0.5 s. When a callout must sit over lines it gets a paper-coloured block with a soft shadow, no border.
- **Cartouche**: in one corner of the sheet, an ink bar, the map's name in both languages and a one-line note in grey. It is furniture: the camera finds it, it is not a title card.
@@ -80,7 +83,8 @@ Example (our demo): paper #F2EEE5, ink #1B1C1E, secondary text #4A4740, river #B
- Stops pop from 0.6× with a small overshoot in about 0.28 s and a ring in the line colour that spreads from 0.10 to 0.42 G and fades in 0.6 s. Minor stops pop the same way at a smaller size.
- Interchanges scale down from 2× in 0.22 s with an ink ring spreading to 0.64 G. A major interchange falls from above in about 0.4 s (from 3.4× its size, its shadow offset and blurred, sharpening as it lands), then rings in ink and in the colours of the lines that met spread to 1.4–2.6 G in 0.9 s.
- Line bullets spring in with a back ease and carry the opening year; they fade when the story moves past their chapter.
-- Trains: white capsules running at a constant speed (about 2 G/s), one per 4 G of track in each direction, only on finished track.
+- Vehicles (§2): white capsules at a constant speed, one per 4 G of track in each direction, only on finished track; boats slower than trains and buses.
+- A line that starts from a station already on the map makes it an interchange the moment its tip leaves; start that tip at least 0.5 s after the first line has reached the station, so the capsule's fall reads as an arrival.
- What never moves: the geometry of anything already built, label positions, the paper and its light.
- A still of the style shows the medium in motion: at least one pen tip with its halo or trains on finished track, the counter landed, and a tilted view with depth of field.
@@ -90,7 +94,7 @@ A pinhole camera with a 32° vertical field of view (about a 42 mm lens on full
| Move | Tilt / zoom / aperture | What it expresses | Can serve |
|---|---|---|---|
-| ride the pen tip, aim about 1.5 G ahead of it | tilt 15–30°, heading within ±15°, 130–260 px/G, aperture 16 | building, one step at a time | the first section; a single new line; a route described stop by stop |
+| ride the pen tip, aim about 1.5 G ahead of it | tilt 15–30°, heading within ±15°, 130–260 px/G for a tip at 1–3 G/s, aperture 16 | building, one step at a time | the first section; a single new line; a route described stop by stop |
| drop low where a line meets water | tilt ~60°, 185 px/G, aperture 26, eased in and out over ~0.5 s | crossing, risk, a threshold | a river or strait; a border; going underground |
| continuous pull-back with level-of-detail changes | tilt 12° → 0°, 80 → 50 px/G, aperture 6 → 0 | growth, scale arriving | years passing; a network filling in; "how big it became" |
| low oblique sweep with shallow focus | tilt 57–62°, heading swinging about 40°, ~100 px/G, aperture 24, inked depth extended | density, life, the present tense | the busiest core; everything running at once |
@@ -99,7 +103,7 @@ A pinhole camera with a 32° vertical field of view (about a 42 mm lens on full
| push in to one segment under a paper veil | tilt 4° → 0°, 60 → 140 px/G, aperture 3 → 0 | memory, origin | where it began; "you are here" |
| locked frame | tilt 0°, aperture 0 | reading, judging | any comparison or verdict (hold ≥ 2.5 s before the verdict) |
-The camera is never lower than about 25° above the paper (tilt ≤ 65°): lower, and the sheet stops reading as a map. Top views carry no blur; any tilt above 10° carries some.
+When riding a tip, keep tip speed × zoom at or under about 500 px/s on screen (a long, fast line means a wider zoom or a slower tip). The camera is never lower than about 25° above the paper (tilt ≤ 65°): lower, and the sheet stops reading as a map. Top views carry no blur; any tilt above 10° carries some.
Framing: the subject sits off-centre with room ahead of a moving tip; the counter owns the top-left corner and nothing important goes under it. Transitions: match cuts on round shapes (a headlight, a lamp, a coin becomes a station dot), glides across the sheet, hard cuts to a new panel. No page turns, no fades to black mid-film.
@@ -110,17 +114,17 @@ Framing: the subject sits off-centre with room ahead of a moving tip; the counte
- **Layering by line**: each new line adds one voice to a running ostinato (flute, spiccato strings, xylophone, horn staccato, harp, trumpet, oboe…), so the arrangement grows with the network. Accelerate by adding voices, not by changing tempo; a groove written in film time never stretches when picture time is slowed.
- **Matter**: a felt-tip glide under every drawing tip; rail clacks in pairs for trains; ratchet ticks for the counter; a filtered, submerged mix while a line runs under water; a descending whistle and a low hit for a capsule that falls.
- **Silence**: one beat of near-silence before a verdict; the end thins to a pad and the chime.
-- Mix: music under the effects, sub-bass shelved (< 50 Hz well below the rest), true peak ≤ −3 dBTP, about −16 LUFS before the master's −14.
+- Mix: music under the effects, sub-bass shelved (< 50 Hz well below the rest), true peak ≤ −3 dBTP measured oversampled (ebur128 with peak=true; a sample-peak limiter misses the inter-sample peaks of short clicks and plucks, so soft-clip those first), about −16 LUFS before the master's −14.
## 8. Native moves
- **The pen tip.** A glowing tip draws a line at the camera's pace; stops light behind it. *Fits content like:* a product roadmap; a migration route; a career, job by job.
-- **The interchange that falls.** When two lines meet for the first time the capsule drops onto the paper with its shadow, then shock rings in both colours. *Fits content like:* two teams merging; a treaty; two rivers joining.
+- **The interchange that falls.** When two lines meet for the first time (a second line arriving, or leaving from a station already drawn) the capsule drops onto the paper with its shadow, then shock rings in both colours. *Fits content like:* two teams merging; a treaty; two rivers joining.
- **The tunnel under the water.** Inside the water band a line turns dashed with a casing; the camera drops low to watch it cross. *Fits content like:* a cable under the sea; a deadline crossed; going public.
- **Time lines.** Two networks drawn as two lines over one year axis, stops at sourced milestones, brackets for the spans. *Fits content like:* two companies' growth; two countries' rollouts; a project against its plan.
- **Levels of detail.** Pulling back, minor stops and their names fade first, interchange names next, hubs stay. *Fits content like:* zooming from a street to a city; from a team to a company; from a gene to a genome map.
- **You are here.** The network fades under a paper veil, one segment stays lit, a red dot pulses. *Fits content like:* an origin story; a recap; a call to visit.
-- **The odometer.** Rolling drums that land only on true values: a year, a running total, a time of day, a count. *Fits content like:* kilometres, users, stores, sensors.
+- **The odometer.** Rolling drums that land only on true values: a year, a running total, a time of day, a count. Each landed value must hold for its reading time (about 1.8 s for five characters), so plan about one landing per 2 s of film; more values than that go into printed callouts. *Fits content like:* kilometres, users, stores, sensors.
- **The plate by the lens.** A station name plate stands on the sheet near the camera, out of focus, as the low sweep passes it. *Fits content like:* a place that matters; a stop someone uses every day; a product's home.
## 9. Pitfalls of the medium
@@ -139,16 +143,28 @@ Framing: the subject sits off-centre with room ahead of a moving tip; the counte
## 10. Engine
-The pipeline, independent of any code: (1) the network as data: stations with native and second-language names and a tier, lines as lists of stations, offsets and bends on the G lattice; (2) expand each route into an octilinear polyline, fillet the corners, measure arc length; (3) precompute everything time-dependent once: when each tip passes each station (by bisection on its keyframes), when a station becomes an interchange, label placement on the finished network; (4) per frame: camera → the region of the sheet it sees → ink that region into a texture → lay it on the plane, print it on paper, light it, blur it by depth → draw the screen-space instrument.
+The pipeline, independent of any code: (1) the network as data: stations with native and second-language names and a tier, lines as lists of stations, offsets and bends on the G lattice, water as bands and areas; (2) expand each route into an octilinear polyline, fillet the corners, measure arc length; (3) precompute everything time-dependent once: when each tip passes each station (by bisection on its keyframes), when a station becomes an interchange, label placement on the finished network; (4) per frame: camera → the region of the sheet it sees → ink that region into a texture (water, surface lines with their erased paper, rail lines, stops, capsules, labels) → lay it on the plane, print it on paper, light it, blur it by depth → draw the screen-space instrument.
-In our demo (`demo/`):
+In our demo (`demo/`), the engine is generic and the film lives in two data files:
-- `net.js`: the network as data, `expand()` (automatic octilinear bends).
-- `film.js`: fillets and arc length (`rounded`, `pointAt`, `subPath`), tunnel intervals, generated minor stops, growth phases and light-up times, `placeLabels()`, the camera (`basis`, `toScreen`, `toPlane`), the inked region (`regionFor`), map drawing, events for the score, `window.TEXTS` for the reading-time check.
- `gl.js`: `makePlane(canvas, paper)`: plane, paper, raking light, sheen, sheet edge, depth of field, vignette.
-- `timeline.js`: the film's direction (facts, phases, camera keys, annotations, panel, counter, overlays, cues). A new film replaces it and `net.js`.
-- The demo engine draws the solid, thin and tunnel forms; the hollow (bus), cased (ferry) and connector forms of §3 are one or two extra strokes in the same line loop.
-- Minimal use, unlike the demo: an invented tram network of three stations and two lines with `thin: true` in `net.js`, one phase per line in `timeline.js`, a camera that rides the first tip; the shared stop becomes a capsule on its own.
+- `film.js`: the engine. Fillets and arc length (`rounded`, `pointAt`, `subPath`), water and tunnel intervals, generated minor stops, the four line forms (`MODES`, `surfaceLine`), piers, walking links, growth phases and light-up times, `placeLabels()`, bullets, the falling interchange, the camera (`basis`, `toScreen`, `toPlane`), the inked region (`regionFor`), events for the score, `window.TEXTS` for the reading-time check. It holds no network and no story.
+- `net.js` → `window.NET = {G, ST, LINES, WATER, LINKS, pt, sid, expand}`. `ST`: `id: [x, y, native, second, tier]` (G; tier 1 hub, 2 interchange, 3 named stop, 4 unnamed). `LINES`: `{id, color, route, branch?, mode?: 'metro' | 'light' | 'bus' | 'ferry', bullet?, ink?, loop?}`; route items are a station id, `[id, dx, dy]` (an offset for parallels) or `[x, y]` (a bend), `'/'` puts the next bend diagonal-first. `WATER`: `{line, outer, inner, tunnel?}` bands and `{area, tunnel?}` outlines. `LINKS`: `{a, b, out?}`.
+- `timeline.js` → `export const DATA` (and optionally `export const WARP`, film time ↔ story time). Required: `DUR`, `SHEET [x0, y0, x1, y1]` (world units, 100 per G), `PHASES` (`{path, a, b, t0, t1, year?, yearLabel?, keys?: [[t, station]...], lin?, bLast?, glow?}`), `camera(t) → {x, y, z, tilt, head, ap, focus?, far?, vig?, dim?}`. Optional hooks, each with a neutral default:
+
+| Hook | Signature | Does |
+|---|---|---|
+| `LABEL_PREF`, `nameAt`, `labelOnly`, `forceLabel`, `hubLabelScale` | `{id: 'e'…}`, `(n, t) → [native, second]`, `t → ids \| null`, `(n, t) → 0..1`, `z → k` | label side, renamed stations, names per shot, forced names, hub growth |
+| `noRoundel`, `roundelPos`, `roundelAlpha`, `roundelScale` | `[ids]`, `{id: [x, y]}` (G), `(t, id, z) → 0..1`, `z → k` | line bullets |
+| `drops`, `dropRing` | `{id: true}`, `(c, n, k2, {capsule, INK})` | which interchanges fall; a custom landing |
+| `veil`, `stationDim`, `highlight` | `t → 0..1`, `(n, t, veil) → alpha`, `(c, t, {PATHS, pointAt, subPath}, top)` | paper veil and the lit segment |
+| `waterLabels` (or `riverLabels`), `furniture`, `annotations` | `(c, t, view, helpers)` on the sheet | water names, cartouche and panels, callouts |
+| `trains` | `(c, t, {PATHS, PH, phaseHead, train, pointAt})` | vehicles |
+| `overlay`, `tunnelOnly` | `(c, t, {b, toScreen, F, INK, view, regW, regS})` in 1920 × 1080 screen space, `t → bool` | the counter, objects by the lens, a screen-only opening |
+| `cues`, `init` | `[{t, type}]` (story time), `(helpers)` | sound cues; access to the built network |
+
+ Every text a hook prints that must be read is registered with `regW` (on the sheet) or `regS` (screen) for `window.TEXTS`.
+- Minimal use, unlike the demo: an invented harbour town with one tram line (`mode: 'light'`), a ferry (`mode: 'ferry'`) across a bay `area`, a bus (`mode: 'bus'`) and an in-station `LINKS` pair, one phase per line and a `camera` in `timeline.js`: nothing else is needed for the shared stop to become a capsule, the ferry to get its lane and piers, and the bus its hollow line.
## 11. Variation space
diff --git a/styles/transit-map/demo/film.js b/styles/transit-map/demo/film.js
index ab5b68c..3e6226c 100644
--- a/styles/transit-map/demo/film.js
+++ b/styles/transit-map/demo/film.js
@@ -1,12 +1,25 @@
-// 《6 公里》 6 Kilometres — Transit Map style demo.
-// A printed schematic of the Shanghai Metro grows year by year from the 6 km first section of Line 1 (1993).
-// Unofficial fan film: line colours and station names are public facts; no operator logo, our own schematic.
+// Transit Map engine: a printed octilinear network drawn by pen tips on a sheet of paper, under a perspective camera.
+// Generic: it holds no network and no story. The network is net.js (window.NET); the film's direction is timeline.js
+// (export DATA, optional export WARP). Every DATA hook below has a default, so a film defines only what it uses;
+// the full list with signatures is in STYLE.md §10 and DEMO.md "Build notes".
// render(t) depends only on t: line growth, stations, trains, camera and counters are closed-form functions of t,
// precomputed at load where needed (station light-up times, label placement).
import { clamp, lerp, seg, ss, eio, eo, ei, back, monotone, track, mulberry, hash } from '/core/lib.js';
-import { DATA, WARP } from './timeline.js';
+import * as TL from './timeline.js';
-const { G, ST, LINES, RIVER, SUZHOU, expand, pt: gpt } = window.NET;
+const DEFAULTS = {
+ // required: DUR (story seconds), SHEET [x0, y0, x1, y1] (world units), PHASES, camera(t) -> {x, y, z, tilt, head, ap, focus?, far?, vig?, dim?}
+ WARP: null, // [[filmT, storyT], ...]; default: film time = story time
+ LABEL_PREF: {}, nameAt: null, labelOnly: null, forceLabel: () => 0, hubLabelScale: z => clamp(Math.pow(.85 / z, .6), 1, 1.75),
+ noRoundel: [], roundelPos: {}, roundelAlpha: () => 1, roundelScale: z => clamp(Math.pow(.9 / z, .55), 1, 1.8),
+ drops: {}, dropRing: null, // ids of interchanges that fall onto the paper; dropRing(c, n, k2, helpers) overrides the landing
+ veil: () => 0, stationDim: () => 1, highlight: () => {},
+ waterLabels: null, riverLabels: () => {}, furniture: () => {}, annotations: () => {}, trains: () => {}, overlay: () => {},
+ tunnelOnly: () => false, cues: [], init: () => {},
+};
+const DATA = { ...DEFAULTS, ...TL.DATA };
+const WARP = TL.WARP || DATA.WARP || [[0, 0], [DATA.DUR, DATA.DUR]];
+const { G, ST, LINES, WATER = [], LINKS = [], expand, pt: gpt } = window.NET;
const DUR = DATA.DUR; // story time (tau)
const DUR_T = WARP[WARP.length - 1][0]; window.DUR = DUR_T; // film time
// film time t -> story time tau (piecewise linear: a slow 1995 beat, a longer verdict hold)
@@ -79,10 +92,29 @@ function subPath(c, path, a, b) { // trace the part [a, b] of a path into the cu
const W = v => v * G;
// river polyline (world) and distance to it
-const RIV = RIVER.map(q => [W(q[0]), W(q[1])]), SUZ = SUZHOU.map(q => [W(q[0]), W(q[1])]);
-const RIVER_W = 76;
+// water (NET.WATER): bands {line: [[x, y]...], outer, inner} (widths in G) and areas {area: [[x, y]...]} (sea, bay, harbour,
+// lake: a closed octilinear outline). With tunnel: true, lines crossing it turn dashed with a casing.
+const WAT = WATER.map(w => ({ ...w, pts: (w.line || w.area).map(q => [W(q[0]), W(q[1])]), outerW: W(w.outer ?? .81), innerW: W(w.inner ?? .75) }));
+function inPoly(poly, x, y) { let ins = false; for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) { const [xi, yi] = poly[i], [xj, yj] = poly[j]; if ((yi > y) !== (yj > y) && x < (xj - xi) * (y - yi) / (yj - yi) + xi) ins = !ins; } return ins; }
+function inWater(x, y) { // inside a tunnel-making body of water, with the same 0.075 G margin past its edge
+ for (const w of WAT) { if (!w.tunnel) continue;
+ if (w.area) { if (inPoly(w.pts, x, y) || distPoly([...w.pts, w.pts[0]], x, y) < 7.5) return true; }
+ else if (distPoly(w.pts, x, y) < w.outerW / 2 + 7.5) return true; }
+ return false;
+}
function distPoly(poly, x, y) { let best = 1e18; for (let i = 1; i < poly.length; i++) { const [ax, ay] = poly[i - 1], [bx, by] = poly[i], dx = bx - ax, dy = by - ay, l2 = dx * dx + dy * dy || 1; const f = clamp(((x - ax) * dx + (y - ay) * dy) / l2); best = Math.min(best, Math.hypot(x - ax - dx * f, y - ay - dy * f)); } return best; }
+// ---------------------------------------------------------------- modes (line form carries the mode; colour carries identity)
+// metro: solid 0.15 G · light (tram, light rail, maglev, people mover; old flag thin: true): solid 0.07 G
+// bus: hollow 0.15 G, edges max(0.04 G, 2.5 px), paper core · ferry: 0.07 G thread on a 0.25 G paper lane, never dashed
+const MODES = {
+ metro: { lw: 15, fillet: 34, minor: true }, light: { lw: 7, fillet: 30 },
+ bus: { lw: 15, fillet: 34, hollow: true, square: true, surface: true }, ferry: { lw: 7, fillet: 30, lane: 25, square: true, surface: true, pier: true },
+};
+const modeOf = L => MODES[L.mode || (L.thin ? 'light' : 'metro')];
+const lum = hex => { const v = [1, 3, 5].map(i => { const c = parseInt(hex.slice(i, i + 2), 16) / 255; return c <= .04045 ? c / 12.92 : Math.pow((c + .055) / 1.055, 2.4); }); return .2126 * v[0] + .7152 * v[1] + .0722 * v[2]; };
+const inkOn = L => L.ink ?? lum(L.color) > .4; // ink text in the bullet on light colours
+
// ---------------------------------------------------------------- network build
const PATHS = {}; // key: lineId or lineId+'b'
const LINE = {};
@@ -91,13 +123,13 @@ for (const L of LINES) {
for (const key of ['route', 'branch']) {
if (!L[key]) continue;
const ex = expand(L[key]);
- const path = rounded(ex.pts.map(q => [W(q[0]), W(q[1])]), L.thin ? 30 : 34);
+ const path = rounded(ex.pts.map(q => [W(q[0]), W(q[1])]), modeOf(L).fillet);
path.line = L.id; path.color = L.color; path.key = L.id + (key === 'branch' ? 'b' : '');
path.st = []; // stations on the path: {id, s, x, y}
L[key].forEach(it => { if (it === '/') return; const id = NET.sid(it); if (!id) return; const q = gpt(it); path.st.push({ id, x: W(q[0]), y: W(q[1]), s: project(path, W(q[0]), W(q[1])) }); });
// tunnel intervals: where the path is inside the river band
path.tun = []; let inT = false, s0 = 0;
- for (let s = 0; s <= path.total; s += 4) { const q = pointAt(path, s), d = distPoly(RIV, q[0], q[1]); const now = d < RIVER_W / 2 + 10;
+ for (let s = 0; s <= path.total; s += 4) { const q = pointAt(path, s); const now = !modeOf(L).surface && inWater(q[0], q[1]);
if (now && !inT) { inT = true; s0 = s; } if (!now && inT) { inT = false; path.tun.push([s0, s]); } }
if (inT) path.tun.push([s0, path.total]);
// minor stops between named stations
@@ -257,11 +289,11 @@ function labelText(c, n, a, scaleK = 1) {
const w = Math.max(wz, we), lx = L.align === 'left' ? ox : L.align === 'right' ? ox - w : ox - w / 2;
regW('st-' + n.id, nm[0] + ' ' + nm[1], n.cx + lx, n.cy + oy, n.cx + lx + w, n.cy + oy + zs + 3 * k + es, a, 26);
}
-function roundel(c, x, y, line, sc, r = 25) {
+function roundel(c, x, y, line, sc, r = 25) { // the line bullet: a disc for rail, a rounded square for bus and ferry
const L = LINE[line]; c.save(); c.translate(x, y); c.scale(sc, sc);
- c.beginPath(); c.arc(0, 0, r, 0, 7); c.fillStyle = L.color; c.fill();
- const txt = L.id === 'P' ? '浦江' : L.id === 'M' ? '磁浮' : L.id === 'A' ? '机场' : L.id;
- c.fillStyle = ['3', '9', '10', '13', '16', '2', '15'].includes(L.id) ? INK : '#fff';
+ c.beginPath(); if (modeOf(L).square) c.roundRect(-24, -24, 48, 48, 12); else c.arc(0, 0, r, 0, 7); c.fillStyle = L.color; c.fill();
+ const txt = L.bullet ?? L.id;
+ c.fillStyle = inkOn(L) ? INK : '#fff';
c.font = F(800, L.id.length > 1 || txt.length > 1 ? (txt.length > 2 || /[^\x00-\x7f]/.test(txt) ? 15 : 22) : 27); c.textAlign = 'center'; c.textBaseline = 'middle';
c.fillText(txt, 0, 1.5); c.restore();
}
@@ -279,6 +311,61 @@ function train(c, path, s, color, a, scale = 1) {
c.restore();
}
+function surfaceLine(c, path, a, b, L, M, z) {
+ // Paper inside a bus line or around a ferry is not painted: it is erased out of the ink layer (destination-out), so the
+ // procedural paper of the WebGL pass shows through with its own tooth and light. Surface lines are drawn before every
+ // solid line, so the erase only removes water and other surface lines under them, never a metro line or a label.
+ c.save(); c.lineCap = 'round'; c.lineJoin = 'round';
+ const px = 1 / Math.max(z, .01); // one screen pixel at the aim point, in world units
+ if (M.hollow) {
+ // 0.15 G with 0.04 G edges; in wide shots it widens so each edge stays >= 2.5 px and the paper core >= 2.5 px
+ const e = Math.max(4, 2.5 * px), w = Math.max(M.lw, 2 * e + 2.5 * px);
+ if (lum(L.color) > .4) { c.strokeStyle = INK; c.lineWidth = w + 2 * Math.max(1.5, px); c.beginPath(); subPath(c, path, a, b); c.stroke(); } // light colours: an ink rim, 0.015 G or 1 px
+ c.strokeStyle = L.color; c.lineWidth = w; c.beginPath(); subPath(c, path, a, b); c.stroke();
+ c.globalCompositeOperation = 'destination-out'; c.lineWidth = w - 2 * e; c.lineCap = 'butt'; c.beginPath(); subPath(c, path, a + 1, b - 1); c.stroke();
+ } else if (M.lane) {
+ c.globalCompositeOperation = 'destination-out'; c.lineWidth = Math.max(M.lane, 10 * px); c.beginPath(); subPath(c, path, a, b); c.stroke(); // the paper lane, >= 10 px
+ c.globalCompositeOperation = 'source-over'; c.strokeStyle = L.color; c.lineWidth = M.lw; c.beginPath(); subPath(c, path, a, b); c.stroke();
+ }
+ c.restore();
+}
+function pier(c, x, y, color, sc = 1) { c.save(); c.translate(x, y); c.scale(sc, sc); c.beginPath(); c.roundRect(-8.5, -8.5, 17, 17, 4); c.fillStyle = '#fff'; c.fill(); c.lineWidth = 4; c.strokeStyle = color; c.stroke(); c.restore(); }
+function drawLinks(c, t, view) { // NET.LINKS: {a, b, out}: in-station (white bar, ink outline) or out-of-station (ink dots)
+ for (const k of LINKS) {
+ const A = SNODE[k.a], B = SNODE[k.b]; if (!A || !B) continue;
+ const t0 = Math.max(A.t1, B.t1); if (t < t0) continue;
+ const u = eo(seg(t, t0, t0 + .35)), x1 = lerp(A.cx, B.cx, u), y1 = lerp(A.cy, B.cy, u);
+ c.save(); c.lineCap = 'round';
+ if (k.out) { const len = Math.hypot(x1 - A.cx, y1 - A.cy), n = Math.floor(len / 8); c.fillStyle = INK;
+ for (let i = 0; i <= n; i++) { const f = n ? i / n : 0; c.beginPath(); c.arc(lerp(A.cx, x1, f), lerp(A.cy, y1, f), 1.5, 0, 7); c.fill(); } }
+ else { c.strokeStyle = INK; c.lineWidth = 6 + 2 * 5.5; c.beginPath(); c.moveTo(A.cx, A.cy); c.lineTo(x1, y1); c.stroke();
+ c.strokeStyle = '#fff'; c.lineWidth = 6; c.stroke(); }
+ c.restore();
+ }
+}
+function dropRing(c, n, k2, { capsule, INK }) { // default landing of a falling interchange: shock rings in ink and in each line's colour
+ if (k2 < 0) return;
+ if (k2 < .9) { const v = k2 / .9, cols = [...n.pts].sort((p, q) => p.tl - q.tl).map(p => LINE[p.line].color);
+ c.save(); c.globalAlpha *= (1 - v) * .75; c.lineWidth = 7; c.strokeStyle = INK; c.beginPath(); c.arc(n.cx, n.cy, 30 + 230 * eo(v), 0, 7); c.stroke();
+ cols.forEach((col, i) => { c.lineWidth = 5; c.strokeStyle = col; c.beginPath(); c.arc(n.cx, n.cy, 26 - 4 * i + (170 - 50 * i) * eo(clamp(v * (1.15 + .15 * i))), 0, 7); c.stroke(); });
+ c.restore(); }
+ capsule(c, n, 1 + .18 * Math.exp(-k2 * 14) * Math.cos(k2 * 40), 7);
+}
+function fallingCapsule(c, t) { // every DATA.drops interchange falls for 0.42 s before it lands at t2; its shadow sharpens
+ for (const id of Object.keys(DATA.drops)) {
+ const n = SNODE[id]; if (!n) continue; const k = t - n.t2; if (!(k > -.42 && k < 0)) continue;
+ const u = 1 + k / .42, h = 1 - ei(u);
+ c.save();
+ c.globalAlpha = .35 * u; c.fillStyle = '#000'; c.filter = `blur(${(14 * h).toFixed(1)}px)`;
+ c.beginPath(); c.ellipse(n.cx + 60 * h, n.cy + 70 * h, 34 + 40 * h, 34 + 40 * h, 0, 0, 7); c.fill(); c.filter = 'none';
+ c.globalAlpha = clamp(u * 2.5);
+ const sc = 1 + 2.4 * h; c.translate(n.cx - 10 * h, n.cy - 30 * h); c.scale(sc, sc);
+ const w = (n.box[2] - n.box[0]) / 2 + 15, hh = (n.box[3] - n.box[1]) / 2 + 15;
+ c.beginPath(); c.roundRect(-Math.max(w, 28), -Math.max(hh, 28), 2 * Math.max(w, 28), 2 * Math.max(hh, 28), 28); c.fillStyle = '#fff'; c.fill(); c.lineWidth = 7; c.strokeStyle = INK; c.stroke();
+ c.restore();
+ }
+}
+
// ---------------------------------------------------------------- the printed sheet: static furniture
const SHEET = DATA.SHEET;
function sheetFurniture(c, t, view) {
@@ -292,20 +379,25 @@ function drawMap(c, t, view) {
const veil = DATA.veil(t); // 0..1: everything but the highlighted first section fades back
// river and creek
c.lineJoin = 'round'; c.lineCap = 'round';
- c.save(); c.strokeStyle = RIVERE; c.lineWidth = RIVER_W + 5; c.beginPath(); RIV.forEach((q, i) => c[i ? 'lineTo' : 'moveTo'](q[0], q[1])); c.stroke();
- c.strokeStyle = RIVERC; c.lineWidth = RIVER_W - 1; c.stroke();
- c.lineWidth = 15; c.strokeStyle = RIVERE; c.beginPath(); SUZ.forEach((q, i) => c[i ? 'lineTo' : 'moveTo'](q[0], q[1])); c.stroke(); c.lineWidth = 11; c.strokeStyle = RIVERC; c.stroke();
+ c.save();
+ for (const w of WAT) { c.beginPath(); w.pts.forEach((q, i) => c[i ? 'lineTo' : 'moveTo'](q[0], q[1]));
+ if (w.area) { c.closePath(); c.strokeStyle = RIVERE; c.lineWidth = W(.05); c.stroke(); c.fillStyle = RIVERC; c.fill(); } // edge 0.025 G outside the fill
+ else { c.strokeStyle = RIVERE; c.lineWidth = w.outerW; c.stroke(); c.strokeStyle = RIVERC; c.lineWidth = w.innerW; c.stroke(); } }
c.restore();
- DATA.riverLabels(c, t, view, { F });
+ (DATA.waterLabels || DATA.riverLabels)(c, t, view, { F });
sheetFurniture(c, t, view);
- // lines
+ // walking links (under everything else on the network)
+ drawLinks(c, t, view);
+ // lines: surface forms first (bus, ferry), because their paper parts are erased out of the ink layer; then solid lines
const active = [];
- for (const o of PH) {
+ for (const pass of [0, 1]) for (const o of PH) {
if (t <= o.t0) continue;
- const head = phaseHead(o, t), path = o.path, L = LINE[path.line];
+ const head = phaseHead(o, t), path = o.path, L = LINE[path.line], M = modeOf(L);
+ if ((pass === 0) !== !!M.surface) continue;
const a = Math.min(o.s0, head), b = Math.max(o.s0, head);
if (b - a < .5) continue;
- const lw = L.thin ? 7 : LW;
+ const lw = M.lw;
+ if (M.surface) { surfaceLine(c, path, a, b, L, M, view.z); if (t < o.t1 + .15) active.push({ o, head, fade: 1 - seg(t, o.t1, o.t1 + .15) }); continue; }
c.save(); c.strokeStyle = path.color; c.lineWidth = lw; c.lineCap = 'round';
// split by tunnel intervals: dashed inside the river
let cur = a; const cuts = path.tun.filter(([x, y]) => y > a && x < b).sort((p, q) => p[0] - q[0]);
@@ -329,7 +421,7 @@ function drawMap(c, t, view) {
DATA.trains(c, t, { PATHS, PH, phaseHead, train, pointAt });
// minor stops
if (lodMinor > 0) for (const path of Object.values(PATHS)) {
- if (LINE[path.line].thin) continue;
+ if (!modeOf(LINE[path.line]).minor) continue;
path.minor.forEach((s, i) => { const tl = path.minorT[i]; if (t < tl) return; const q = pointAt(path, s), k = t - tl;
c.save(); c.globalAlpha = lodMinor * (1 - .6 * veil); stopDot(c, q[0], q[1], path.color, 6.5 * (.6 + .4 * back(seg(k, 0, .25), 3)), 3.6); c.restore(); });
}
@@ -343,10 +435,10 @@ function drawMap(c, t, view) {
if (n.tier <= 3 || lodMinor > 0) { const p = n.pts.reduce((a, b) => a.tl <= b.tl ? a : b); const col = LINE[p.line].color;
const sc = .6 + .4 * back(seg(k1, 0, .28), 3);
if (k1 < .6) { c.save(); c.globalAlpha *= (1 - k1 / .6) * .6; c.lineWidth = 3; c.strokeStyle = col; c.beginPath(); c.arc(p.x, p.y, 10 + 32 * eo(k1 / .6), 0, 7); c.stroke(); c.restore(); }
- c.globalAlpha *= n.tier <= 3 ? 1 : lodMinor; stopDot(c, p.x, p.y, col, 8.5 * sc, 4.6); }
+ c.globalAlpha *= n.tier <= 3 ? 1 : lodMinor; if (modeOf(LINE[p.line]).pier) pier(c, p.x, p.y, col, sc); else stopDot(c, p.x, p.y, col, 8.5 * sc, 4.6); }
} else {
const k2 = t - n.t2, drop = DATA.drops[n.id];
- if (drop) DATA.dropRing(c, n, k2, { capsule, INK });
+ if (drop) (DATA.dropRing || dropRing)(c, n, k2, { capsule, INK });
else { const u = seg(k2, 0, .22), sc = lerp(2.0, 1, eo(u));
if (k2 < .55) { c.save(); c.globalAlpha *= (1 - k2 / .55) * .5; c.lineWidth = 3.5; c.strokeStyle = INK; c.beginPath(); c.arc(n.cx, n.cy, 18 + 46 * eo(k2 / .55), 0, 7); c.stroke(); c.restore(); }
c.globalAlpha *= clamp(u * 3); capsule(c, n, sc); }
@@ -377,6 +469,7 @@ function drawMap(c, t, view) {
labelText(c, n, a, n.tier === 1 ? DATA.hubLabelScale(z) : 1);
}
DATA.annotations(c, t, view, { F, INK, MUTED, pointAt, PATHS, SNODE, W, stopDot, roundel, capsule, LINE, ...RG });
+ fallingCapsule(c, t);
}
// ---------------------------------------------------------------- frame
@@ -440,7 +533,7 @@ function events() {
// ---------------------------------------------------------------- boot
const fontList = ['400 20px Inter', '500 20px Inter', '600 20px Inter', '700 20px Inter', '800 20px Inter', '500 20px NotoSC', '600 20px NotoSC', '700 20px NotoSC', '800 20px NotoSC'];
-Promise.all(fontList.map(f => document.fonts.load(f, f.includes('Noto') ? '上海地铁' : 'A1'))).then(() => document.fonts.ready).then(() => {
+Promise.all(fontList.map(f => document.fonts.load(f, f.includes('Noto') ? '地铁' : 'A1'))).then(() => document.fonts.ready).then(() => {
plane = window.makePlane(glC, paperTexture());
placeLabels();
DATA.init({ PATHS, SNODE, PH, LINE, pointAt, project, W, F, meas, basis, toScreen });
diff --git a/styles/transit-map/demo/net.js b/styles/transit-map/demo/net.js
index f49f9a0..7644b25 100644
--- a/styles/transit-map/demo/net.js
+++ b/styles/transit-map/demo/net.js
@@ -1,6 +1,8 @@
// Schematic of the Shanghai Metro network, drawn by hand on an octilinear grid (0/45/90 degrees).
// Unofficial: geometry is our own schematic, not the operator's map. Units: G = 1 grid step = 100 world units.
// x grows east, y grows south. People's Square is the origin.
+// Lines: {id, color, route, branch?, mode?: 'metro' (default) | 'light' | 'bus' | 'ferry', bullet?: text in the bullet
+// (default: the id), ink?: ink text in the bullet (default: on colours lighter than 0.4 relative luminance), loop?}.
// Route items: 'ID' = the station's point; ['ID', dx, dy] = that station, offset for this line (parallel pairs);
// [x, y] = a bend. Stations carry {zh, en, tier}: tier 1 = big hub (label at every zoom), 2 = interchange, 3 = named stop.
(function () {
@@ -155,26 +157,26 @@ const ST = {
// colours: official line colours of the network (as published on the operator's maps, approximated for print)
const LINES = [
{ id: '1', color: '#E3002B', route: ['XZ', 'LHL', 'JJLY', 'SHNZ', 'CBL', 'TYG', 'XJH', 'CSL', 'SXNL', 'HPNL', 'RMGC', 'HZL', 'SHZ', 'YCL', 'PPXC', 'GFXC', 'FJL'] },
- { id: '2', color: '#82BF25', route: ['XJD', ['HQZ', 0, -0.08], ['HQ2', 0, -0.08], 'SHL', 'LSGL', 'ZSGY', 'JSL', 'JAS', 'NJXL', 'RMGC', 'NJDL', 'LJZ', 'DCL', ['SJDD', 0, -0.1], 'KJG', 'LYL', 'ZJGK', 'GLL', 'CS', 'PDJC'] },
- { id: '3', color: '#FCD600', route: ['SHNZ', [-2.7, 5.9], 'SLL', 'LCL', ['YSL', -0.1, 0], ['HQL', -0.1, 0], ['YAXL', -0.1, 0], ['ZSGY', -0.1, 0], ['JSJL', -0.1, 0], ['CYL', -0.1, 0], [-4.5, -2.5], [-4.1, -2.9], ['ZPL', 0, -0.1], ['ZTL', 0, -0.1], ['SHZ', 0, -0.1], ['BSL', 0, -0.1], 'HKZQ', 'JWZ', 'CJNL', 'JYBL'] },
+ { id: '2', ink: true, color: '#82BF25', route: ['XJD', ['HQZ', 0, -0.08], ['HQ2', 0, -0.08], 'SHL', 'LSGL', 'ZSGY', 'JSL', 'JAS', 'NJXL', 'RMGC', 'NJDL', 'LJZ', 'DCL', ['SJDD', 0, -0.1], 'KJG', 'LYL', 'ZJGK', 'GLL', 'CS', 'PDJC'] },
+ { id: '3', ink: true, color: '#FCD600', route: ['SHNZ', [-2.7, 5.9], 'SLL', 'LCL', ['YSL', -0.1, 0], ['HQL', -0.1, 0], ['YAXL', -0.1, 0], ['ZSGY', -0.1, 0], ['JSJL', -0.1, 0], ['CYL', -0.1, 0], [-4.5, -2.5], [-4.1, -2.9], ['ZPL', 0, -0.1], ['ZTL', 0, -0.1], ['SHZ', 0, -0.1], ['BSL', 0, -0.1], 'HKZQ', 'JWZ', 'CJNL', 'JYBL'] },
{ id: '4', color: '#461D84', loop: true, route: [['YSL', 0.1, 0], ['HQL', 0.1, 0], ['YAXL', 0.1, 0], ['ZSGY', 0.1, 0], ['JSJL', 0.1, 0], ['CYL', 0.1, 0], [-4.3, -2.5], [-4.0, -2.8], ['ZPL', 0, 0.1], ['ZTL', 0, 0.1], ['SHZ', 0, 0.1], ['BSL', 0, 0.1], 'HLL', 'DLL', [3.8, -2.8], [4.3, -2.3], 'PDDD', ['SJDD', -0.1, 0], [4.3, 2.0], ['LCL2', -0.1, 0], [3.6, 3.9], [2.9, 3.9], 'XZNL', 'DMQL', 'DAL', [-3.0, 4.5], 'TYG', [-3.5, 4.5], ['YSL', 0.1, 0]] },
{ id: '5', color: '#944D9A', route: ['XZ', 'DCL5', 'MHKF'], branch: ['DCL5', [-5.8, 12.4], [-2.2, 16.0], [-1.8, 16.4], 'FXXC'] },
{ id: '6', color: '#D40068', route: ['GCL', [9.0, -4.5], 'JFL', 'MSL', [4.5, 0.0], ['SJDD', 0.1, 0], [4.5, 2.0], ['LCL2', 0.1, 0], 'GKXL', 'DMLU', [0.8, 9.5], 'DFTY'] },
{ id: '7', color: '#ED6F00', route: ['MLH', [-6.4, -8.8], [-3.0, -5.4], [-3.0, -2.9], 'ZPL', [-2.4, -2.3], 'CSL7', 'JAS', 'CSL', 'ZJBL', 'DAL', 'LHZL', 'YHL', 'CQL', [2.4, 7.7], [4.4, 5.7], 'GKXL', [7.1, 3.2], [7.1, 2.6], 'LYL', [8.8, 4.4], 'HXL'] },
{ id: '8', color: '#0094D8', route: ['SGL', 'JPL', 'SPL', 'HKZQ', [1.2, -4.0], [0.6, -3.4], 'QFL', [0.6, -0.6], 'RMGC', [0.6, 0.6], 'DSJ', 'LXM', 'LJBL', 'XZNL', 'ZHYSG', 'YHL', 'CSL8', 'DFTY', 'SDGL'] },
- { id: '9', color: '#87CAED', route: ['SJNZ', [-9.6, 4.8], 'QB', 'GLL9', ['YSL', 0, 0], 'XJH', 'ZJBL', 'JSL9', 'MDL', 'LJBL', [1.2, 3.3], 'SCL', [4.2, 0.3], ['SJDD', 0, 0.2], 'YGZL', 'JHL', [10.6, 0.3], 'CL'] },
- { id: '10', color: '#C6AFD4', route: ['XJWC', 'WJC', 'SPL', 'HLL', [1.0, -1.8], 'TTL', 'NJDL', 'YY', [1.0, 1.4], 'LXM', 'XTD', 'SXNL', 'JTDX', [-3.8, 2.4], 'HQL', 'HQ1', [-10.2, 1.4], ['HQ2', 0, 0.12], ['HQZ', 0, 0.12]], branch: ['HQ1', [-7.6, 2.4], 'JTL'] },
+ { id: '9', ink: true, color: '#87CAED', route: ['SJNZ', [-9.6, 4.8], 'QB', 'GLL9', ['YSL', 0, 0], 'XJH', 'ZJBL', 'JSL9', 'MDL', 'LJBL', [1.2, 3.3], 'SCL', [4.2, 0.3], ['SJDD', 0, 0.2], 'YGZL', 'JHL', [10.6, 0.3], 'CL'] },
+ { id: '10', ink: true, color: '#C6AFD4', route: ['XJWC', 'WJC', 'SPL', 'HLL', [1.0, -1.8], 'TTL', 'NJDL', 'YY', [1.0, 1.4], 'LXM', 'XTD', 'SXNL', 'JTDX', [-3.8, 2.4], 'HQL', 'HQ1', [-10.2, 1.4], ['HQ2', 0, 0.12], ['HQZ', 0, 0.12]], branch: ['HQ1', [-7.6, 2.4], 'JTL'] },
{ id: '11', color: '#871C2B', route: ['JDB', [-12.6, -9.6], 'SHXZ', 'ZR', 'CYL', 'LDL', 'JSL', 'JTDX', ['XJH', -0.1, 0], [-2.6, 4.1], [-2.6, 4.7], 'LH', [-0.4, 6.9], '/', [0.6, 8.5], 'DFTY', [1.4, 9.6], [4.0, 9.6], 'DSN'], branch: ['HQ11', [-12.4, -3.6], [-11.6, -2.8], 'SHXZ'] },
{ id: '12', color: '#007A60', route: ['QXL', 'CBL', 'LCL', 'LH', [-1.8, 4.7], 'DMQL', 'JSL9', 'SXNL', [-1.8, 0.7], 'NJXL', 'HZL', 'QFL', 'TTL', [2.2, -2.3], [2.5, -2.3], 'DLL', [3.6, -3.4], 'JFL', [10.4, -3.4], 'JHL'] },
- { id: '13', color: '#E999C0', route: ['JYL', 'DDHL', 'JSJL', 'LDL', 'CSL7', ['HZL', 0, 0], [0.1, -1.0], ['NJXL', 0.1, 0.1], [-1.0, 1.1], [-0.3, 1.8], 'XTD', 'MDL', [-0.3, 4.2], 'SBDD', 'CQL', 'CSL8', 'DMLU', [6.0, 8.6], 'ZKL'] },
+ { id: '13', ink: true, color: '#E999C0', route: ['JYL', 'DDHL', 'JSJL', 'LDL', 'CSL7', ['HZL', 0, 0], [0.1, -1.0], ['NJXL', 0.1, 0.1], [-1.0, 1.1], [-0.3, 1.8], 'XTD', 'MDL', [-0.3, 4.2], 'SBDD', 'CQL', 'CSL8', 'DMLU', [6.0, 8.6], 'ZKL'] },
{ id: '14', color: '#626020', route: ['FL', [-5.8, -2.9], 'ZR', [-4.3, -2.1], [-2.4, -0.2], [-1.3, 0.9], 'HPNL', 'DSJ', 'YY', [2.0, 0.9], 'LJZ', [3.9, -1.0], 'PDDD', [10.0, -1.0], 'GQL'] },
- { id: '15', color: '#BCA886', route: ['GCGY', [-6.6, -3.6], [-6.2, -3.2], 'DDHL', 'LSGL', 'GLL9', [-6.2, 4.0], [-3.7, 6.5], 'SHNZ', [-3.3, 8.0], 'ZZGX'] },
- { id: '16', color: '#98D1C0', route: ['LYL', [7.6, 3.2], [7.6, 4.8], [14.6, 11.8], 'DSH'] },
+ { id: '15', ink: true, color: '#BCA886', route: ['GCGY', [-6.6, -3.6], [-6.2, -3.2], 'DDHL', 'LSGL', 'GLL9', [-6.2, 4.0], [-3.7, 6.5], 'SHNZ', [-3.3, 8.0], 'ZZGX'] },
+ { id: '16', ink: true, color: '#98D1C0', route: ['LYL', [7.6, 3.2], [7.6, 4.8], [14.6, 11.8], 'DSH'] },
{ id: '17', color: '#BC796F', route: ['HQZ', [-12.6, 0], [-15.0, 2.4], 'DFL'] },
{ id: '18', color: '#C4984F', route: ['CJNL', [3.0, -8.0], [4.0, -7.0], 'JPL', [6.1, -2.7], 'MSL', 'YGZL', [6.1, 1.7], 'LYL', [6.6, 6.6], 'YSH'] },
- { id: 'P', name: '浦江线', color: '#B5B5B6', route: ['DFTY', [0.6, 10.2], [2.0, 11.6], 'SHGZ'] },
- { id: 'M', name: '磁浮', color: '#008B9A', thin: true, route: ['LYL', [6.6, 2.8], [12.6, 2.8], 'PDJC'] },
- { id: 'A', name: '机场联络线', color: '#3D688A', route: [['HQZ', 0, 0.12], [-11.6, 0.7], 'QB', [-3.0, 9.3], 'HJ', [0.2, 9.3], [1.4, 10.6], 'SLN', 'ZJZ', 'DJQ', ['PDJC', 0, 0.1]] },
+ { id: 'P', name: '浦江线', bullet: '浦江', ink: false, color: '#B5B5B6', route: ['DFTY', [0.6, 10.2], [2.0, 11.6], 'SHGZ'] },
+ { id: 'M', name: '磁浮', bullet: '磁浮', mode: 'light', color: '#008B9A', route: ['LYL', [6.6, 2.8], [12.6, 2.8], 'PDJC'] },
+ { id: 'A', name: '机场联络线', bullet: '机场', color: '#3D688A', route: [['HQZ', 0, 0.12], [-11.6, 0.7], 'QB', [-3.0, 9.3], 'HJ', [0.2, 9.3], [1.4, 10.6], 'SLN', 'ZJZ', 'DJQ', ['PDJC', 0, 0.1]] },
];
// the Huangpu: Bund stretch north, bend east round Lujiazui, out to the Yangtze (top right)
@@ -207,5 +209,12 @@ function expand(route) {
}
return { pts: out, ids };
}
-window.NET = { G, ST, LINES, RIVER, SUZHOU, pt, sid, expand };
+// water for the engine: bands (rivers, creeks: a centre line and two widths in G) and areas (sea, bay, harbour, lake:
+// a closed octilinear outline); tunnel: true makes lines crossing it run dashed underneath
+const WATER = [
+ { id: 'huangpu', line: RIVER, outer: 0.81, inner: 0.75, tunnel: true },
+ { id: 'suzhou', line: SUZHOU, outer: 0.15, inner: 0.11 },
+];
+const LINKS = []; // walking transfers: {a, b} inside a station complex, {a, b, out: true} through the street
+window.NET = { G, ST, LINES, WATER, LINKS, pt, sid, expand };
})();
diff --git a/styles/transit-map/demo/timeline.js b/styles/transit-map/demo/timeline.js
index db7b0ea..a826d19 100644
--- a/styles/transit-map/demo/timeline.js
+++ b/styles/transit-map/demo/timeline.js
@@ -233,7 +233,7 @@ function expo(c, t, { F, INK }) {
c.fillStyle = INK; c.textAlign = 'left'; c.textBaseline = 'alphabetic'; c.font = F(800, 40); c.fillText('2010 世博会', 40, 4); c.font = F(600, 26); c.fillText('Expo 2010', 40, 38);
c.restore();
}
-// the People's Square ring falls onto the paper before it lands at t2
+// People's Square falls onto the paper before it lands at t2 (the engine draws the fall); dropRing overrides the landing
const drops = { RMGC: true };
function dropRing(c, n, k2, { capsule, INK }) {
if (k2 < 0) return;
@@ -244,19 +244,6 @@ function dropRing(c, n, k2, { capsule, INK }) {
c.strokeStyle = '#E3002B'; c.beginPath(); c.arc(n.cx, n.cy, 22 + 120 * eo(clamp(v * 1.3)), 0, 7); c.stroke(); c.restore(); }
capsule(c, n, 1 + .18 * Math.exp(-k2 * 14) * Math.cos(k2 * 40), 7);
}
-function fallingRing(c, t) {
- const n = H.SNODE.RMGC; const k = t - n.t2; if (!(k > -.42 && k < 0)) return;
- const u = 1 + k / .42; // 0 -> 1 as it falls
- const h = (1 - ei(u)); // height 1 -> 0
- c.save();
- // shadow on the paper grows sharper as the ring comes down
- c.globalAlpha = .35 * u; c.fillStyle = '#000'; c.filter = `blur(${(14 * h).toFixed(1)}px)`;
- c.beginPath(); c.ellipse(n.cx + 60 * h, n.cy + 70 * h, 34 + 40 * h, 34 + 40 * h, 0, 0, 7); c.fill(); c.filter = 'none';
- c.globalAlpha = clamp(u * 2.5);
- const sc = 1 + 2.4 * h; c.translate(n.cx - 10 * h, n.cy - 30 * h); c.scale(sc, sc);
- c.beginPath(); c.roundRect(-28, -28, 56, 56, 28); c.fillStyle = '#fff'; c.fill(); c.lineWidth = 7; c.strokeStyle = '#1b1c1e'; c.stroke();
- c.restore();
-}
// time-line panel content: London and Shanghai drawn as two lines over one axis
function timeLines(c, t, K) { const { F, INK, MUTED } = K; let nid = 0;
if (t < 20.5) return;
@@ -332,7 +319,7 @@ function hereMarker(c, t, K) { const { F, INK } = K;
c.restore();
}
function annotations(c, t, view, k) {
- plaque(c, t, k); expo(c, t, k); fallingRing(c, t); timeLines(c, t, k); hereMarker(c, t, k);
+ plaque(c, t, k); expo(c, t, k); timeLines(c, t, k); hereMarker(c, t, k);
}
// ------------------------------------------------------------------ trains