ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

FAQ   •   VIEW ALL
 Random ease between two values with minimum and maximum on-off times on Mar 28, 2018 at 2:44:51 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: http://CreationEffects.com

 Re: Random ease between two values with minimum and maximum on-off timeson Mar 28, 2018 at 7:23:11 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