ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Expression to generate linear path between time remapped keyframes?

FAQ   •   VIEW ALL
 Expression to generate linear path between time remapped keyframes? on May 1, 2019 at 5:00:57 amLast Edited By Chris Green on May 1, 2019 at 5:44:54 am

Hi all,

I have a series of time remapped deformations on a shape. These deformations are created by specific position keys on a Joystick.

If I want to move from shape 1 (keyframe 1) to shape 2 (keyframe 2), the interpolation is smooth and straight forward, as they are neigbouring keyframes as far as time remapping is concerned.

If I want to move from shape 1 (keyframe 1) to shape 8 (keyframe 8), time remapping behaves as normal and counts up from 1-8, but it hits every keyframe in between. If the time between these keys is short, I get a lot of pop in the interpolation as it cycles through the deformations. This is not the desired outcome. I need to ignore the keys inbetween.

Is there an expression that will generate a linear path between dispirate frames? Something using valueAtTime() and or linear()?

I have a rudimentary understanding of scripting but lack the specific langauge I need to achieve this (if its even possible).

Many thanks in advance for any help rendered! :)

 Re: Expression to generate linear path between time remapped keyframes?on May 1, 2019 at 7:44:06 am

If we take the time remapping out of the equation, this is possible. You can linearly interpolate between any two keyframe values over time. If you just want to retrieve the intermediate position, for instance. (If you retrieve the intermediate time, you'll just end up with the original issue.)

The question is, how to tell the expression which two keyframes you want to interpolate between. I guess the simplest approach would be two sliders with hold keyframes, one for starting keyframe index, one for ending keyframe index. Then a third linear (or eased) slider to control the animation progress from 0 to 100 (as a percentage).

Ok, so if you had those three sliders, you can retrieve the starting and ending positions with something like yourlayerhere.transform.position.valueAtTime(key(index).time)
[That might not be exactly right, check the expression reference]

And you can interpolate between those two positions with the "animation progress" slider, which allows you to add easing very simply.

I find it easier to use the percentage to calculate the x and y positions separately and combine them into an array on the last line [xPos, yPos].

I would animate the "animation progress" slider back and forth, and leap frog the starting and ending position values. Meaning animate from 0 to 100, then change the value for the starting position index and animate from 100 to 0, change the ending position index, animate from 0 to 100, etc.

You would have to do this for every property you wanted to animate, so if you have 10 control points to animate, they all need the same expression applied to them.

Kalleheikki Kannisto
Senior Graphic Designer

 Re: Expression to generate linear path between time remapped keyframes?on May 1, 2019 at 12:48:06 pm

It really depends on what you mean by deformed shapes ?

Is this just one Path that has shape keyframes ? Does every one of those keyframes have the same amount of vertices ?

Are they parametric shapes like a polystar ?

Or is it a complex shape layer with a lot of shapes, with keyframed positions, colors, stroke weights, wiggles, paths,…