Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Color Array Randomized Text Color

New Here ,
Jan 12, 2021 Jan 12, 2021

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?

Screen Shot 2021-01-12 at 7.40.46 PM.png

TOPICS
Expressions
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2021 Jan 12, 2021

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 12, 2021 Jan 12, 2021
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines