Blackmagic Fusion Simple Expressions-Cookbook + Tutorial

Math Operations

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:

Fusion math.max operation
:return math.max(CT.PointIn1.X,CT.PointIn2.X,CT.PointIn3.X)

You can do the opposite by exchanging the max() with min().

Convert to an integer with math.floor, math.ceil

Works exactly like you might know from Lua. This will return a full integer of a floating value. For example, 1.6 returns 1.

math.floor(value)
math.floor
math.ceil(value)

This will do the same except you get the next integer, so 1.6 would return 2.

Random numbers with math.random

As the name suggest, this will return random numbers, you can set a min and max number.

math.random()

will return a random value between 0 and 1.

math.random(value1)

will return a random number between 1 and value1.

math.random(value1, value2)

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 wiggle() equivalent, 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.

Quickly share this!

Subscribe
Notify of
16 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Scroll to top