Where text breathes, flows, and becomes.
An advanced editorial text layout engine built on pretext. Text flows around animated obstacles, responds to pressure with warm color shifts, and lives atop a generative particle flow field.
Zero DOM reads. Zero reflows. Pure arithmetic.
π Live Demo
π₯ Watch the full demo video
- Multi-column layout with cursor handoff (up to 3 columns)
- Adaptive headline sizing via binary search β largest possible without word breaks
- Shrinkwrap pull quotes β tightest bounding box with zero dead space
- Mixed-font inline flow β technical terms in monospace,
@mentionsas styled chips - Gradient drop cap with
drop-shadowfilter - Cormorant Garamond italic for pull quotes
- Drag orbs to reposition β text reflows in real time
- Click to pause/resume orb animation
- Double-click to remove an orb
- Click empty space to spawn a new orb (max 12)
- Keyboard navigation β Tab to focus orbs, Enter/Space to toggle, arrows to nudge
- Dual themes β Ink (dark editorial) and Paper (light editorial)
- Flow field background β 1200 particles trace invisible wind currents
- Orb-driven wakes β particles scatter and swirl around moving obstacles
- Pressure-reactive text β lines glow amber/rose when compressed by orbs
- Film grain overlay + radial vignette
- Staggered entrance animations on page load
- Layout computation: < 0.5ms per frame
- 0 DOM reads β text measured once via canvas
measureText, cached forever - 0 layout reflows β all positioning is explicit via
translate3d - Color-coded perf meter (green < 0.5ms, amber < 1ms, red > 1ms)
cd D:\Arthur\editorial-engine-adv
npm install
npm run dev # dev server with HMR
npm run build # production bundle (dist/)
npm run preview # serve production buildsrc/
βββ main.ts β Thin entry point (~75 lines)
βββ config.ts β All constants, dual themes, orb definitions
βββ types.ts β Shared type definitions
βββ render.ts β DOM pooling, text projection, GPU transforms, flow field
βββ interaction.ts β Pointer event queue, hit-testing, drag, mode switching
βββ flow-field.ts β 1200-particle system, simplex noise vector field, trails
βββ simplex-noise.ts β 3D simplex noise (seeded, reproducible)
βββ physics.ts β Standalone orb simulation module
βββ layout-engine.ts β Standalone headline fit + column layout
βββ ui.ts β Control panel, perf meter, theme toggle, settings persistence
β
βββ pretext/ β pretext layout engine (frozen, unmodified)
βββ layout.ts β Public API: prepare, layout, walk
βββ measurement.ts β Canvas text measurement
βββ analysis.ts β Text segmentation, normalization
βββ inline-flow.ts β Mixed-font inline layout
βββ line-break.ts β Line breaking engine
βββ bidi.ts β Bidirectional text
βββ text-modules.d.ts
- No framework β vanilla TypeScript with DOM pooling
- GPU-composited transforms β orbs use
translate3d, neverleft/top - Separated concerns β render.ts handles DOM, interaction.ts handles input, flow-field.ts handles particles
- Settings persistence β theme, orb count, speed saved to
sessionStorage - Accessibility β ARIA labels on orbs, keyboard navigation,
prefers-reduced-motionsupport
- Preparation phase: pretext measures every word via canvas
measureText, caches widths - Layout computation: pure arithmetic on cached widths β slot carving, obstacle intersection, column handoff
- DOM projection: explicit positioning of each line element β no layout tree queries
- Flow field: simplex noise drives 1200 particles, orbs disturb the field, trails accumulate
The entire render loop runs in under 1 millisecond regardless of page complexity.
This project is an extended upgrade of the original editorial-engine demo from the pretext repository by Cheng Lou.
pretext β Copyright (c) 2026 Cheng Lou. Licensed under MIT.
The src/pretext/ subdirectory contains an unmodified copy of the pretext layout engine, included here for standalone build convenience.
- Iowan Old Style / Palatino Linotype β body text
- Cormorant Garamond β pull quotes
- JetBrains Mono β inline code
All fonts loaded via Google Fonts. See index.html for details.
Contributions are welcome! Please read our Contributing Guide before submitting pull requests.
This project follows a Code of Conduct.
MIT License β See the LICENSE file for details.


