Reference / Effects / Drivers
Updated
Expression
Expression is a Drivers effect.
What it does
Section titled “What it does”Type an expression and the box hands out its answer on a wire, so a parameter can follow a
line of arithmetic instead of its keyframes. It is written in JavaScript or Rhai, picked in
the dropdown under Edit expression…, with the names a property’s own expression has in
that language. A box with no text starts in the language new expressions are written in.
In Rhai: time * 2, sin(time) * 50, [comp_width / 2, comp_height / 2], [1, 0.5, 0].
The box can take numbers in as well. Add input gives it a number input named
input_1, then input_2, and so on. Each input is a socket on the box and a row in the
Node panel, and the expression reads it by that name: (input_1 + input_2) * input_3.
A wired input carries what its wire carries. An unwired one holds the value on its row,
which keyframes like any other number. Remove input takes the last input away, and
its wire with it.
The box always has four output sockets - Value, Colour, Point x and Point y -
and what the expression returns decides which of them carry anything on a given frame.
A number fills Value. A pair, [x, y], fills Point x and Point y. Three or four numbers,
[r, g, b] or [r, g, b, a], fill Colour. The other sockets carry nothing, and a
parameter wired to one of them reads its own keyframes for that frame.
An expression that cannot run - a typing mistake, a name that is not in scope, a division by nought, a result that is none of the three shapes - carries nothing at all, so whatever it drives keeps its keyframes rather than jumping to a number that only looks like an answer. The editor shows the sentence about why.
The answer depends on the text and on the frame - the comp, the layer and the time - and on nothing else, so the preview and the export agree exactly.
Parameters
Section titled “Parameters”| Parameter | Control | Range | Default | Unit |
|---|---|---|---|---|
| Edit expression… | Button | - | - | - |
| Add input | Button | - | - | - |
| Remove input | Button | - | - | - |
What each control does
Section titled “What each control does”- Edit expression…: opens the editor for the text the box runs. The text itself is not a parameter - it has no keyframes and nothing to wire into.
- Add input: adds a number input. Inputs are named
input_1,input_2and so on, in the order they are added. - Remove input: removes the last input and unplugs its wire. An expression that still reads that name stops running until the name is taken out of it.
- input_1, input_2 and so on: one row per input, holding the number the expression reads when nothing is wired to that input.
Related
Section titled “Related”- Math - the arithmetic you can see, for one operation on two numbers.
- Split - a colour taken apart into four numbers, the same four-socket shape.
- Expressions - the language, and the names it knows.
- The node graph - where a driver is added and wired.
- Drivers
- Effects