Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions color1 to color2 animation triggered by maximum position.speed?

  • color1 to color2 animation triggered by maximum position.speed?

    Posted by Juanluis Vich on February 5, 2019 at 5:14 pm

    Hi!
    I’m trying to go from color 1 to color 2, but based on the position speed of the layer. So we start with color 1 when the object has 0 speed, then the animation of the position starts, and when the position goes at its max speed, it triggers the fading to the color 2, so when the object stops the animation (so has 0 speed again), we will see color2

    it would be something similar to this effect here I read at an old post here (https://forums.creativecow.net/readpost/227/24965)

    amt = .01;
    effect("Motion Tile")("Tile Center").speed*amt

    but adapting to affect the colors, and make the color 2 stay when the speed is again 0, (and not going back to color 1 if the speed is 0)

    soo, basically: color 1 when position speed is 0 —–object starts moving —–reaches max speed —-fades to color 2—– the object is 0 again but we are in color 2

    any idea will be super welcome! thanks!

    Juanluis Vich replied 7 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    February 5, 2019 at 6:00 pm

    The problem is that maximum speed isn’t something that’s readily available to an expression. On each frame, the expression will have to examine the speed at every frame between the in point and the out point to see if the maximum has been reached yet. So performance could be an issue if your comp is long. If that’s the case, you might want to convert the expression to keyframes once it works the way you want it to. In any case, this should be close to what you’re looking for:


    color1 = [1,1,0,1]; // yellow
    color2 = [1,0.5,0,1]; // orange
    fadeTime = 1;
    max = 0;
    t = inPoint;
    tMax = t;
    while (t < outPoint){
    if (Math.abs(position.speedAtTime(t)) > max){
    max = Math.abs(position.speedAtTime(t));
    tMax = t;
    }
    t += thisComp.frameDuration;
    }
    tFade = Math.max(time-tMax,0);
    linear(tFade,0,fadeTime,color1,color2);

    Dan

  • Juanluis Vich

    February 5, 2019 at 6:51 pm

    great! thanks!

    mmm do you think if I add a manual threshold, (so it doesnt have to calculate that max value), the performance won’t get insane?

  • Dan Ebberts

    February 5, 2019 at 6:57 pm

    I guess that would help some, but the expression would still have to check every previous frame to see if the speed had ever exceeded the threshold and calculate how long ago that happened.

    Dan

  • Juanluis Vich

    February 5, 2019 at 7:13 pm

    oh! jeez! well, I will convert to keyframes then…

    many thanks! you have been super helpful!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy