1. Authoring model

Core concepts

Concept Contract
Frame A requirement ($ Frame), not a parameter: local sample time and duration/rate metadata, read with now(), progress(start, end, ease), last_sample_time() and clip_length()
Node Immutable visual description of one sample, keeping semantic children and the order of image operations
Build A requirement: the block a drawing call adds its node to. Drawing is the row $ Build + Frame
Props Typed content, data and style inputs
Prepared assets Immutable font, media, analysis, layout and correspondence handles
Clip A duration plus a retained pure view that can be sampled at other times
Video Picture, audio, target, and delivery and verification policy
Project A name, build!: fn!() -> Result[List[Video], PrepareError] $ Preparing and the fonts its text names; a package's main hands its projects to command_line!, the CLI

A project is its own hd package that depends on nippo and names the library as dep.nippo.X. src/lib.hd is that surface: the prelude's names, plus Project, FontFace, Preparing, Commands, command_line and the native traits its main needs. It re-exports declarations, not modules. nippo's own main is the same thing over src/examples/; nippo-starter is the smallest project package.

A component is not a special class. series, parallel, at and clip.then(...) combine clips and return clips. Grouping does not flatten content into pixels.

There are two composition axes: space, through layout and nested functions; and time, through clips, placement, overlap and retiming. A component can take part in both.

Teach one rule: the function describes what appears, its frame tells it when, and its arguments supply content and style.

A reusable component

struct HeadlineProps:
    label: string
    width: f64
    color: Color

fn headline(p: HeadlineProps) -> Child $ Drawing:
    text(p.label, size=96.0, weight=700.0, max_width=p.width, color=p.color)
        .reveal_words(ms(0), ms(90), ms(240))
        .look(glow(20.0, 0.3, .Some(p.color)))

The author supplies content, timing and appearance without positioning each word. reveal_words keeps layout. To work with the whole component in time, retain its view:

intro := Clip::from_view(sec(3), fn(): headline(props))
picture := series([intro, explanation, outro], overlap=ms(400), transition=.Fade)

Build reusable clips while assembling the video, not on every frame. Scene code can call headline(props) directly. A clip installs its own Frame provider for what it draws, so delayed, retimed and echoed children see their own clocks; clip.show() draws a nested clip at the current time.

A builder without $ Frame cannot change over time, so the renderer may cache its result across frames.

Drawing in blocks

Scenes are written as nested blocks. Each drawing call adds its node to the innermost block and returns a Child, a handle whose modifiers (translate, look, opacity, …) change that node in place:

fn card(label: string) -> Child $ Drawing:
    face := group:
        rect(0.0, 0.0, 300.0, 64.0, hex("#111827"), radius=32.0)
        text(label, size=28.0).center_in(300.0, 64.0)
    face.translate(40.0, 40.0).opacity(progress(ms(0), ms(400)))

fn scene() -> Child $ Drawing:
    canvas(1920.0, 1080.0):
        for k in 0..3:
            card("step ${k}").translate(0.0, 90.0 * f64(k))

Containers (canvas, group, row, column, stack) take a trailing block; loops and if decide children directly. Statement order is paint order. A view is a fn() -> void $ Drawing; Clip::from_view(d, fn(): scene()) and Video.scene(...) take one.

Values remain for what consumes a node rather than drawing it: a look's input, a glass backdrop, a mask, a transition side, a preparation source. Node::rect(...), Node::group(list) and the other Node:: constructors build them; node: captures what a block draws as one value (the node itself, or a group); collect(block) gives the list; add(value) draws a value.

A modifier can't follow a block's dedent, so a container that needs one is bound first (face := group: ...). Blocks can't capture & references; pass by value or copy first.

Progressive customization

An author uses a polished component, adjusts typed inputs, composes more operations, then copies and adapts its ordinary hd source. Library components are readable hd, never opaque native implementations. Start with content, layout, motion, clips and functions; selectors, shaders and display programs come in when a variation needs them.

Three stages

  1. prepare!(props) returns immutable Prepared values. Declared capabilities allow asset reads or configured speech generation here. Fonts, generated audio, timing and correspondence are resolved and locked before rendering.
  2. video(props, prepared) builds a pure Video: target, rate, duration, fonts, background, a scene function, audio and checks.
  3. The runner samples the scene, resolves layout, renders and exports. Scene functions never touch the network, and repeated or shuffled samples don't advance hidden state.

A project brings its own fonts, by path (Project.fonts, a FontSet); FontSet::bundled() is the library's defaults, Inter and JetBrains Mono. Fonts are loaded from files before preparation; there is no implicit system-font lookup, so a render doesn't depend on what the machine has installed.

Prepared results are tied to their input props and configuration. Changing narrated text or morph sources requires preparing again; changing only the output target can reuse compatible assets.

Provider traits declare their rows: AssetRead.read! needs $ FsRead, Speech.speak! needs $ Http + FsRead. Preparation uses the row aliases Reading and Speaking.

Values, units and delivery

Surface Meaning
Video::new(target, rate, duration, background, fonts) Output configuration, plus .scene(view), .audio(track), .markers(...), .color(...) and .verify(...)
Time, ms, sec, Rate::new Time counts flicks (1/705,600,000 s) in an i64. Every common video and audio rate lands on whole flicks, so boundaries are exact and times order, add and hash as integers. Time.max and .ceil_to_frame(rate) support content-derived durations
Target Output size and safe area. Landscape 1920×1080, portrait 1080×1920, square 1080×1080. .inset() and .safe_social() return a Target; .safe() returns the Rect

Geometry, font sizes, effect radii and offsets are in pixels; rotations in radians; progress and strengths are dimensionless. hex takes RGB and RGBA. Working color and alpha rules are explicit, with one final output transform.

hd has no implicit conversions: text(...) adds a node and returns its Child; Node::text(...) returns the Node. validate(ok, message) is a plain call, since validation doesn't wait.

This page’s source on GitHub