Skip to content

Explanation

Text and code on planes

write puts text on any plane. code does the same for code, coloured by a small tokenizer. Both wrap to their box.

Text on any plane
Text on any planewrite(text, { at, u, v, size }). u and v are the directions of the text's right and up.A wallA slopeHello,floor.

Drag to turn, scroll or pinch to zoom, double click to reset.

u and v are the directions of the text’s right and up, so the plane can face any way: a floor, a wall, a screen.

Devices with a screen have write and code. The text is laid out inside the screen, from the top left.

Typing code on a screen
Typing code on a screenScreens have code(), and typeOn types it letter by letter.1const s = new Scene();2s.add(ground(),laptop());34// animate it5tl.play(fadeIn(laptop));

Drag to turn, scroll or pinch to zoom, double click to reset.

typeOn types it letter by letter. Wrapping is computed before typing, so words never jump lines in the middle of a word.

Terminals start empty. write() puts lines in them.

A terminal
A terminalTerminals start empty. write() puts lines in them. zsh $ npm installadded 1 package$ npm run builddone in 0.4s

Drag to turn, scroll or pinch to zoom, double click to reset.

wrap is 'word', 'char' or 'none'. mark colours chosen words with a role or any CSS colour, matching strings, regular expressions or [start, end] ranges.

import { Scene, write } from 'cseen';
const s = new Scene({ view: 'front' });
s.add(write('Deploying to production. This takes two minutes.', {
size: [4, 1.2],
fontSize: 'md',
mark: { production: 'accent', 'two minutes': 's2' },
}));
Text that wraps
Text that wrapsText wraps to its box and marks colour chosen words. status.example.com Deploying the new version toproduction. This takes abouttwo minutes, and nothing needsto be restarted.

Drag to turn, scroll or pinch to zoom, double click to reset.

Sizes can be world units, a preset ('sm', 'md' or 'lg', relative to the box), or lines: n, meaning n lines fill the box. Text that still does not fit shrinks, or is cut off if you ask for overflow: 'clip'.

Sizes that fit
Sizes that fitSizes can be world units, sm, md, lg or a number of lines.Size text by preset, by lines,or in world units.Size text by preset,by lines, or in worldunits.Size text bypreset, by lines,or in worldunits.Size text bypreset, by lines,or in world units.

Drag to turn, scroll or pinch to zoom, double click to reset.

Text widths assume a monospace font, which is the default. For another font, give the layout a charWidth. The widths are approximate for custom fonts.