Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change color per character of text

  • Change color per character of text

    Posted by Tom Szymanski on July 25, 2020 at 3:51 am

    Hi all,

    (I’m running After Effects 2020), and I’ve looked on the forums and found things that are close to this, but not quite there.

    I’m working on a project where I have to make a whole bunch of text layers where each letter is a specific color based on their order in the words.

    “These Words” where T – yellow, h – blue, e – red, s – purple, then repeating the cycle of colors for the next e – yellow, W – blue, etc.

    I’ve seen the expression control for color, so it seems like it should be possible to change afterwords the hue of yellow for all of these things if the client doesn’t like the yellow that’s been selected as an example.

    But I’m stumped on how to do the first part with differentiating the colors based on the order of characters.

    Any suggestions?
    Thank you!
    Tom

    Dan Ebberts
    replied 4 days ago
    5 Members · 8 Replies
  • 8 Replies
  • Andrei Popa

    July 25, 2020 at 7:37 am

    Since you need 4 colors, you need 4 text animators. And you need 4 color controls effects on the layer so you can change colors easily. So here’s how we’re gonna do that:

    Step 1. Add 4 color controls to your text layer. I named them “Color 1”, “Color 2” etc.

    Step 2. Add a “Fill” text animator. Pick-whip the color to Color 1. The expression should be this:
    effect("Color 1")("Color")
    Then add an expression selector to your animator. Choose “Based on” ->”Characters Excluding Spaces”
    Add this expression to the “Amount”:
    if ( textIndex%4 == 1 ) 100
    else 0

    Step 3. Duplicate this animator to make 4 of them. The expressions to the other 3 will be almost the same:

    2
    effect("Color 2")("Color")
    if ( textIndex%4 == 2 ) 100
    else 0

    3
    effect("Color 3")("Color")
    if ( textIndex%4 == 3 ) 100
    else 0

    4
    effect("Color 4")("Color")
    if ( textIndex%4 == 0 ) 100
    else 0

    Now you can change all the colors from the 4 color controls you placed at the beginning

    Andrei
    My Envato portfolio.

  • Tom Szymanski

    July 25, 2020 at 4:31 pm

    Thanks Andrei!

    I think I almost have it.

    On Step 2, adding “Fill” to text animator…sorry, I think I’m missing something, not in the syntax, in where to apply the expression. Where do I add the expression exactly? I’m not seeing a text animator, or maybe I’m thinking of something else.

    Thanks!

  • Andrei Popa

    July 25, 2020 at 5:07 pm

    You add the fill animator by clicking the “Animate” button that is right of your “Text” properties then “Fill Color” then “RGB”.
    Anyway, here is a link to a project that contains such a text layer https://www.dropbox.com/t/2oMNyIjbcQ6O0wfk

    Andrei
    My Envato portfolio.

  • Tom Szymanski

    July 25, 2020 at 6:53 pm

    Thank you SO SO SO much! That worked great! I opened up your project and could see it and it made more sense.

    One thing which you did that I didn’t notice at first was, the last color in the order you made it

    if ( textIndex%4 == 0) 100
    else 0

    Where I was expecting…

    if ( textIndex%4 == 4) 100
    else 0

    I was following your directions pretty well up until me skipping that part and the quickie project you send gave me something concrete to look at.

    You’re a LIFESAVER. I had to do like 100 of these manually with various words and it took forever!

    Thank you SO much!

  • Robin Borchers

    May 22, 2023 at 1:22 pm

    Hi, this expression doesn’t work.

  • Dan Ebberts

    May 22, 2023 at 3:48 pm

    It seems to work fine if you follow all the steps described by Andrei. In what way is it not working for you?

  • James Devonport

    June 16, 2024 at 3:41 pm

    For me, it doesn’t recognise ‘textIndex’. I’m running the latest version of 24. I thought it may have been removed, so I went back to the last version of 23 to test and I got the same error.

  • Dan Ebberts

    June 16, 2024 at 4:03 pm

    That expression will only work with an Expression Selector, not a Range Selector.

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