Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Randomize Specific Set of Characters

  • Randomize Specific Set of Characters

    Posted by Liam Campbell on March 11, 2018 at 4:42 pm

    I want to make a randomly changing character expression but I want each character to pull from a determined pool of characters.

    I want to use these “º_-•˙|” characters only and when randomized I want each one to be only able to use characters from that set?

    Declan Smith replied 8 years, 4 months ago 2 Members · 3 Replies
  • 3 Replies
  • Declan Smith

    March 11, 2018 at 7:22 pm

    Try something like this

    chars=["º", "_", "-", "•", "˙", "|"]
    char_index=Math.floor(random(chars.length))
    random_char=chars[char_index]

    Declan Smith
    https://www.madpanic.tv
    FCPX / Adobe CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

    \”it\’s either binary or it\’s not\”

  • Liam Campbell

    March 11, 2018 at 9:11 pm

    Thanks for the reply! This is where I am:

    chars = [“º” , “_” , “-” , “•” , “˙” , “|”];
    seedRandom(5,true)
    n = Math.floor(random(0,6))
    chars[n] + chars[n] + chars[n] + chars[n] + chars[n] + chars[n]

    but obviously all of the “chars[n]” are the same character. What’s a clean way to make them all different?

  • Declan Smith

    March 11, 2018 at 10:05 pm

    Try this variation. This will loop over the array and build a string containing the random chars.

    chars=["º", "_", "-", "•", "˙", "|"]
    mystr=""
    for (i=0;i <chars.length; i++) {
    mystr+=chars[Math.floor(random(chars.length))]
    }
    mystr

    Declan Smith
    https://www.madpanic.tv
    FCPX / Adobe CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

    \”it\’s either binary or it\’s not\”

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