Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
Wiggle expression family
Simple wiggle
Wiggle (5, 10)
- The first number, 5, defines how long your layer oscillates per second. In this case it moves five times in a second
- The second number, 10, defines how much it moves up and down — in this case, 10 pixels
rendering
expression
wiggle(8.120)
Copy the code
Start & end wiggle expressions
With slider controls you can easily control your swing to start and stop motion
rendering
expression
wiggle(thisComp.layer("Null 1").effect("Slider Control") ("Slider"),10)
Copy the code
Hold wiggle expression
If you want to pause your swing, this expression should do the trick. The code allows you to stop swinging on frame 100
rendering
expression
stopFrame = 100;
t = Math.min(time,framesToTime(stopFrame));
wiggle(13.20.1.. 5,t)
Copy the code
Wiggle vertical expressions
Using this Wiggle expression, you can animate vertically on the Y-axis.
rendering
expression
org=value; temp=wiggle (8.40);
[org[0],temp[1]].Copy the code
Wiggle level expressions
This is the expression for the horizontal oscillation along the X axis.
rendering
expression
org=value; temp=wiggle (5.120);
[temp[0],org[1]].Copy the code
Wiggle depth (z-axis) expression
Change your layer to 3D and use this expression to wiggle on the Z-axis.
rendering
expression
a =wiggle(0.0);
b =wiggle(0.0);
c = wiggle(5.95); [a[0],b[1],c[2]]
Copy the code
Evenly scale wiggle expressions
This expression allows you to scale your layers.
rendering
expression
w = wiggle(5.80);
[w[0],w[0]]
Copy the code
Seamlessly loop wiggle expressions
This wiggle expression allows you to loop perfectly. Just don’t forget to adjust loopTime for your composite timeline.
rendering
expression
freq = 1;
amp = 110;
loopTime = 3;
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1.0.5, t);
wiggle2 = wiggle(freq, amp, 1.0.5, t - loopTime);
linear(t, 0, loopTime, wiggle1, wiggle2)
Copy the code