Skip to content

feat(demos): Floating Languages — multilingual physics demo with live reflow#93

Open
RAKKUNN wants to merge 1 commit intochenglou:mainfrom
RAKKUNN:feat/floating-languages-demo
Open

feat(demos): Floating Languages — multilingual physics demo with live reflow#93
RAKKUNN wants to merge 1 commit intochenglou:mainfrom
RAKKUNN:feat/floating-languages-demo

Conversation

@RAKKUNN
Copy link
Copy Markdown

@RAKKUNN RAKKUNN commented Apr 3, 2026

What

New demo page: Floating Languages — everyday phrases from 12+ languages
float on screen with physics, colored by script family, and respond to
interaction with live Pretext-powered reflow visualization.

Demo URL

/demos/floating-languages

Features

  • 27 multilingual phrases (Korean, Japanese, Chinese, Arabic, Thai, Hindi,
    English, Spanish, French, German, Portuguese, Russian, Emoji, Mixed bidi)
  • Script-family glow colors: CJK → gold, Arabic → emerald, Indic → coral,
    Thai/SEA → green, European → purple, Emoji → yellow, Mixed → lavender
  • 3 physics modes (Float / Orbit / Gravity) toggled via header buttons
  • Click-to-reflow: clicked bubble animates width 60–320px, Pretext
    recalculates line breaks each frame; particle burst on line-count change
  • User input bar: type any text → auto-detect script → launch new bubble
  • Canvas background: proximity connection lines + per-bubble radial glow
  • FPS counter, bubble count

Pretext APIs used

API Role
prepare() One-time measurement handle per phrase
layout() Height & line count (hot path, pure arithmetic)
prepareWithSegments() Rich handle for walkLineRanges
walkLineRanges() Shrinkwrap width + live reflow animation

Files changed

  • pages/demos/floating-languages.html — new
  • pages/demos/floating-languages.ts — new
  • pages/demos/index.html — added demo card to grid

Multilingual phrases float across the screen with physics simulation,
showcasing Pretext DOM-free text measurement across 27 phrases in
12+ languages.

Features:
- Script-family color coding (CJK=gold, Arabic=emerald, Indic=coral, etc.)
- Three physics modes: free float, orbit, and gravity
- Click-to-reflow animation with live line-break recalculation and particle bursts
- User text input with automatic script detection
- Canvas background with proximity lines and radial glow per family
- FPS counter and bubble count display

Uses prepare(), layout(), prepareWithSegments(), and walkLineRanges()
for all text measurement — zero DOM reads at runtime.
@RAKKUNN
Copy link
Copy Markdown
Author

RAKKUNN commented Apr 3, 2026

Demo Preview

스크린샷 2026-04-03 18 45 58

Demo YouTube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant