Skip to content

Poojan38380/Editorial-Engine-Upg

Typogenesis β€” Living Typography

Where text breathes, flows, and becomes.

License: MIT TypeScript Vite Stars

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

Showcase

Upgraded Version β€” Ink Theme (Dark)

Typogenesis Editorial Engine Advanced - Dark Theme

Paper Theme (Light)

Typogenesis Editorial Engine - Light Theme

πŸŽ₯ Watch the full demo video

Original (pretext demo)

Original Editorial Engine

Features

Typography

  • 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, @mentions as styled chips
  • Gradient drop cap with drop-shadow filter
  • Cormorant Garamond italic for pull quotes

Interaction

  • 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

Visual

  • 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

Performance

  • 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)

Quick Start

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 build

Architecture

src/
β”œβ”€β”€ 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

Key Design Decisions

  • No framework β€” vanilla TypeScript with DOM pooling
  • GPU-composited transforms β€” orbs use translate3d, never left/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-motion support

How It Works

  1. Preparation phase: pretext measures every word via canvas measureText, caches widths
  2. Layout computation: pure arithmetic on cached widths β€” slot carving, obstacle intersection, column handoff
  3. DOM projection: explicit positioning of each line element β€” no layout tree queries
  4. 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.

Credits

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.

Fonts

  • 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.

Contributing

Contributions are welcome! Please read our Contributing Guide before submitting pull requests.

This project follows a Code of Conduct.

License

MIT License β€” See the LICENSE file for details.

About

Living typography that breathes, flows & reacts. Text wraps around animated obstacles, glows under pressure & floats above a generative particle flow field. Zero DOM reads. Pure arithmetic. <1ms/frame.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors