From After Effects¶
After Effects expressions are JavaScript, including older ExtendScript. Shrimply uses Rhai. Pasting an After Effects expression will not work.
value is the property before the expression. time is seconds. t
and local_t are the same as time. The last value in the script is
the result. See Expression basics for the full list.
Continuous motion¶
This rotates by 40 degrees per second:
time * 40
time * 40 // or t * 40
Variables¶
Declare a variable with let or const. Later assignments drop the
keyword:
speed = 40;
speed = 20;
time * speed
let speed = 40;
speed = 20;
t * speed
Wiggle and shake¶
wiggle(frequency, amount) varies around the current value. Multiply
time by the frequency, multiply shake by the amount, and add it to
the value:
wiggle(5, 20)
value + shake(t * 5) * 20
For a 2D property, give each axis its own seed:
[
x + shake(t * 5, 0) * 20,
y + shake(t * 5, 1) * 20
]
Oscillation¶
value + Math.sin(time * 4) * 20
value + sin(t * 4) * 20
Remapping values¶
lerp with a clamped progress value replaces linear. This moves from
0 to 100 over two seconds:
linear(time, 0, 2, 0, 100)
lerp(0, 100, clamp(t / 2, 0, 1))
Conditions¶
time < 1 ? 0 : 100
if t < 1 { 0 } else { 100 }
What Shrimply does not have¶
There is no thisComp, thisLayer, or link to another property.
Expressions cannot read keyframes, so loopIn(), loopOut(), and
valueAtTime() have nothing to call.
To loop a clip, open in the inspector and set Strategy to Repeat or Ping Pong.