ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Randomize Specific Set of Characters

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Liam Campbell
Randomize Specific Set of Characters
on Mar 11, 2018 at 4:42:31 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?


Return to posts index

Declan Smith
Re: Randomize Specific Set of Characters
on Mar 11, 2018 at 7:22:12 pm

Try something like this

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


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

"it's either binary or it's not"


Return to posts index

Liam Campbell
Re: Randomize Specific Set of Characters
on Mar 11, 2018 at 9:11:41 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?


Return to posts index


Declan Smith
Re: Randomize Specific Set of Characters
on Mar 11, 2018 at 10:05:47 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
http://www.madpanic.tv
FCPX / Adobe CS6/ FCS3 / Canon XLH1 / Canon 7D / Reason / Cubase

"it's either binary or it's not"


Return to posts index

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