Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random ease between two values with minimum and maximum on-off times

  • Random ease between two values with minimum and maximum on-off times

    Posted by Noel Powell on March 28, 2018 at 2:44 pm

    I’m exploring ways to have a property randomly ease between two values, but with a several controlling factors built in. I’ve used this expression from Dan Ebberts before, which works great for creating random blinking between two values (in this case, 0 and 100), using slider controls to determine the minimum and maximum on times, and minimum and maximum off times. What I can’t figure out is how to modify the expression to make it ease between the two values over a set amount of time.
    For example, if there was a slider control named “easeDuration” that was set to 0.5, then every time the property goes from 0 to 100, I’d like it ease from 0 to 100 over a period of 0.5 seconds, and then when it goes back to 0, it would do so over a period of 0.5 seconds.
    I’ve tried many times to wrap my head around all of Dan’s brilliant articles on expressions, but my brain can only follow up to a certain point. Any help is greatly appreciated!

    minOnTime = effect("Minimum On Time")("Slider");
    maxOnTime = effect("Maximum On Time")("Slider");
    minOffTime = effect("Minimum Off Time")("Slider");
    maxOffTime = effect("Maximum Off Time")("Slider");
    i = 0;
    tEnd = 0;
    seedRandom(index,true);
    preRun = random(maxOnTime);
    while (time + preRun >= tEnd){
    i++;
    if(i%2){
    tEnd += random(minOnTime,maxOnTime);
    result = 100;
    }else{
    tEnd += random(minOffTime,maxOffTime);
    result = 0;
    }
    }
    result

    After Effects Templates – digital glitch effects, 80s VHS effects, old film effects, art effects, and more: https://CreationEffects.com

    Noel Powell replied 8 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 28, 2018 at 7:23 pm

    Something like this maybe:


    minOnTime = effect("Minimum On Time")("Slider");
    maxOnTime = effect("Maximum On Time")("Slider");
    minOffTime = effect("Minimum Off Time")("Slider");
    maxOffTime = effect("Maximum Off Time")("Slider");
    easeTime = effect("Ease Time")("Slider");
    i = 0;
    seedRandom(index,true);
    preRun = random(Math.min(maxOffTime,maxOnTime));
    t = time + preRun;
    tEnd = 0;
    while (t >= tEnd){
    i++;
    tPrev = tEnd;
    if(i%2)
    tEnd += random(minOnTime,maxOnTime)
    else
    tEnd += random(minOffTime,maxOffTime);
    }
    if (i%2)
    ease(t,tPrev,tPrev + easeTime,0,100)
    else
    ease(t,tPrev,tPrev + easeTime,100,0)

    Dan

  • Noel Powell

    March 28, 2018 at 8:17 pm

    Works beautifully, Dan. Thank you so much!

    After Effects Templates – digital glitch effects, 80s VHS effects, old film effects, art effects, and more: https://CreationEffects.com

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