Aller au contenu
Skillpedia
Sites et interfaces (frontend)260k · #474

pretext

Ce qu’il fait

Elle aide à construire des démonstrations créatives dans le navigateur où le texte est l'élément visuel principal, comme des paragraphes qui s'écoulent autour d'un sprite en mouvement. Elle s'adresse aux développeurs et designers qui veulent des effets web originaux et saisissants.

Quand l’utiliser

  • ✓Quand vous voulez un texte qui s'écoule autour d'une forme ou d'un élément animé en mouvement.
  • ✓Quand vous voulez un jeu ou un effet de style ASCII construit à partir de vrais mots.
  • ✓Quand vous voulez une typographie cinétique qui brise le texte en particules.

Lien du skill

https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/creative/pretext/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/creative/pretext/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Fais une démonstration dans le navigateur où un paragraphe se réorganise autour d'une balle qui rebondit sur la page.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'agent utilise la bibliothèque pretext pour mesurer et disposer le texte sans passer par l'étape de mise en page habituelle du navigateur, de sorte que les positions se mettent à jour rapidement à chaque image. Il construit ensuite l'effet visuel autour de cette disposition.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

Pretext Creative Demos

Overview

@chenglou/pretext is a 15KB zero-dependency TypeScript library by Cheng Lou (React core, ReasonML, Midjourney) for DOM-free multiline text measurement and layout. It does one thing: given (text, font, width), return the line breaks, per-line widths, per-grapheme positions, and total height — all via canvas measurement, no reflow.

That sounds like plumbing. It is not. Because it is fast and geometric, it is a creative primitive: you can reflow paragraphs around a moving sprite at 60fps, build games whose level geometry is made of real words, drive ASCII logos through prose, shatter text into particles with exact per-grapheme starting positions, or pack shrink-wrapped multiline UI without any getBoundingClientRect thrash.

This skill exists so Hermes can make cool demos with it — the kind people post to X. See pretext.cool and chenglou.me/pretext for the community demo corpus.

When to Use

Use when the user asks for:

  • A "pretext demo" / "cool pretext thing" / "text-as-X"
  • Text flowing around a moving shape (hero sections, editorial layouts, animated long-form pages)
  • ASCII-art effects using real words or prose, not monospace rasters
  • Games where the playfield / obstacles / bricks are made of text (Tetris-from-letters, Breakout-of-prose)
  • Kinetic typography with per-glyph physics (shatter, scatter, flock, flow)
  • Typographic generative art, especially with non-Latin scripts or mixed scripts
  • Multiline "shrink-wrap" UI (smallest container width that still fits the text)
  • Anything that would require knowing line breaks before rendering

Don't use for:

  • Static SVG/HTML pages where CSS already solves layout — just use CSS
  • Rich text editors, general inline formatting engines (pretext is intentionally narrow)
  • Image → text (use ascii-art / ascii-video skills)
  • Pure canvas generative art with no text role — use p5js

Creative Standard

This is visual art rendered in a browser. Pretext returns numbers; you draw the thing.

  • Don't ship a "hello world" demo. The hello-orb-flow.html template is the starting point. Every delivered demo must add intentional color, motion, composition, and one visual detail the user didn't ask for but will appreciate.
  • Dark backgrounds, warm cores, considered palette. Classic amber-on-black (CRT / terminal) works, but so do cold-white-on-charcoal (editorial) and desaturated pastels (risograph). Pick one and commit.
  • Proportional fonts are the point. Pretext's whole vibe is "not monospaced" — lean into it. Use Iowan Old Style, Inter, JetBrains Mono, Helvetica Neue, or a variable font. Never default sans.
  • Real source/text, not lorem ipsum. The corpus should mean something. Short manifestos, poetry, real source code, a found text, the library's own README — never lorem ipsum.
  • First-paint excellence. No loading states, no blank frames. The demo must look shippable the instant it opens.

Stack

Single self-contained HTML file per demo. No build step.

Layer Tool Purpose
Core @chenglou/pretext via esm.sh CDN Text measurement + line layout
Render HTML5 Canvas 2D Glyph rendering, per-frame composition
Segmentation Intl.Segmenter (built-in) Grapheme splitting for emoji / CJK / combining marks
Interaction Raw DOM events Mouse / touch / wheel — no framework
<script type="module">
import {
  prepare, layout,                   // use-case 1: simple height
  prepareWithSegments, layoutWithLines,  // use-case 2a: fixed-width lines
  layoutNextLineRange, materializeLineRange, // use-case 2b: streaming / variable width
  measureLineStats, walkLineRanges,  // stats without string allocation
} from "https://esm.sh/@chenglou/pretext@0.0.6";
</script>

Pin the version. @0.0.6 at time of writing — check npm for the latest if demo behavior is off.

The Two Use Cases

Almost everything reduces to one of these two shapes. Learn both.

Use-case 1 — measure, then render with CSS/DOM

const prepared = prepare(text, "16px Inter");
const { height, lineCount } = layout(prepared, 320, 20);

You still let the browser draw the text. Pretext just tells you how tall the box will be at a given width, without a DOM read. Use for:

  • Virtualized lists where rows contain wrapping text
  • Masonry with precise card he
Questions fréquentes

Qu'est-ce que la bibliothèque pretext ?

Une petite bibliothèque TypeScript qui mesure et dispose du texte sur plusieurs lignes sans toucher à la mise en page de la page.

Est-ce destiné aux sites de production ?

La skill vise les démonstrations créatives, du type de celles que l'on partage en ligne, plutôt que la mise en page quotidienne des pages.

Quelle est la taille de la bibliothèque ?

La skill la décrit comme environ 15 Ko, sans dépendances.

Détails

Description originale de l’auteur

Build creative browser demos with DOM-free text layout.

repo: NousResearch/hermes-agent

Popularité

Étoiles GitHub
260k
Position au classement
#474
Licence
MIT
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires