Introducing a new way to review your PRs.

Read the announcement

bas3line / ascii

Animated ascii art for web pages, in TypeScript: React, Next.js, Astro, or one HTML tag

View on GitHub

21 documents · Updated Oct 26, 2026

docs / kit-recipes

Kit recipes

Kit recipes are the reusable, named layer above the kit primitives. They turn fields, drawing, scenes, effects, materials, and layouts into ready-to-use looks, motions, and widgets that return normal pieces.

Recipe layer

The recipe layer gives common visual goals a short, word-based interface. A recipe accepts a thing to show or a small set of options, then applies the needed kit parts and returns a piece that can play in the same places as any other piece. The recipe exports are grouped as looks, motion, widgets, shared words, and palette helpers in src/…/index.ts.

The layer separates choice from construction. An engineer can ask for a sea, a floating card, or a gauge without first choosing cells, frames, or math. When a recipe does not fit, the same primitives remain available through the related scene composition, drawing and fields, and effects and materials pages.

Recipe families

Each family solves a different level of reuse. The families can also work together because their results share the piece contract.

FamilyPurposeTypical result
LooksProduce a named animated picture with a palette and visual character.sea(), plasma(), stars()
MotionGive a piece, text, shape, or assembled part a movement pattern.floating(spinning(cube()))
WidgetsProduce a complete display object with a useful shape and behavior.gauge(), progressBar(), card()
Shared wordsConvert common human terms into consistent choices for speed, scale, amount, direction, and easing.speed: "slow", amount: "strong"
Palette helpersGive colors a named meaning that works on light and dark pages.palette("ocean")

Looks

A look is a named moving picture. It packages a field-based visual pattern with its default scale, palette, character ramp, and loop so that a user selects a visual idea instead of writing a formula. The look set covers natural scenes, abstract patterns, weather, space, and light effects in src/…/looks.ts.

Looks remain composable after creation. They can be mixed, added, masked by words or shapes, moved, zoomed, rotated, warped, softened, or placed over another piece. This makes a named look a starting point for a scene rather than a closed asset. See kit drawing and fields for the lower-level field and drawing concepts.

References: src/…/looks.ts• L65-71 src/…/looks.ts• L99-119 src/…/looks.ts• L402-418

Motion

Motion recipes attach a reusable movement pattern to a supported thing. The input may be a piece, text, a grid, a 3D shape, a material area, or assembled parts; pieceOf() gives that input the common piece form before the motion is applied in src/…/words.ts and src/…/motion.ts.

The motion family covers spatial movement, repeated emphasis, and entrance or exit behavior. Its patterns include spinning, orbiting, bouncing, floating, swaying, pulsing, blinking, shaking, drifting, and sliding. Motions wrap, so a recipe can add one behavior around another without rebuilding the source. The nested example in examples/…/recipe-motion-hover.ts makes a cube spin on a turntable while it floats.

References: src/…/motion.ts• L48-63 src/…/motion.ts• L90-156 src/…/motion.ts• L215-267 src/…/motion.ts• L428-512 examples/…/recipe-motion-hover.ts• L1-7

Widgets

A widget is a complete visual object for status, data, text, or display work. It supplies a useful size and visual form so the caller gives it a value or label instead of assembling a frame, text, and chart by hand. The main widget recipes are defined in src/…/widgets.ts.

Widgets include clocks, progress bars, spinners, gauges, sparklines, bar charts, panels, cards, typewriters, marquees, and countdowns. A value may be fixed, animated by the recipe, or read from a function for live data. Widgets are still pieces, so they can receive motion and join rows, columns, grids, layers, or sequences. examples/…/recipe-widget-dashboard.ts shows this role by combining gauges, a sparkline, and a spinner in a dashboard.

References: src/…/widgets.ts• L217-249 src/…/widgets.ts• L252-313 src/…/widgets.ts• L449-505 src/…/widgets.ts• L507-586 examples/…/recipe-widget-dashboard.ts• L1-8

Shared recipe contract

All recipe families return a normal piece with metadata and a frame-producing default. This common result lets downstream players render a recipe in a browser, terminal, SVG, or composition without knowing which recipe made it. The conversion boundary is described by pieceOf() in src/…/words.ts.

Recipes use shared words so an option has the same meaning across families. The shared vocabulary is defined in src/…/words.ts and checked by the family recipes.

Shared choiceRole in recipes
speed and periodControl how fast a motion or animation runs and how long its cycle lasts.
scale, size, height, and radiusDescribe visual extent without requiring cell or geometry calculations.
amount and densitySet strength or quantity with plain words or numbers.
to, from, way, and laneDescribe direction and placement in the terms of the recipe.
easeDescribes how an entrance or movement starts and stops.
name and noteGive the resulting piece stable display metadata.

The recipe layer checks options when the recipe is created. This makes a misspelled or unsupported choice fail near its source instead of silently changing the rendered result. Palette names follow the same shared contract through src/…/palettes.ts.

References: src/…/words.ts• L24-30 src/…/motion.ts• L48-63 src/…/widgets.ts• L217-223 src/…/palettes.ts• L24-45

Composition flow

Recipes form a small pipeline: a caller selects a named behavior, the recipe normalizes its input, the recipe assembles kit primitives, and the result returns to the common piece system.

flowchart LR
    A[Recipe call] --> B[Shared option words]
    B --> C[Recipe family]
    C --> D[Kit primitives]
    D --> E[Named piece]
    E --> F[Motion or effect]
    E --> G[Layout or scene]
    E --> H[Player or export]

The important boundary is the named piece. A look already is a piece. A motion wraps a thing into a piece. A widget creates a piece with its own display behavior. After that boundary, composition and playback do not need to know the recipe family.

References: src/…/words.ts• L37-66 src/…/looks.ts• L92-138 src/…/motion.ts• L115-156 src/…/widgets.ts• L280-313

Time and loop behavior

Recipes describe time as a loop when the output can repeat. A family combines the cycles of its parts so the result returns to its start as one piece. loopFor() in src/…/words.ts provides the shared rule for combining known loops.

This rule supports seamless export and composition. Still inputs do not add a cycle. A live widget or another moving input with no known loop keeps the result loopless. Entrance recipes can also hold forever, which makes their end state a deliberate still state rather than a repeating animation.

References: src/…/words.ts• L69-94 src/…/motion.ts• L441-447 src/…/widgets.ts• L225-249

Extension boundary

The recipe layer is also a pattern for adding reusable product behavior. A new recipe should expose a clear named goal, use shared option words where they fit, compose existing primitives, and return a normal piece. The existing looks, motions, and widgets are short examples of this style in src/…/looks.ts, src/…/motion.ts, and src/…/widgets.ts.

For a custom look, look() supplies a recipe with a normalized scale, speed, period, and looping noise helpers. For a custom motion or widget, the existing families show how a recipe can build from effects, layers, scenes, drawing, and text while keeping the public result simple. Prefer the related kit effects and materials, kit particles and simulation, and kit geometry, math, and images pages when the new behavior depends on one of those primitive groups.

References: src/…/looks.ts• L579-605 src/…/looks.ts• L607-681 src/…/motion.ts• L90-156 src/…/widgets.ts• L33-179

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the exports in src/…/index.ts aligned with the public recipe entry point.
  • Keep shared option words and palette names consistent across looks, motions, widgets, and any new recipe family.
  • Check loop metadata when a recipe adds a moving input, a nested motion, a live value, or a forever hold.
  • Check the pieceOf() boundary when a recipe accepts a new kind of input, so the new input still composes with layouts and players.
  • Keep names and notes useful for composed pieces, since layouts and downstream tools use piece metadata.

Important failure modes

TriggerConsequenceGuard
A recipe accepts an input that pieceOf() cannot normalize.Motion or composition fails before it can produce a piece.Keep accepted inputs within the shared Thing contract or add its conversion path.
A nested moving part has no known loop.The composed output cannot promise a seamless repeating cycle.Preserve loopless metadata and avoid claiming a fixed loop.
A live widget value is treated as a fixed value.Export or playback can show stale data or report a false loop.Keep live readers as live pieces with clock behavior.
A recipe uses a family-specific option without registering it.The option is rejected or a user typo is not checked at the intended boundary.Register family options with the recipe's option contract.
A layout adds a second frame around a widget that already draws one.The result has an unwanted nested border.Preserve the widget's framing metadata when composing it.

Key files

FileWhy to read it
src/…/index.tsShows the public recipe surface and how the recipe groups are exported.
src/…/looks.tsShows how named visual patterns become composable pieces.
src/…/motion.tsShows how reusable movement patterns accept many kinds of things and wrap each other.
src/…/widgets.tsShows how complete data and display objects become pieces with fixed, animated, or live behavior.
src/…/words.tsDefines the shared input boundary, piece conversion, and loop combination rules.
src/…/palettes.tsDefines named colors shared across recipe and primitive layers.
examples/…/recipe-motion-hover.tsShows nested motion recipes applied to a 3D shape.
examples/…/recipe-widget-dashboard.tsShows widgets composed into a larger dashboard.