Skip to main content

Module expr

Module expr 

Source
Expand description

The expression language (docs/compositing.md#expressions): ffmpeg’s function names and semantics over f64, plus easing, lerp, smoothstep, and stateless random and noise.

A source string is tokenised, parsed by precedence climbing into an AST, resolved against a Scope (names to variable slots), constant-folded and flattened to stack ops. Evaluating the ops is a pure function of the Frame: no state, no loops, so it always terminates.

Structs§

Compiled
A compiled expression: evaluates in about a hundred nanoseconds.
ExprError
A compile error: what is wrong and where (1-based column, in characters).

Constants§

MAX_ARGS
Most arguments a call takes (min, max).
MAX_DEPTH
Deepest accepted nesting (parentheses, calls, unary operators, the right side of ^, and each operator of a chain like a + b + c, which nests to the left).
MAX_LEN
Longest accepted source, bytes.

Functions§

is_builtin_name
Names an expression can’t use for anything else (vars may not shadow them).
noise
noise(seed, x): value noise in [-1, 1], smooth in x (lattice values at integers, eased with the quintic fade between them).
random
random(seed) on frame n: uniform in [0, 1), the same on every render.