DaVinci Resolve

Fusion Expressions Cheat Sheet

Expressions and examples for DaVinci Resolve Fusion, from the Fusion Fu page of the old site.

Bar graph

Get the value from a text node:

Text1.StyledText.Value

Display a % value based on the graph length:

floor(Rectangle1.Width/1.8*100) .." %"

Position the Text node Layout Center on the graph bar:

Point(Rectangle1.Width/2-0.02, 0.5)

Get the value from another Text node, even if that value is made with an expression:

:a=tonumber(string.sub(Text1.StyledText.Value, 0, string.len(Text1.StyledText.Value)-2)); return a

Use in the Rectangle node Width property. Changes the width based on the main Rectangle Width, its value and the value of the current bar:

floor(Rectangle1.Width*Text2.StyledText.Value/Text1.StyledText.Value*100)/100

Watch the video

Stop and go transition

iif(time<=floor(comp.RenderEnd*0.87), 
 ceil(comp.RenderEnd/2), 
 iif(time>ceil(comp.RenderEnd*0.86), 
 floor(ceil(comp.RenderEnd/2)+(time-floor(comp.RenderEnd*0.86))*(floor(comp.RenderEnd/2))/(comp.RenderEnd-floor(comp.RenderEnd*0.86)))))

Watch the video

Dynamic transitions

Use in the Dissolve node to switch Foreground/Background.

Instantly switch between FG/BG at the midpoint of the clip duration:

iif(time<(comp.RenderEnd/2),1,0)

Does the same in a different way:

iif((comp.RenderEnd-time)<(comp.RenderEnd/2),0,1)

Gradually blend and switch FG/BG:

time/comp.RenderEnd

Watch the video

Rounding numbers

floor(1.99) -- returns 1
ceil(1.01)  -- returns 2

Composition frames

time              -- the current frame
comp.RenderStart  -- the first frame
comp.RenderEnd    -- the last frame

Min, max, random

min(num1,num2)     -- the lower of the 2 numbers
max(num1,num2)     -- the larger of the 2 numbers
random(num1,num2)  -- random number between num1 and num2

Social media border timer (1080p, 2k, 4k, 1350p)

Adjusts the rectangle starting position based on the timeline resolution:

:if (ratio == 1.77) then return 0.585; end; if (ratio == 0.56) then return 0.657; end; if (ratio == 0.8) then return 0.636; end; if (ratio == 1) then return 0.622; end; if (ratio == 1.89) then return 0.58; end;

Make a ratio variable inside ANY node:

:ratio=floor(comp:GetPrefs("Comp.FrameFormat.Width")/comp:GetPrefs("Comp.FrameFormat.Height")*100)/100;

Watch the video

Date and time

Format codes:

%a - "Mon"
%A - "Monday"
%b - "Jan"
%B - "January"
%c - date and time "01/28/87 20:50:20"
%d - day from 01 to 31
%H - 24h format
%I - 12h format
%M - minutes from 0 to 59
%m - month from 01 to 12
%p - "am" or "pm"
%S - seconds from 00 to 59
%w - weekday from 0 to 6 (Sunday-Saturday)
%x - date "01/28/87"
%X - time "20:50:20"
%Y - year "1987"
%y - year with 2 digits from 00 to 99
%% - gives you the % character

Usage example:

os.date("%Y, %x, %b, %A")

Custom time format (30 being FPS, and 60 seconds):

floor((comp.RenderEnd-time)/30/60)..":"..floor((comp.RenderEnd-time)/30%60)

Get time in minutes and seconds (30 being FPS):

os.date("%M:%S",(comp.RenderEnd-time)/30)

Watch the video

Milliseconds example

Save the comp FPS in variable x:

: x=comp:GetPrefs("Comp.FrameFormat.Rate"); return x

Then:

os.date("%M:%S", (comp.RenderEnd-time)/x)..":".. string.format("%03d", math.fmod(comp.RenderEnd-time, x)*1000/x)

Or, instead of returning the x value, combine the 2 expressions:

: x=comp:GetPrefs("Comp.FrameFormat.Rate"); return os.date("%M:%S", (comp.RenderEnd-time)/x)..":".. string.format("%03d", math.fmod(comp.RenderEnd-time, x)*1000/x)

Watch the video

Countdown timer, count-up timer

Get the current FPS in variable x:

: x=comp:GetPrefs("Comp.FrameFormat.Rate"); return x

Count DOWN timer, with 3 decimals:

string.format("%.3f", (comp.RenderEnd-time)/x)

Count UP timer, with 3 decimals:

string.format("%.3f", (time)/x)

Watch the video

Scroll to Top