ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Random numbers in one source text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kyle Maven
Random numbers in one source text
on Oct 30, 2019 at 4:39:36 pm

I want to display a group of six numbers, each with a value of either 0 or 1 (with spaces between). I want each number to randomize every 4-8 frames. I was hoping to keep it all in one layer's Source Text with the ability to add more numbers with a slider (instead of 6 numbers, I want 9 or 12). Also I want the seed to be different if I duplicate the layer.

I don't know too much about expressions but I know its a combination of posterizeTime, seedRandom, Math.round, gaussRandom, repeat, and a slider. But I just don't know how to lay it all out.

Right now I am just working on getting them all to be different numbers, then I was going to work on "adding" numbers but I'm stumped. The expression I currently have displays all the same number.

0 0 0 0 0 0

but I want something like
1 0 0 1 1 0 >>> 1 0 1 1 0 0

I appreciate any help!

posterizeTime(gaussRandom(4,8);
seedRandom(index, timeless = false);
Num = Math.round(gaussRandom(0,1));

Num + " " + Num + " " + Num + " " + Num + " " + Num + " " + Num + " "


Return to posts index

Dan Ebberts
Re: Random numbers in one source text
on Oct 30, 2019 at 6:05:18 pm

You need to call random() (or gaussRandom()) for each number, something like this:


seedRandom(index, false);
n = 6; //number of digits
str = "";
for (i = 0; i < n; i++){
str += Math.round(gaussRandom(0,1)) + (i == n-1 ? "" : " ");
}
str




Return to posts index

Kyle Maven
Re: Random numbers in one source text
on Oct 30, 2019 at 8:37:57 pm

Just added posterizeTime() but works perfectly! Thanks!


Return to posts index

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