Here are a few examples of using some arbitrary math operations. I demonstrate some of these using a Custom tools Point Positions, but you can use all other controls as well. I also won’t cover many of these, for more you can look here as these are mostly the normal Lua functions.
Get Maximum or Minimum of different values
If you need the maximum value of a set of numbers you can use the
max(value1, value2, ...) Expression. It’s very simple to use and does exactly as you expect. In my example, I have used three controls but you can use more or less.
Here it prints the maximum X value of the three Position Controls of the Custom Tool:
You can do the opposite by exchanging the
Convert to an integer with
Works exactly like you might know from Lua. This will return a full integer of a floating value. For example, 1.6 returns 1.
This will do the same except you get the next integer, so 1.6 would return 2.
Random numbers with
As the name suggest, this will return random numbers, you can set a min and max number.
will return a random value between 0 and 1.
will return a random number between 1 and value1.
will return a random number between value1 and value2.
Quick notice! While I have added these for the sake of it, you won’t actually need these. Most users, especially After Effects users, only want a
math.random is not it. It’s much easier and better to use the Shake Modifier and the control you want to move/wiggle/rotate.
On the next page we will look at Metadata.