# Script API

What a comp file calls that is not a node, and the conventions every comp follows. The types are those `lamino schema --dts` prints.

## Conventions

`lamino schema` prints this text. Read it before writing a comp file.

```text
Laminolith conventions (read before writing a comp file)

Coordinates: origin top-left, +x right, +y down. Lengths are in WIDTH UNITS: the image width is 1.0 and
y runs 0..H/W (a 16:9 frame is 1.0 x 0.5625), so the same number means the same shape at any resolution
and proxy level. Rotation is in degrees, clockwise positive. Pixel centres are at +0.5. Never write pixel
counts into parameters (lint L_PIXEL_UNITS). Parameter names are camelCase everywhere (TypeScript, IR, schema).

Colour: every image inside the engine is scene-linear (the config's scene_linear role, ACEScg by default)
and PREMULTIPLIED. `read` converts from the declared input colourspace; declare it (`colorspace`) for
anything that is not an EXR already in the working space (lint L_COLORSPACE_UNSPECIFIED). A read without
`colorspace` takes, in order: a specific file rule of the config, the colourspace the file header declares
(a colourspace attribute, or the OpenEXR `colorInteropID` such as Blender's `lin_ap1_scene`, matched to the
config's names, aliases and interop_ids: info L_COLORSPACE_FROM_FILE), then the default rule (a guess, warned);
EXR chromaticities alone are an estimate (L_ESTIMATED), not a declaration. Nodes that need
straight rgb (grade, colorspace, despill) unpremultiply only where alpha > 0 and re-premultiply by the output
alpha; pixels with alpha 0 keep their rgb (emissive sparks survive). Previews and the review window apply
the display/view transform; EXR output does not. Colour state: each node's pixels are in a colour
space known from the IR (read = working space, or its colorspace with `convert: false`; colorspace() = `to`;
displayView() = the colour space of its display / view, or its scene side with `inverse: true`; lut() = its
input's, or the `outputColorspace` it declares; merge = B; other nodes = their input). Previews, probe, compare, the review window and movies start the view from that
state, so a node already in display values (displayView({ display, view })) gets no second view transform;
render writes the values as they are and records the state in the EXR header `lamino:colorspace`. A view
transform (the tone curve) is applied by displayView() only: colorspace() to a display colour space goes
through the config's default view transform, which in the ACES configs has no tone curve (lint
L_DISPLAY_WITHOUT_VIEW). Display-referred material that goes back out through a view (an offline movie, a
logo) comes in through the inverse of that view: read(path, { colorspace: "<display>", convert: false })
.displayView({ display, view, inverse: true }). Merging two states is lint L_COLOR_STATE_MISMATCH; a `from`
(or what a displayView decodes) that is not the input's state is L_COLORSPACE_FROM_MISMATCH. A colour may be [r,g,b,a], [r,g,b] or a scalar (alpha =
the parameter's identity: 0 for lift/offset, 1 for gain/constant), or "#rrggbb" (sRGB, converted via the config).

Merge: `inputs[0]` is A (the foreground), `inputs[1]` is B (the background). `over` = A + B*(1 - A.alpha);
every op applies to all four channels (Nuke/Natron semantics, alpha masking off); `screen` is HDR-safe.
In the script layer `bg.over(fg)` places fg over bg (the receiver is B) and `over(a, b)` is A over B.
Muting a node (`override mute`) passes its input through (merge: mix = 0).

Nodes: every node — bundled Rust node, project GLSL node or future package — implements the same contract
(ports, params, roi, window, temporal, scale, kernels, hints, version). Namespaces: primitives in `lamino`,
effects and presets in `lamino/fx` (glow, lensBlur, lensFlare, levels, curves, fractalNoise, displace, lightWrap, grain, …;
the After Effects / Nuke staples, see each node's description), AOV nodes in `lamino/aov` (aov, despill, motionBlur,
fog, uvMap). Data layers (depth, motion, position, uv) are read with `aov`, which converts the renderer's
declared conventions to the internal ones (depth: metres from the camera plane; motion: width units, Y down,
forward; position/normal: world, right-handed, Y up, metres; uv: 0..1, V down). Nothing is guessed: declare
`kind`, `units`, `direction`, `space`, `handedness`, `up` as the renderer writes them; `inspect` shows each
layer's value range. No node clips to the display window; only `crop` and the writer do (`render --out`
crops each written frame to the display window unless `--keep-overscan`).

GLSL nodes declare their contract in the source with `#pragma lamino param|inputs|padding|temporal|hint|version`
lines; `#include` resolves inside the project. Declare `padding` or `hint pointwise`, or the node reads the whole
input and lint warns. Positions come as `p` (width units) and `uv` (0..1); read inputs with texture(srcN, uv).

Paths: every asset path starts with a root alias (`$SHOTS/...`, `$OUT/...`) declared in lamino.jsonc
(`"roots": { "SHOTS": { "windows": ..., "macos": ..., "linux": ... } }`; `lamino schema --config` prints the
template of lamino.jsonc with every key). A path whose alias is not declared for this OS is an error of
`check` (E_PATH_UNKNOWN_ALIAS). Absolute paths and `..` are refused. Frame numbers are written as `####`. Plates and renders are
read-only; outputs go only to a versioned FOLDER (`name_v001/`) under a writable root and never overwrite
an existing frame (re-running a render fills in missing frames only).

