Interactive text reflow demo powered by Pretext — Cheng Lou's DOM-free text layout engine.
Drag the sprite around and watch the text reflow in real-time.
Open index.html in any modern browser, or:
npx serve .Edit the CONFIG object at the top of the <script> section in index.html:
spriteHTML— Replace with any SVG or<img>tagspriteSize— Width/height of the draggable sprite (px)paragraphs— Array of{ text, title }objectscolumns/columnGap— Multi-column layout settingsfontSize/fontFamily— Typography- Colors —
titleColor,firstTitleColor,textColor,lastParaColor
prepareWithSegments()measures all text segments once via CanvasmeasureText()— no DOM reflow- On each drag frame,
layoutNextLine()computes line breaks with per-line variable widths to flow around the sprite - Text is rendered to
<canvas>in a multi-column layout
MIT