Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression – random numbers with decimal point

  • Expression – random numbers with decimal point

    Posted by Robert Cornfoot on March 7, 2014 at 9:18 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

    Amy Young replied 8 years, 3 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    March 7, 2014 at 4:10 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

  • Robert Cornfoot

    March 8, 2014 at 4:14 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

  • Dan Ebberts

    March 8, 2014 at 4:38 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

  • Robert Cornfoot

    March 9, 2014 at 2:35 pm

    Thanks a million Dan. Perfect!

    Rob

  • Amy Young

    February 10, 2018 at 3:00 am

    Still very useful — thanks Dan!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy