ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Looping a Random Expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
John Turner
Looping a Random Expression
on Oct 25, 2018 at 2:13:38 pm

Hi everyone!

I have a rectangle that I would like to scale in the X-direction. The scale amount should be a random amount between 90% and 100%. Additionally, this random scaling should be applied every 1 second with a 1-second delay between scaling. Also, the scaling should be smooth across the 1 second.

Currently I have this:
t = (time)%2;
if (t ==0)
content("Rectangle 1").transform.scale=[content("Rectangle 1").transform.scale[0]*random(0.9,1),100];
else
content("Rectangle 1").transform.scale=[content("Rectangle 1").transform.scale[0]*1,100]


However, I seem to be having a few problems. The rectangle only seems to scale once (at the start of the layer), the scaling is instant, whereas I would like to make it scale up/down to its new value across 1 second, and there is no delay between scalings.

Could someone help me out on this? Thanks!


Return to posts index

Dan Ebberts
Re: Looping a Random Expression
on Oct 25, 2018 at 3:49:00 pm

Something like this maybe:

n = Math.floor(time/2);
t = time%2;
seedRandom(n,true);
mNext = random(0.9,1);
seedRandom(n-1,true);
mPrev = random(0.9,1);
m = linear(t,0,1,mPrev,mNext);
[value[0]*m,value[1]]


Dan



Return to posts index

John Turner
Re: Looping a Random Expression
on Oct 25, 2018 at 7:29:50 pm

Absolutely perfect! Thanks so much!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]