Files: the comp file (`*.comp.ts`) is the source of truth and is written only by agents and humans.
Laminolith writes only `.lamino/` (regenerable), `lamino.lock` and `$OUT`. History, provenance and locks
are git's job: commit the comp file and lamino.lock; undo with git. The lock hashes every asset file: a
sequence per frame (`frames: {"1001": …}`), and a single file — a still, a font, a JSON file, and also a
whole video (.mov / .mp4 / .mxf) — as one entry `frames: {"0": …}` with `range: [0, 0]`. That is by design
for videos: the file is the unit of identity; `inspect` reports their own frames as [1, frameCount].

Loop: edit -> save -> `lamino dev` re-evaluates -> read lint, probe and stats numbers -> look at a preview
only when the numbers do not settle it. Always work at the proxy level (default long edge 960 px); render at
full resolution only for delivery. Deterministic output is the EXR sequence. Movies are encoded outside
Laminolith: `render --pipe y4m` (a delivery) and `preview --pipe y4m` (review pictures of a comp or an OTIO
timeline) stream display-referred frames (BT.709 limited 4:4:4, 16-bit, size and rate in the stream) to an
encoder; `contrib/lamino_movie.py` runs ffmpeg on it with the colour labels and the output rules. For a
movie with alpha, `render --pipe pam` streams R'G'B'A with STRAIGHT alpha (the colour is divided by alpha
before the view; light without coverage is not in it) and `lamino_movie.py --alpha` makes ProRes 4444 of it.

Backends (`--backend`, for every command that evaluates: render, preview, probe, compare, bench, stats, dev):
`cpu` runs the CPU reference kernels and never touches a hardware GPU; `shader` nodes, which have no CPU kernel,
run on the software adapter (WARP on Windows, a Vulkan software driver such as lavapipe on Linux) with their
inputs uploaded and the result downloaded, and a machine without one fails such a comp before the first frame
(E_GPU). `gpu-software` runs the GPU kernels on the software adapter: it runs on
the CPU and uses no GPU either. Without `--backend`, `eval.backend` of lamino.jsonc decides (default `auto`).
`auto` takes the hardware GPU, else the CPU reference (faster than the GPU kernels on the software adapter). LAMINO_GPU=software starts at the software adapter (use it, or --backend gpu-software, when the
machine's GPU is shared and you were not given it); LAMINO_GPU=hardware insists on the hardware GPU.
`gpu` takes the hardware GPU whatever LAMINO_GPU says (E_GPU when there is none). The backends agree within
each node's tolerance. `stats` is not a read-only query: when the process has not evaluated the comp yet (a
fresh CLI call always) it evaluates the first frame at the proxy level, on the chosen backend, like `preview`.
`stats`, `bench` and `render --trace` measure and `preview` is looked at: a node over the per-node budget (or a
frame over the per-frame budget) is a warning there (L_COST_BUDGET / L_FRAME_BUDGET) and the measurement or the
picture completes; every other command (render, check's evaluations, the MCP evaluation tools) stops with
E_COST_BUDGET.

Boundary: if a review comment can be answered by changing a parameter, the work belongs in Laminolith
(grade, transform, blur, glow, masks, text, shapes). If it needs a new simulation, render, track or
generated element, make it outside and bring it in with `read` plus provenance (`lamino prov add`).

Errors: every error carries code, what, why, fix and, when it comes from the comp file, file and line.
Nothing is silently corrected; estimates become lint warnings.

Starting a project (`lamino schema --setup` prints this section alone)

Laminolith writes no project file. It prints each starting file on stdout; you save it as UTF-8. In sh,
PowerShell 7 and cmd `>` does that. In Windows PowerShell 5 `>` writes UTF-16, which lamino refuses: use
`| Out-File -Encoding utf8 <file>` there, or write the text with your own file tool.

One project is one git repository named after the project code. In its root:

  lamino schema --config                  > lamino.jsonc        the settings: set "project" and the paths under "roots"
  lamino schema --config-schema           > lamino.schema.json  what "$schema" in lamino.jsonc points at (editors)
  lamino schema --dts                     > lamino.d.ts         types of the `lamino` modules (editors)
  lamino schema --template tsconfig.json  > tsconfig.json       editor setup for the comp files
  lamino schema --template glsl.d.ts      > glsl.d.ts           types `import src from "./x.glsl"`
  lamino schema --template .gitignore     > .gitignore          keeps .lamino/ and out/ out of git
  lamino schema --template CLAUDE.md      > CLAUDE.md           the working rules for the agent: replace <PROJECT>
                                                                in its heading, then read it

For each shot, make the folder shots/<shot>/ first (a redirect does not create it), then:

  lamino schema --template shot.comp.ts   > shots/<shot>/<shot>.comp.ts
                                          change the comp() id, res, fps, frames and the asset paths
  lamino check shots/<shot>/<shot>.comp.ts --json
                                          fix every diagnostic it reports, then work with `lamino dev <file>`

lamino.schema.json and lamino.d.ts are generated: print them again after updating lamino.

Required by lamino:
- lamino.jsonc at the project root. Every command finds the project by walking up from the comp file or the
  current directory (E_CONFIG_NOT_FOUND).
- Assets are read through the root aliases of lamino.jsonc ($SHOTS/...). Absolute paths and `..` are refused.
- A comp file imports, and a shader includes, only from its own folder and the folders of `lib.roots`.
- Renders go only into a versioned folder under $OUT ($OUT/<name>_v001/).
- git is needed by `render --job` (it renders a pinned commit) and by `git:<rev>` targets (`compare`,
  `preview --compare-with`); nothing else checks for a repository.

Conventions (not enforced, but CLAUDE.md, tsconfig.json and .gitignore are written for them):
- shots/<shot>/<shot>.comp.ts, one folder per shot. lamino writes .lamino/ next to the comp file and
  lamino.lock in the root.
- lib/ holds the project's own effects and common/ the shared ones (a git submodule: effects, fonts, LUTs,
  the OCIO config). Both are in `lib.roots` of the template.
