Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Reverse effect of expression

  • Reverse effect of expression

    Posted by John Madison on January 11, 2014 at 2:27 pm

    Hi,

    I have the following expression:

    t = time - inPoint;
    startVal = 0;
    endVal = 100;
    dur = thisComp.layer("Controls").effect("Stretch Duration")("Slider")/10;
    if (t < dur){
    s = linear(t,0,dur,startVal,endVal);
    }else{
    amp = (endVal - startVal)/dur;
    freq = 3;
    decay = 5;
    w = freq*Math.PI*2;
    s = endVal + amp*Math.sin((t-dur)*w)/Math.exp(decay*(t-dur))/w;
    }
    [s,s]

    As it is, it scales the layer from 0=100 with a slight elastic effect, the duration of the elasticity determined by the slider. I would like to then reverse this effect so that the layer, after a period determined by a slider, returns to 0, again with some elasticity.
    Your help will be greatly appreciated.
    Thanks

    Dan Ebberts replied 12 years, 3 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    January 11, 2014 at 6:48 pm

    I’m not sure this is what you’re after, but it might get you headed in the right direction:


    period = thisComp.layer("Controls").effect("Period")("Slider");
    dur = thisComp.layer("Controls").effect("Stretch Duration")("Slider")/10;

    t = time - inPoint;
    if (t < period){
    startVal = 0;
    endVal = 100;
    }else{
    startVal = 100;
    endVal = 0;
    t -= period;
    }
    if (t < dur){
    s = linear(t,0,dur,startVal,endVal);
    }else{
    amp = (endVal - startVal)/dur;
    freq = 3;
    decay = 5;
    w = freq*Math.PI*2;
    s = endVal + amp*Math.sin((t-dur)*w)/Math.exp(decay*(t-dur))/w;
    }
    [s,s]

    After the time set by the Period slider it will do a reverse ramp with bounce at the end.

    Dan

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