Start learning with our library of video tutorials taught by experts. Get started

After Effects Apprentice 09: Expressions
Illustration by John Hersey

Linear interpolation


From:

After Effects Apprentice 09: Expressions

with Chris Meyer and Trish Meyer

Video: Linear interpolation

In this chapter, we're going to take your expression skills to the next level by going just a little bit further in what you can do with the Pick Whip tool and simple numbers. If you've watched the last movie in this series, we're continuing on with the Clockwork copy I've been working with. If you jump straight here, just go ahead and open up the comp 03-Clockwork*starter in the project AEA_expressions. Don't worry about having not expressed the hour and second hands yet; we're still tying everything off of what the minute hand is doing. In fact, I'll twirl those up for now. You might have noticed we have this nice blue background going on behind this watch face.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
After Effects Apprentice 09: Expressions
1h 37m Intermediate Jul 27, 2011 Updated Nov 29, 2012

Viewers: in countries Watching now:

Expressions are one of the most powerful but underused features in After Effects. They can be used to animate layer properties with code, as compared to explicitly keyframing every value in the Timeline, and have multiple parameters and layers that follow the lead of a master layer or controller effect, making it much easier to coordinate complex animations and quickly accommodate client changes. In this introduction, Chris Meyer shows how to let After Effects do most of the work by creating simple but very useful expressions that can be put to work on a wide variety of jobs.

The After Effects Apprentice videos on lynda.com were created by Trish and Chris Meyer and are designed to be used on their own and as a companion to their book After Effects Apprentice. We are honored to host these tutorials in the lynda.com Online Training Library®.

Topics include:
  • Creating and managing expressions
  • Linking together different parameters
  • Randomizing a layer's movement
  • Looping an animation
  • Controlling multiple layers from a single source
Subjects:
Video Motion Graphics Visual Effects
Software:
After Effects
Authors:
Chris Meyer Trish Meyer

Linear interpolation

In this chapter, we're going to take your expression skills to the next level by going just a little bit further in what you can do with the Pick Whip tool and simple numbers. If you've watched the last movie in this series, we're continuing on with the Clockwork copy I've been working with. If you jump straight here, just go ahead and open up the comp 03-Clockwork*starter in the project AEA_expressions. Don't worry about having not expressed the hour and second hands yet; we're still tying everything off of what the minute hand is doing. In fact, I'll twirl those up for now. You might have noticed we have this nice blue background going on behind this watch face.

We actually gave you a second background layer as well. If I turn off the Alien Atmospheres movie, you'll see we have this Digidelic movie that we've used in few of our lessons. Let's say that we want to reveal that Digidelic movie with a sweep that's coordinated with that minute hand. Well, there is actually an effect that does that. I've selected Alien Atmospheres, go up to Effect, and go down to the Transition category, which is multiple ways of getting rid of one layer to reveal whatever lies underneath.

In this case, we want a Radial Wipe. Radial Wipe has a parameter called Transition Completion that does this clockwork-type reveal that we want. There is a problem though: whereas rotation works in degrees-- 360 degrees being a full circle--Transition Completion works in percentage with 100% being a full circle. How do we line those two up? Well, we could just use the Pick Whip tool and simple math...

well, not-so-simple math. You'd have to search saying, well, divide by 360 because that's the degrees, times 100 by the completion, that should get us back to where we want to be, and you'd be right. But rather than twisting your mind every time you need to convert one parameter range to another, there's this wonderful little expression called Interpolation that can do it for you. So let's explore that. We want Transition Completion to follow Rotation. I already have rotation exposed. I'll hold on Option or Alt, click on the stopwatch for Transition Completion, and it will be exposed down here in the Timeline panel.

Rather than use the Pick Whip tool or start typing code, I'm going to take advantage of this little arrow here and reveal what's known as the Expression Language menu. For those who are really get into expressions, this is a list of many different expression methods and other arguments that are available to you inside After Effects. The category we're interested in is called Interpolation, how to take one range of numbers and interpolate it to match what you need for a second range of numbers. In this case, we want to use the linear interpolation, so it's a straight-up translation, and we are going to use this second option.

I'll select that and After Effects will write this little starter piece of code for me automatically. What this code is really telling me is it wants to take a value, t--the default is to use time, but it can be anything you want--and as that value goes from its minimum to its maximum value, translate it into a new desired minimum and maximum value. At this point, we can just go ahead and use the Pick Whip and type in numbers, just like we have so far. I'll carefully select this t and say, rather than using time, instead I want you to follow the rotation of this layer.

Let go over the mouse and all the code I need is written for me. I don't need to type this by hand, but it's easy enough to read. This comp has a layer called minute. Use its transform property, rotation. Great! What's rotation's minimum? 0. What its maximum? 360. That's easy. What's the minimum value I want to translate to? 0 for 0% transition completion. What's the maximum value I want to translate to? 100 for 100% complete, literally all there is to it.

Click off, the expression has been accepted, and you're going to already see up here in the Comp panel that this transition is lining up with the minute hand. I'll press 0 in the numeric keypad to RAM preview, and you'll see I now have a coordinated animation. And just as with any other expressions, I can go ahead and edit these keyframe values. Maybe I want it to be a full 360 degrees. Enter, zero to RAM preview, and automatically, my effect for transition completion follows along with my altered master keyframe value.

This linear expression is one of my favorites. I use it all the time because I'm forever having to translate to get animations to line up. Remember that it resides underneath the Expression Language menu > Interpolation, second one down. Use the Pick Whip to replace the t with whatever property you want to follow and just type in your starting and minimum and maximum, your target minimum and maximum. By the way, if you want to see a finished version of this composition, go back into the Project panel, twirl open Comps_Finished, and open up 03-Clockwork_final.

We've done a lot more things here. We've added drop shadows and in the case of the drop shadows on the watch hands, we use that trick you've already learned earlier in this lesson to make the shadow always follow the right direction. We're doing the Radial Wipe and we're doing one more trick that's kind of fun: we're having the hue of that background layer change as the animation progresses, and we're using the exact same trick we used for Radial Wipe. I'll select the Alien Atmospheres layer. Press F3 to reveal it in the Effect Controls panel.

You'll see I use the effect Color Balance. It has a Hue value that also goes from 0 to 360 degrees. But I didn't want it to go all the way around the Hue wheel. I want a very specific range. So what I did is, with the expression turned off, and set somewhere where I can see what I was doing, I went ahead and scrubbed the Hue value to see what I wanted for a starting color, maybe something in there to go ahead and match my watch face color. Then went towards the end of the animation where I can see just a little segment in here and scrub and say, let's go ahead and match the color of my new background as we get close. Maybe something more in that range.

And once I know what those two values are, I just went ahead and use that same linear expression. I used the pick whip to tie it to the rotation of the minute hand, and as it went from the 0 to 360 degrees, I said I wanted my Hue rotation to go from -180 to 120. Just the same thing as we just did with Transition Completion. I'll click off, the expression turns back on, RAM preview, return to the start of my comp, and as I drag the Current Time Indicator through here, you can watch how the Hue value changes to coordinate its movements with the minute hand.

So the Linear Interpolation expression is one good tool to have in your toolkit. Another one is the Loop expression and I'll show that in the next movie.

Find answers to the most frequently asked questions about After Effects Apprentice 09: Expressions.


Expand all | Collapse all
Please wait...
Q: This course was updated on 11/29/2012. What changed?
A: We have added exercise files designed for After Effects CS6. We also added a movie that shows our premium subscribers how to use the exercise files.
Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed After Effects Apprentice 09: Expressions.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked