ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Change color per character of text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tom Szymanski
Change color per character of text
on Jul 25, 2020 at 3:51:24 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



Return to posts index

Andrei Popa
Re: Change color per character of text
on Jul 25, 2020 at 7:37:59 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.


Return to posts index

Tom Szymanski
Re: Change color per character of text
on Jul 25, 2020 at 4:31:27 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!


Return to posts index


Andrei Popa
Re: Change color per character of text
on Jul 25, 2020 at 5:07:37 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.


Return to posts index

Tom Szymanski
Re: Change color per character of text
on Jul 25, 2020 at 6:53:10 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!


Return to posts index

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