Copy link to clipboard
Copied
Hello! I'm new to using expressions so forgive me if this is simple. I'm trying to randomize the color of each letter I type in AE and this is what I'm using on an expression selector:
colorArray = [[126, 31, 134]/255,[145, 196, 242]/255,[140, 160, 215]/255],[161, 77, 160]/255,[126, 31, 134]/255;
seedRandom(textIndex,true);
colorArray[Math.floor(random(colorArray.length))]*100
So this works for randomizing my colors but I also don't want a color to be repeated one after another. Does anyone know how to fix this?
Copy link to clipboard
Copied
Random is random. You'll need a pseudo-random formula and I can't do that off the top of my head. It's going to be javascript math. This article, the first brought up by Duck Duck Go, might get you started. I searched "javascript nonrepeating random number generator.
Copy link to clipboard
Copied
If you want to control the randomness this way, you have to create a loop that tests what color has been used already and given the limitations of expressions in AE this would mean you'd end up with a pretty clunky construct using large arrays and it would evaluate quite slowly. You may have better luck assigning your colors in a fixed pattern and then using wiggly selectors to randomize it after the fact strictly on a color-by-color basis.
Mylenium
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more