- edit/<name>.otio holds timelines; data/ holds tables and text read by json() / table() / readText().

Commit lamino.jsonc, lamino.schema.json, lamino.d.ts, lamino.lock, tsconfig.json, glsl.d.ts, .gitignore,
CLAUDE.md and the comp files. Do not commit .lamino/ or out/.
```

## Types and functions

The declarations of each module without the node and preset functions and their option types, which are in the node chapters.

### `lamino`

```ts
/** Canonical spellings only; `"inOut"` / `"in-out"` are E_IR_PARAM_INVALID (use `ease.inOut`, which is `"inout"`). */
export type Ease = "linear" | "in" | "out" | "inout";
/** How whole frames are picked for a fractional time (`retime`'s `sample`, withTime()'s `sample`). */
export type RetimeSample = "floor" | "nearest" | "blend";
export type Key<T> = [number, T] | [number, T, Ease];
export interface Animated<T = number> { keys: Key<T>[]; interp?: "linear" | "hold" }
/** Opaque marker returned by t(); baked into hold keys when the IR is written. */
export interface TimeFn<T = number> { readonly __timeFn: T }
export type Anim<T> = T | Animated<T> | TimeFn<T>;
export type Vec2 = [number, number];
export type Vec3 = [number, number, number];
export type Vec4 = [number, number, number, number];
/** [r,g,b,a], [r,g,b] (alpha = the parameter's identity), a scalar broadcast to rgb, or "#rrggbb(aa)" sRGB. */
export type Color = number | Vec3 | Vec4 | string;
export interface CompSettings {
  /** [num, den] or a number (23.976 → [24000, 1001]). */
  fps: [number, number] | number;
  /** [width, height] in pixels. */
  res: [number, number];
  /** Pixel aspect ratio (default 1). */
  par?: number;
  /** Inclusive frame range: the default render range and the sampling range of t(). Without it t() samples the union of the read sequences' ranges (L_ESTIMATED). */
  frames?: [number, number];
  workingColorspace?: string;
}
/** A comp file's default export: callable as a precomp from another comp. */
export interface Precomp<P = Record<string, unknown>> { (params?: P): Node }
export function comp<P = Record<string, unknown>>(id: string, settings: CompSettings, build: (params: P) => Node): Precomp<P>;
/** A time map of withTime(): the source time shown at each output frame. Constant speed: `time(f) = origin + offset + (f - origin) * speed` (`speed` 0.5 = half speed, -1 = backwards about `origin`; a number is read as the decimal it prints as, `[num, den]` is an exact ratio; `origin` defaults to the comp's first frame; `offset` has the sign of `timeOffset`'s `frames`). Or `time`: any mapping output frame → source time, as keys(), t(), a function or a constant — the meaning of `retime`'s `time`. `sample` is how nodes that only exist on whole frames are retimed (default `"blend"`). */
export type TimeMap =
  | { speed?: number | [number, number]; origin?: number; offset?: number; sample?: RetimeSample }
  | { time: number | Animated<number> | TimeFn<number> | ((frame: number) => number); sample?: RetimeSample };
