FORUMS: list search recent posts

Expression - random numbers with decimal point

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Robert Cornfoot
Expression - random numbers with decimal point
on Mar 7, 2014 at 9:18:31 am

Hello

Firstly can I say I am new to expressions. However I would like to know if there is a simple way of generating a random number with two further numbers after the decimal point.

e.g. 15.17

I have used the 'Character Offset' with a wiggle command - wiggle(1,5) but this only produces a two digit number with no decimal.

Does anyone know a work around?

Thanks
Rob


Return to posts index

Dan Ebberts
Re: Expression - random numbers with decimal point
on Mar 7, 2014 at 4:10:43 pm

I'm not sure if this is exactly what you had in mind, but give this source text expression a try:

random(100).toFixed(2)


Dan



Return to posts index

Robert Cornfoot
Re: Expression - random numbers with decimal point
on Mar 8, 2014 at 4:14:05 pm

That's fantastic thanks - just what I wanted.

One further question. Can the speed of the random numbers be controlled? (slowed down) For example, can the time between each change of digits be extended - so the each digit is on screen for longer.

Thanks
Rob


Return to posts index


Dan Ebberts
Re: Expression - random numbers with decimal point
on Mar 8, 2014 at 4:38:36 pm

Something like this probably:

frames = 5; // frames to hold each random number
seed = Math.floor((time - inPoint)/framesToTime(frames));
seedRandom(seed,true);

random(100).toFixed(2)



Dan



Return to posts index

Robert Cornfoot
Re: Expression - random numbers with decimal point
on Mar 9, 2014 at 2:35:55 pm

Thanks a million Dan. Perfect!

Rob


Return to posts index

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