Skip to content

Expressions

Last updated

An expression is a line of script on a property, calculated every frame.

  1. Right-click the property’s value field.
  2. Choose Set expression.

The field becomes a small code editor, seeded with the value that was there, and the number beside it shows what the expression comes to at the playhead. Type as you would in any editor: the function names complete as you go.

Right-click the editor and choose Remove expression to go back to a plain value — the property keeps the number it was showing.

Transform properties and effect parameters both take one. Anything made of several numbers — a point, a colour — does not yet, and the menu simply does not offer it there.

The language is Rhai. time is the composition’s time in seconds; layer().time is the layer’s own clock, counted from its in point.

Constantstime, comp_width, comp_height, comp_fps, num_layers, num_markers, cut_in, cut_out
Mathssin, cos, sinh, cosh, floor, ceil, round, abs, clamp, noise, smoothstep, fit, fit_clamped, fit01
The compositioncomp().name
A layerlayer() for this one, layer("Name") for another — .name, .time, .x, .y, .rotation, .scale_x, .scale_y, .anchor_x, .anchor_y, .opacity

A few to start from:

time * 90 // a turn of ninety degrees a second
layer("Sun").x + 20 // twenty pixels behind another layer
noise(time * 2) * 50 // a smooth wander, the same on every run
fit(layer().time, 0, 2, 0, 100) // nought to a hundred over two seconds
  • An expression that fails reads as −1. Nothing is reported yet, so a property sitting at −1 is worth a second look at the script.

  • One property reading another that reads it back stops after a hundred cycles rather than at the first.

An expression draws as a curve like anything else, sampled across the view. It has no keyframes to take hold of — to change the shape, change the script.