/** Build a sub-graph in mapped time: everything `build` creates plays as `time(frame)` says. Keyframes (`keys()`, `.animate()`, `{ keys }` literals, `perGlyph` channels) get their key times moved — exactly, onto fractional frames, for a constant speed or offset; resampled per output frame for any other map — and `t(f => …)` callbacks receive the mapped, fractional source time, so keyframed text, shapes and precomps are retimed smoothly. Nodes that only exist on whole frames (`read` / `aov` / `cryptomatte` / `lottie` / `camera` and what they drive, the time nodes, and whatever feeds them) keep their own frames and are retimed through a `retime` node with the same map (`timeOffset` for a whole-frame offset); Info `L_TIME_FRAME_SAMPLED` names them. Scopes nest (the maps compose) and a precomp called inside is retimed as a whole. Noise seeded per frame (`grain`, `glitch`) and a shader's `frame` / `time` stay on the output frame. Returns the node `build` returned, or the `retime` over it. */
export function withTime(map: TimeMap, build: () => Node): Node;
/** `at(frame)`: the row's value; between two rows (a fractional frame, as inside withTime()) the linear interpolation of the two, `undefined` when a row is missing. */
export interface ValuesTable { at(frame: number): number | undefined; has(frame: number): boolean; frames(): number[] }
/** Per-frame scalar table (CSV / JSON) read by the host. */
export function values(path: string, opts?: { column?: string }): ValuesTable;
/** The JSON document at `path`, an alias path (`"$ALIAS/..."`, a root of lamino.jsonc), read on the host when the script runs: data is material, not code, so `import "./x.json"` is refused. The file is a lock asset and `lamino dev` watches it. UTF-8 only (a BOM is allowed). Parsed by `JSON.parse` (property order is JavaScript's: integer-like keys first, then insertion order); each call returns a fresh value. */
export function json<T = unknown>(path: string): T;
/** The records of the CSV at `path` (TSV for `.tsv`), an alias path: one object per record, keyed by the header names as written (an empty or repeated header name, or a record of another length, is E_DATA_TABLE). Every cell is a **string** exactly as written (no trimming, `"0010"` stays `"0010"`): convert explicitly, e.g. `Number(row.frame)`. An empty or header-only file is `[]`. A lock asset like `json()`; UTF-8 only. */
export function table(path: string): Record<string, string>[];
/** The text of the file at `path`, an alias path (UTF-8; a leading BOM removed, line endings as written). A lock asset like `json()`. */
export function readText(path: string): string;
export function keys<T = number>(keys: Key<T>[], opts?: { interp?: "linear" | "hold" }): Animated<T>;
export const ease: { readonly in: "in"; readonly out: "out"; readonly inOut: "inout"; readonly linear: "linear" };
/** Sample over the comp's frames (or the read sequences' range) and bake into hold keys. The callback returns numbers (or an array of them); for an animatable string (the string of `text`) it returns the string of each frame: `text(t((f) => String(f)), …)`. */
export function t<T extends number | number[] | PathVertex[] | string>(fn: (frame: number) => T): TimeFn<T>;
export function bake<N extends Node>(node: N, name: string): N;
/** Deterministic PRNG in [0, 1). */
export function random(seed: number): () => number;
/** Seeded smooth noise over time, like After Effects' wiggle(): `freq` wiggles per second, values within ±`amp` (a number, or one per dimension) around 0, so it is an offset: `translate: wiggle(2, 0.01, { dims: 2 })` shakes a layer about its place. `octaves` adds finer detail. A t()-like value, sampled over the comp's frames; the same seed gives the same motion. */
export function wiggle<T extends number | number[] = number>(freq: number, amp: number | number[], opts?: { seed?: number; octaves?: number; dims?: number }): TimeFn<T>;
/** Repeat keys beyond their first and last frame (After Effects' loopOut() / loopIn() in one): `cycle` repeats, `pingpong` runs back and forth, `offset` repeats and adds the difference between the last and the first value each time, `continue` carries on at the speed of the ends. A t()-like value. */
export function loop<T = number>(keys: Animated<T>, opts?: { mode?: "cycle" | "pingpong" | "offset" | "continue" }): TimeFn<T>;
/** Frame delays for a row of layers: element i of `items` (an array, or a count) gets `each`·(its distance from `from`) frames. `from`: "first" (default), "last", "center" or an index. Use the delay in the layer's key times: `keys([[start + d, 0], [start + d + 12, 1]])`. */
export function stagger(items: number | unknown[], opts?: { each?: number; from?: "first" | "last" | "center" | number }): number[];
/** After Effects' linear() / ease(): x from a..b mapped to y0..y1 and held outside (numbers or arrays of one length); `ease` shapes the way (the eases of keys()). Plain arithmetic for use inside t(). */
export function remap<T extends number | number[]>(x: number, a: number, b: number, y0: T, y1: T, ease?: Ease): T;
/** Keys with their times scaled by `factor` about `origin` (default: the first key): 2 plays them twice as slowly. A smooth retime of anything keyed. */
export function stretch<T = number>(keys: Animated<T>, factor: number, opts?: { origin?: number }): Animated<T>;
/** A named 3D point of a camera file: per frame its world position in metres. `project()` takes it in place of a constant `[x, y, z]`. A point with one frame is static (every frame). */
export interface PointRef { readonly name: string; at(frame: number): Vec3 | undefined }
/** A `camera()` node: a planning-time value, not an image. Accepted by `camera` options and by `project()`. */
export class CameraNode extends Node {
  private readonly __camera: true;
  /** A named point of this camera's `lamino-camera-v1` file (`points`), read on the host with this node's `metersPerUnit` / `frameOffset`. An unknown name is an error naming the nearest ones. */
  point(name: string): PointRef;
}
/** `lamino_core::shape::Transform` of a group: `T(position) · R(rotation) · K(skew, skewAxis) · S(scale) · T(−anchor)`; width units, degrees clockwise, opacity 0..1. Every field may be animated (`keys()`, `t()`), each group on its own: one `shape` node can hold many separately moving groups. */
export interface ShapeTransform { anchor?: Anim<Vec2>; position?: Anim<Vec2>; scale?: Anim<Vec2 | number>; rotation?: Anim<number>; skew?: Anim<number>; skewAxis?: Anim<number>; opacity?: Anim<number> }
/** Style of a builder's group. `fill` omitted = white, `null` = none; a stroke is added only when `stroke` is given (`strokeWidth` default 0.002). Colours: scene-linear [r, g, b(, a)] or "#rgb" / "#rrggbb(aa)" sRGB. */
export interface ShapeStyle { fill?: Color | null; stroke?: Color | null; strokeWidth?: number; transform?: ShapeTransform }
/** One `lamino_core::shape::Item` (tagged by `type`; see that module for every field). The builders return `group` items. */
export interface ShapeItem { type: "group" | "path" | "rect" | "ellipse" | "polygon" | "mask" | "fill" | "stroke" | "trim" | "repeater"; [field: string]: unknown }
/** A path vertex in width units: `[x, y]` (a corner), `[x, y, inX, inY, outX, outY]` (Bézier tangents relative to the vertex, After Effects' `vertices` / `inTangents` / `outTangents`), or the model's object; a plain `number[]` (an exporter's `number[][]`) is accepted and must hold 2 or 6 numbers. */
export type PathVertex = Vec2 | [number, number, number, number, number, number] | number[] | { point: Vec2; inTangent?: Vec2; outTangent?: Vec2 };
/** A path's points: a static list, `keys()` of lists (whole-path keys, AE's model: linear keys need the same vertex count, E_IR_PARAM_INVALID otherwise; `interp: "hold"` may change it) or `t(f => list)` sampled per frame. */
export type PathPoints = PathVertex[] | Animated<PathVertex[]> | TimeFn<PathVertex[]>;
/** How a mask combines with the masks before it (AE): add = min(1, a + m), subtract = max(0, a − m), intersect = a·m, difference = |a − m|, lighten = max, darken = min, none = ignored. The stack starts opaque when its first mask subtracts, intersects or darkens. */
export type MaskMode = "add" | "subtract" | "intersect" | "difference" | "lighten" | "darken" | "none";
/** Attributes of a roto mask. `feather`: total width of the soft edge, centred on the (expanded) outline (width units, ≥ 0); `expansion`: moves the outline out (> 0, corners grow round) or in (< 0), width units; `opacity` 0..1; `falloff` of the feather: smooth (smoothstep, default) or linear. Feather and expansion are measured on the output picture. */
export interface MaskOptions { mode?: MaskMode; inverted?: boolean; opacity?: Anim<number>; feather?: Anim<number>; expansion?: Anim<number>; falloff?: "smooth" | "linear" }
/** The shape model (`lamino_core::shape::Shape`): items drawn bottom to top, in comp width units (origin top-left). */
export interface ShapeModel { items: ShapeItem[] }
/** What `shape()` accepts: a model, one item or an array of items (wrapped into a model). */
export type ShapeInput = ShapeModel | ShapeItem | ShapeItem[];
/** A blend function of `merge`: what `blend()` takes as its mode. */
export type BlendMode = "screen" | "add" | "subtract" | "multiply" | "difference" | "max" | "min" | "from" | "divide" | "exclusion" | "overlay" | "softLight" | "hardLight" | "colorDodge" | "colorBurn" | "linearBurn" | "linearLight" | "vividLight" | "pinLight" | "hardMix" | "hue" | "saturation" | "color" | "luminosity" | "darkerColor" | "lighterColor";
/** merge({ op: "over" }): A over/… B. */
export function over(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "under" }): A over/… B. */
export function under(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "screen" }): A over/… B. */
export function screen(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "add" }): A over/… B. */
export function add(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "subtract" }): A over/… B. */
export function subtract(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "multiply" }): A over/… B. */
export function multiply(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "difference" }): A over/… B. */
export function difference(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "max" }): A over/… B. */
export function max(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "min" }): A over/… B. */
export function min(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "in" }): A over/… B. */
export function inside(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "out" }): A over/… B. */
export function outside(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "mask" }): A over/… B. */
export function mask(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "stencil" }): A over/… B. */
export function stencil(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** merge({ op: "xor" }): A over/… B. */
export function xor(a: Node, b: Node, opts?: Omit<MergeOptions, "op">): Node;
/** A layer blend mode (After Effects / W3C compositing): merge({ op: mode, composite: "layer" }). A is the layer, B the backdrop. */
export function blend(a: Node, b: Node, mode: BlendMode, opts?: Omit<MergeOptions, "op" | "composite">): Node;
/** Builders of the shape model (`lamino_core::shape`). Sizes and positions are width units, centred on the model origin. */
export namespace shape {
  /** Rectangle `width × height` centred on the group origin; `roundness` is the corner radius (width units). */
  function rect(width: number, height: number, opts?: ShapeStyle & { roundness?: number }): ShapeItem;
  /** Ellipse inscribed in `width × height` (height defaults to width), centred on the group origin. */
  function ellipse(width: number, height?: number, opts?: ShapeStyle): ShapeItem;
  /** Regular polygon (`points` ≥ 3) of outer `radius`, first vertex up; `innerRadius` makes a star; `rotation` in degrees; `roundness` 0..1. */
  function polygon(points: number, radius: number, opts?: ShapeStyle & { innerRadius?: number; rotation?: number; roundness?: number }): ShapeItem;
  /** SVG path data (`M L H V C S Q T Z`, absolute or relative; no arcs) in width units; one `path` item per subpath. */
  function path(d: string, opts?: ShapeStyle): ShapeItem;
  /** A Bézier path through `points` (absolute width units, not centred), static or animated (`keys()` of whole paths, `t()`); closed unless `closed: false`. */
  function path(points: PathPoints, opts?: ShapeStyle & { closed?: boolean }): ShapeItem;
  /** A roto mask (always closed) through `points` (absolute width units), static or animated; paint masks with `shape.roto()`. */
  function mask(points: PathPoints, opts?: MaskOptions): ShapeItem;
  /** A matte: the masks (and plain geometry items, as `add` masks) combined in order with their modes, filled with `color` (default opaque white). Use the node's `window` to draw outside the display (overscan, a larger plate). */
  function roto(masks: ShapeItem[], opts?: { color?: Color; transform?: ShapeTransform }): ShapeItem;
}
/** One card of `stack3d`: a layer image and its `card3d` placement; `camera` defaults to the stack's. */
export interface Card3dSpec extends Omit<Card3dOptions, "camera" | "id"> { layer: Node; camera?: CameraNode | string }
export class Node {
  private constructor();
  /** Explicit node id (wins over the variable name). */
  id(name: string): this;
  bake(name: string): this;
  /** Set an animated parameter after construction: `keys` as for keys() (an `ease` given here applies to every key without one). */
  animate<T = number | number[]>(param: string, keys: Key<T>[] | Animated<T>, ease?: Ease): this;
  /** Move the display centre to (x, y) in width units (a transform). */
  at(x: Anim<number>, y: Anim<number>): Node;
  /** grade({ multiply: [v, v, v, v], unpremult: false }). */
  opacity(v: Anim<number>): Node;
  /** Keep this effect only where `mask` is (an adjustment layer with a mask): merge({ op: "copy", mask, mix }) of this node over the picture it was made from — its first image input, the backdrop of a merge, or the picture a preset was applied to. Outside the mask, and by 1 − `mix`, that picture shows. */
  masked(mask: Node, mix?: Anim<number>): Node;
  /** merge({ op: "over" }) with this node as B (background). */
  over(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "under" }) with this node as B (background). */
  under(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "screen" }) with this node as B (background). */
  screen(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "add" }) with this node as B (background). */
  add(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "subtract" }) with this node as B (background). */
  subtract(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "multiply" }) with this node as B (background). */
  multiply(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "difference" }) with this node as B (background). */
  difference(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "max" }) with this node as B (background). */
  max(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "min" }) with this node as B (background). */
  min(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "mask" }) with this node as B (background). */
  mask(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "stencil" }) with this node as B (background). */
  stencil(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  /** merge({ op: "xor" }) with this node as B (background). */
  xor(fg: Node, opts?: Omit<MergeOptions, "op">): Node;
  merge(fg: Node, opts?: MergeOptions): Node;
  /** A layer blend mode (After Effects / W3C compositing): merge({ op: mode, composite: "layer" }) with this node as the backdrop: `plate.blend(texture, "overlay", { mix: 0.6 })`. */
  blend(fg: Node, mode: BlendMode, opts?: Omit<MergeOptions, "op" | "composite">): Node;
  /** Lift / gain / gamma / offset colour correction (Nuke-style). */
  grade(opts?: GradeOptions): Node;
  /** Clamp each channel to [min, max]. */
  clamp(opts?: ClampOptions): Node;
  /** Convert between colourspaces of the color config (OCIO). */
  colorspace(opts: ColorspaceOptions): Node;
  /** Apply the view transform of a display / view pair of the color config, or its inverse (OCIO DisplayViewTransform). */
  displayView(opts: DisplayViewOptions): Node;
  /** Apply a 1D or 3D LUT file (.cube, .spi1d, .spi3d) to RGB. */
  lut(opts: LutOptions): Node;
  /** Translate / rotate / scale in width units. */
  transform(opts?: TransformOptions): Node;
  /** Crop the data window to a box (the display window is unchanged). */
  crop(opts?: CropOptions): Node;
  /** Gaussian, box or disc blur; `size` is the sigma in width units. */
  blur(size: number): Node;
  blur(opts?: BlurOptions): Node;
  /** Morphological erode (positive size) or dilate (negative) of alpha or all channels. */
  erode(size: number): Node;
  erode(opts?: ErodeOptions): Node;
  /** Multiply RGB by alpha. */
  premult(opts?: PremultOptions): Node;
  /** Divide RGB by alpha where alpha > 0. */
  unpremult(opts?: UnpremultOptions): Node;
  /** Rearrange channels; sources may come from a second input. */
  shuffle(opts?: ShuffleOptions): Node;
  shuffle(B?: Node, opts?: ShuffleOptions): Node;
  /** Reduce an image (optionally masked, optionally within a region) to one statistic held in a 1×1 image. */
  measure(opts?: MeasureOptions): Node;
  measure(mask?: Node, opts?: MeasureOptions): Node;
  shader(opts: ShaderOptions, ...inputs: Node[]): Node;
  /** Film grain: seeded, luminance-weighted noise added in straight RGB. */
  grain(size: number): Node;
  grain(opts?: GrainOptions): Node;
  /** Darken (or lighten) towards the edges with a soft elliptical falloff. */
  vignette(opts?: VignetteOptions): Node;
  /** Offset red, green and blue separately: channel shift and lateral chromatic aberration. */
  rgbSplit(opts?: RgbSplitOptions): Node;
  /** Shift each pixel by an amount read from a map image (displacement map). */
  displace(map: Node, opts?: DisplaceOptions): Node;
  /** Blur along a direction (motion streak), two-sided or as a one-sided trail. */
  directionalBlur(opts?: DirectionalBlurOptions): Node;
  /** Zoom or spin blur about a centre. */
  radialBlur(opts?: RadialBlurOptions): Node;
  /** Spread straight colour outward from the alpha edge (fills transparent pixels with the nearest colour). */
  edgeExtend(size: number): Node;
  edgeExtend(opts?: EdgeExtendOptions): Node;
  /** Digital glitch: seeded horizontal block displacement and channel split. */
  glitch(opts?: GlitchOptions): Node;
  /** Colour-difference keyer (IBK style) for green / blue screens: pulls a matte and removes the screen colour. */
  screenKey(opts: ScreenKeyOptions): Node;
  screenKey(cleanPlate: Node, opts: ScreenKeyOptions): Node;
  /** 4×4 colour matrix plus offset (channel mixer, black and white, sepia, luma to alpha). */
  colorMatrix(opts?: ColorMatrixOptions): Node;
  /** Tone curves through control points: one master curve and one per channel. */
  curves(opts?: CurvesOptions): Node;
  /** Rotate the hue, scale the saturation and the lightness, optionally for one hue range only. */
  hueSat(opts?: HueSatOptions): Node;
  /** Saturation, contrast, gamma, gain and offset for the whole picture and per tonal range (shadows / midtones / highlights). */
  colorCorrect(opts?: ColorCorrectOptions): Node;
  /** Map a channel (or the luma) through a colour gradient: tint, tritone, false colour, colour cycling. */
  gradientMap(opts?: GradientMapOptions): Node;
  /** Reduce each colour channel to a number of levels. */
  posterize(opts?: PosterizeOptions): Node;
  /** Reveal or hide a picture with a moving edge: linear, radial (clock) or blinds. */
  wipe(opts?: WipeOptions): Node;
  /** Combine two mattes (or prepare one): union, intersect, subtract, …, from alpha or luma, inverted or not. */
  matteOp(opts?: MatteOpOptions): Node;
  matteOp(B?: Node, opts?: MatteOpOptions): Node;
  /** Edge strength (Sobel) of the colour, the alpha or the luma. */
  edgeDetect(opts?: EdgeDetectOptions): Node;
  /** Long cast shadow of a picture's alpha towards a directional or point light, with opacity, softness and colour changing along its length (the kernel of `castShadow`). */
  shadowRay(opts?: ShadowRayOptions): Node;
  shadowRay(soft1?: Node, soft2?: Node, soft3?: Node, opts?: ShadowRayOptions): Node;
  /** Multi-scale glow with a power-law falloff: a bright core and a long soft tail. */
  glow(opts?: GlowOptions): Node;
  /** Lens blur (bokeh): every point becomes the shape of the iris, with blades, cat's eye, rim and highlight boost. */
  lensBlur(opts?: LensBlurOptions): Node;
  lensBlur(map?: Node, opts?: LensBlurOptions): Node;
  /** Pixelate: the picture in blocks of one colour each. */
  mosaic(opts?: MosaicOptions): Node;
  /** Displace the picture along a travelling wave: sine, triangle, square, sawtooth or smooth noise. */
  waveWarp(opts?: WaveWarpOptions): Node;
  /** Radial lens distortion from two coefficients: add it to a CG element or remove it from a plate (when there is no ST map). */
  lensDistort(opts?: LensDistortOptions): Node;
  /** Twirl, bulge or polar-coordinate warp about a centre. */
  warp(opts?: WarpOptions): Node;
  /** Pin the four corners of the frame to four points (perspective / projective transform). */
  cornerPin(opts?: CornerPinOptions): Node;
  /** Remove green/blue screen spill from straight RGB. */
  despill(opts?: DespillOptions): Node;
  /** Vector motion blur from a motion AOV. */
  motionBlur(motion: DataNode, opts?: MotionBlurOptions): Node;
  /** Depth fog: blend towards a colour by distance. */
  fog(depth: DataNode, opts?: FogOptions): Node;
  /** Resample the input through a UV / ST map (lens undistort/redistort, texture mapping). */
  uvMap(uv: DataNode, opts?: UvMapOptions): Node;
  /** Weighted average of the frames around the current one (frame averaging / motion smear). */
  frameBlend(opts?: FrameBlendOptions): Node;
  /** Trails: decayed copies of the previous frames composited under the current one. */
  echo(opts?: EchoOptions): Node;
  /** Per-channel median over the surrounding frames (flicker and dropout removal). */
  temporalMedian(opts?: TemporalMedianOptions): Node;
  /** Shift the input in time: out(frame) = in(frame + frames). */
  timeOffset(opts?: TimeOffsetOptions): Node;
  /** Freeze one frame: every output frame shows the input at `frame`. */
  frameHold(opts?: FrameHoldOptions): Node;
  /** Time remap: out(frame) = in(time(frame)), time keyframed or computed. */
  retime(opts: RetimeOptions): Node;
  /** Place an image on a card in 3D and render it through a camera (image + depth). */
  card3d(opts: Card3dOptions): Card3dNode;
  /** Composite two images by per-pixel depth: the nearer pixel goes over the farther one. */
  zMerge(aDepth: DataNode, b: Node, bDepth: DataNode, opts?: ZMergeOptions): ZMergeNode;
  lightWrap(bg: Node, opts?: import("lamino/fx").LightWrapOptions): Node;
  edgeBlur(opts?: import("lamino/fx").EdgeBlurOptions): Node;
  flash(opts?: import("lamino/fx").FlashOptions): Node;
  withAlpha(matte: Node, opts?: import("lamino/fx").WithAlphaOptions): Node;
  undistort(st: DataNode, opts?: import("lamino/fx").UndistortOptions): Node;
  redistort(stInverse: DataNode, opts?: import("lamino/fx").RedistortOptions): Node;
  starGlow(opts?: import("lamino/fx").StarGlowOptions): Node;
  turbulentDisplace(opts?: import("lamino/fx").TurbulentDisplaceOptions): Node;
  levels(opts?: import("lamino/fx").LevelsOptions): Node;
  exposure(opts?: import("lamino/fx").ExposureOptions): Node;
  tint(opts?: import("lamino/fx").TintOptions): Node;
  tritone(opts?: import("lamino/fx").TritoneOptions): Node;
  monochrome(opts?: import("lamino/fx").MonochromeOptions): Node;
  fill(opts?: import("lamino/fx").FillOptions): Node;
  dropShadow(opts?: import("lamino/fx").DropShadowOptions): Node;
  castShadow(opts?: import("lamino/fx").CastShadowOptions): Node;
  outline(opts?: import("lamino/fx").OutlineOptions): Node;
  unsharp(opts?: import("lamino/fx").UnsharpOptions): Node;
  posterizeTime(opts?: import("lamino/fx").PosterizeTimeOptions): Node;
  tile(opts?: import("lamino/fx").TileOptions): Node;
  mirror(opts?: import("lamino/fx").MirrorOptions): Node;
  offset(opts?: import("lamino/fx").OffsetOptions): Node;
  roughenEdges(opts?: import("lamino/fx").RoughenEdgesOptions): Node;
  matte(matte: Node, opts?: import("lamino/fx").MatteOptions): Node;
}
/** Output of `aov` and the `depth` outputs of the 3D nodes: normalised per-pixel data, connects to the data ports (fog, motionBlur, uvMap, zMerge). */
export class DataNode extends Node { private readonly __data: true; }
/** A channel of a glyph in `perGlyph`: `x` / `y` offset the cluster (width units, in the text's own coordinates), `rotation` (degrees, clockwise) and `scaleX` / `scaleY` pivot on the baseline at the centre of its advance, `opacity` is 0..1; `scale` sets both scales. */
export type GlyphParam = "x" | "y" | "rotation" | "scale" | "scaleX" | "scaleY" | "opacity";
/** One grapheme cluster of a text node, inside `perGlyph`. Clusters are counted in text order: spaces count, line breaks do not; a ligature is drawn by its first cluster. */
export interface Glyph {
  /** Index of the cluster (the callback's second argument). */
  readonly index: number;
  /** Number of clusters of the text. */
  readonly count: number;
  /** The cluster's text (e.g. to skip spaces). */
  readonly text: string;
  /** Set a channel to a number, keys() or t(). */
  set(param: GlyphParam, value: Anim<number>): this;
  /** Animate a channel: `keys` as for keys() (an `ease` given here applies to every key without one). */
  animate(param: GlyphParam, keys: Key<number>[] | Animated<number>, ease?: Ease): this;
}
/** A `text` node. */
export class TextNode extends Node {
  private readonly __text: true;
  /** Per-character animation: `fn` is called once per grapheme cluster with a handle and the index, and fills the node's `perGlyph` list. The host lays the string out with its fonts to count the clusters (the fonts go into the lock). Each cluster is rasterised once; its motion and opacity are applied when it is painted. Call it on the text node, or on the node `.at()` returned for it. */
  perGlyph(fn: (glyph: Glyph, index: number) => void): this;
  /** Move the display centre to (x, y) in width units. Returns the placing `transform` node; `.perGlyph()` on that node is forwarded to this text node while the placement is the text's only consumer, so `text(…).at(x, y).perGlyph(fn)` gives the same IR as `text(…).perGlyph(fn).at(x, y)`. */
  at(x: Anim<number>, y: Anim<number>): this;
}
/** A `card3d` node: its image plus the named outputs below (`"<id>:<name>"` in the IR). */
export class Card3dNode extends Node {
  private readonly __card3d: true;
  /** camera-plane distance in metres in R (+inf where nothing is drawn), A = 1 where drawn */
  readonly depth: DataNode;
}
/** A `stack3d` node: its image plus the named outputs below (`"<id>:<name>"` in the IR). */
export class Stack3dNode extends Node {
  private readonly __stack3d: true;
  /** camera-plane distance in metres in R (+inf where nothing is drawn), A = 1 where drawn */
  readonly depth: DataNode;
}
/** A `zMerge` node: its image plus the named outputs below (`"<id>:<name>"` in the IR). */
export class ZMergeNode extends Node {
  private readonly __zMerge: true;
  /** camera-plane distance in metres in R (+inf where nothing is drawn), A = 1 where drawn */
  readonly depth: DataNode;
}
```

### `lamino/fx`

```ts
import { Node, DataNode, Anim, Vec2, Vec3, Vec4, Color } from "lamino";
export { fractalNoise, curlNoise, lensFlare, grain, vignette, rgbSplit, displace, directionalBlur, radialBlur, edgeExtend, glitch, screenKey, colorMatrix, curves, hueSat, colorCorrect, gradientMap, posterize, wipe, matteOp, edgeDetect, shadowRay, glow, lensBlur, mosaic, waveWarp, lensDistort, warp, cornerPin } from "lamino";
```

### `lamino/aov`

```ts
import { DataNode, AovOptions } from "lamino";
export { despill, motionBlur, fog, uvMap } from "lamino";
```

### `lamino-text`

```ts
export { text, shape, lottie } from "lamino";
export type { TextOptions, TextNode, ShapeOptions, LottieOptions, Glyph, GlyphParam, ShapeItem, ShapeModel, ShapeInput, ShapeStyle, ShapeTransform, PathVertex, PathPoints, MaskMode, MaskOptions } from "lamino";
```

### `lamino-3d`

```ts
import { Anim, CameraNode, PointRef, Vec3 } from "lamino";
export { camera, card3d, stack3d, zMerge } from "lamino";
export type { CameraOptions, Card3dOptions, Card3dNode, Stack3dOptions, Stack3dNode, ZMergeOptions, ZMergeNode, CameraNode, Card3dSpec, PointRef } from "lamino";
/** Result of project(): per frame the point's position in width units (x 0..1, y 0..H/W, origin top-left) and its camera-plane depth in metres. `at(f)` is `undefined` behind the camera, for a frame the camera or the point lacks, or while the host has no camera loader: `t(f => p.at(f)?.x ?? 0.5)`. `x` / `y` / `depth` are the same values as animated parameters — `img.at(p.x, p.y)` — sampled over the comp's frames like t() (plain numbers when the camera and the point are both static); they are errors on a frame without a value. Between two frames (a fractional frame, as inside withTime()) the value is the linear interpolation of the two frames' values, and there is none when either is missing. */
export interface Projected { at(frame: number): { x: number; y: number; depth: number } | undefined; readonly x: Anim<number>; readonly y: Anim<number>; readonly depth: Anim<number> }
/** Project a world point (metres) through a camera for every frame, on the host (like values()): `project(nulls.point("launch_01"), cam)`. `point` is `[x, y, z]` or `camera(file).point(name)`; `camera` is a `camera()` node, an alias path of a camera file or a camera spec object. A one-frame camera file is a static camera (lint L_CAMERA_STATIC). */
export function project(point: Vec3 | PointRef, camera: CameraNode | string | Record<string, unknown>): Projected;
```
