Functions
In this guide, we will demonstrate how to recreate the famous bouncing DVD logo effect. This involves several variables such as composition width, height, and duration, as well as the image's width and height. Handling these variables with the Keyframe
object can be complex, which is where functional properties
become useful. Follow the steps below for implementation:
Import Required Modules
First, import the necessary modules and create a Composition:
Fetch Resources
Fetch the required video and image resources in parallel:
Add Background Video
We can now add our background video to the Composition
:
Add the Bouncing DVD Logo
Add the image clip to the composition and use functional properties to animate its position:
Explanation
- ImageClip Properties: We use functional properties for
x
andy
to animate the image's position.x
calculates the horizontal position based on the elapsed time.y
calculates the vertical position similarly.
- Position Calculation:
reltime.seconds
provides time relative to the start of the clip in seconds, which is used to compute the position.- You can also use
reltime.millis
orreltime.frames
depending on the required precision. - The position is adjusted to ensure the image bounces within the composition boundaries.
Note: When using arrow functions for properties,
this
is not accessible, and you will need to pass theTimestamp
as the first argument. For example:x: (reltime: Timestamp) => reltime.frame
.
This setup will recreate the iconic bouncing DVD logo effect by leveraging functional properties to animate the image clip's position dynamically.