本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)260k · #474

pretext

できること

このスキルは、テキストを主な視覚要素とする、創造的なブラウザのデモの作成を支援します。例えば、動くスプライトの周りを段落が流れるような表現です。風変わりで目を引くWebの効果がほしい開発者やデザイナーのためのものです。

使う場面

  • ✓テキストが動く図形やアニメーションの要素の周りを流れるようにしたいとき。
  • ✓実際の単語から作られたゲームやASCII風の効果がほしいとき。
  • ✓テキストを粒子に分解するキネティックタイポグラフィがほしいとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/creative/pretext/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“段落が、ページの上を跳ねるボールの周りを回り込むブラウザのデモを作ってください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、pretextライブラリを使って、ブラウザの通常のレイアウト処理を経ずにテキストを測定し、レイアウトします。そのため、位置は毎フレーム素早く更新できます。その後、そのレイアウトを中心に視覚効果を作ります。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)を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
よくある質問

pretextライブラリとは何ですか?

複数行のテキストを、ページのレイアウトに触れずに測定し、配置する小さなTypeScriptのライブラリです。

本番のWebサイトのためのものですか?

このスキルは、人々がオンラインで共有するような創造的なデモを対象としており、日常のページのレイアウトには向いていません。

ライブラリはどのくらいの大きさですか?

スキルは、依存関係なしで約15KBだと説明しています。

詳細

作者による元の説明

Build creative browser demos with DOM-free text layout.

repo: NousResearch/hermes-agent

人気

GitHubのスター
260k
ランキング
#474
ライセンス
MIT
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル