FORUMS TUTORIALS MAGAZINE STOCKYARD VIDEOS PODCASTS EVENTS SERVICES NEWSLETTER NEWS BLOGS
 ADOBE AFTER EFFECTS: Home Forum Basics Expressions Tutorials Podcasts AE Techniques Training Creative Cloud Debate FAQ

Random Scale Expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
 Random Scale Expression by Tommaso Rota on Oct 11, 2012 at 1:03:14 pm

Hi everyone, i'm Tommy nice to meet you i'm new to this world of expressions.
I need an expression that would randomly scale my object (choosing between 5 values) over a random period of time.
I managed to make it scale randomly between 10% and 100%, but what I need to do is a random scale of the object to 10% OR 20% OR 30% OR 40% OR 50%.
I hope that was clear enough.
Thank you

```seg_start_time = 0; seg_end_time = 0; i =1; tmin = 2; tmax = 8; while (time >= seg_end_time){ i = i+1; seed_random(i,true); seg_start_time = seg_end_time; seg_end_time = seg_end_time + random(tmin,tmax); } percent = (time - seg_start_time)/(seg_end_time - seg_start_time); s = random(10, 100); seed_random(i-1,true); x=random(); old_s = random(10, 100); ease(percent,[old_s],[s]); [s,s] ```

 Re: Random Scale Expressionby Dan Ebberts on Oct 11, 2012 at 1:35:00 pm

I'd do it like this:

``` minDur = 2; maxDur = 8; seedRandom(index,true); prev = next = inPoint; while (time >= next){ prev = next; next += random(minDur,maxDur); } seedRandom(prev,true); s = (Math.floor(random(5))+1)*10; [s,s] ```

Dan

 Re: Random Scale Expressionby Tommaso Rota on Oct 11, 2012 at 2:06:04 pm

thank you dan!!! it works perfectly!!
now i'd just like the size to change gradually and not to jump directly.
i mean, if it goes for example from 20% to 40%, i'd like the size not to jump but to gradually (rapidly though) change from 20% to 40%
can this be done?
thanks a lot!!

 Re: Random Scale Expressionby Dan Ebberts on Oct 11, 2012 at 2:14:32 pm

More like this then:

``` minDur = 2; maxDur = 8; tRamp = .25; seedRandom(index,true); prev = next = inPoint; while (time >= next){ prev = next; next += random(minDur,maxDur); } seedRandom(prev,true); sPrev = (Math.floor(random(5))+1)*10; seedRandom(next,true); sNext = (Math.floor(random(5))+1)*10; ease(time,next-tRamp,next,[sPrev,sPrev],[sNext,sNext]) ```

Dan

 Re: Random Scale Expressionby Tommaso Rota on Oct 11, 2012 at 2:18:19 pm

thanks a lot mate, you're my hero!!!!