FORUMS: list search recent posts

Expression to assign a color to a letter?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ari Grunzeweig
Expression to assign a color to a letter?
on Jun 9, 2019 at 12:47:43 am
Last Edited By Ari Grunzeweig on Jun 9, 2019 at 12:48:25 am

Hi,

I found the following expression on CC to assign a color to letters in a block of text.

However, even though I have the letter 'a' associated with a specific color value, different 'a's in my text and appearing as different colors.

txt = text.sourceText;
switch(txt[textIndex-1]){
case "A":
color = [0,1,0];
break;
case "C":
color = [0,0,1];
break;
case "T":
color = [1,1,0];
break;
case "G":
color = [1,0,0];
break;
default:
color = [0,0,0];
break;
}
color*100


See attached image.


Any ideas how to ensure each letter is always the same color?

Thanks,
Ari


Return to posts index

Kalleheikki Kannisto
Re: Expression to assign a color to a letter?
on Jun 9, 2019 at 3:04:20 pm

How do you have this set up and what property are you applying this expression to?

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Ari Grunzeweig
Re: Expression to assign a color to a letter?
on Jun 9, 2019 at 9:26:00 pm

Thanks so much for your reply. Please see the attached screenshot. Does that help clarify?

Thanks gain!



Thanks,
Ari


Return to posts index


Kalleheikki Kannisto
Re: Expression to assign a color to a letter?
on Jun 10, 2019 at 3:37:44 am
Last Edited By Kalleheikki Kannisto on Jun 10, 2019 at 3:46:03 am

Ok, I see. That should work, as long as the original color of the type is black. You are adding a percentage of white to each of the RGB channels to the existing color. If the original color is something else, the target color gets added to the original color, resulting in something else.

If you want to use colored lettering to start with, you'll need two color animators with expression selector. The first color expression would add 100% black to any letters that you want to subsequently color. The second would be the same you currently have.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Ari Grunzeweig
Re: Expression to assign a color to a letter?
on Jun 10, 2019 at 11:48:17 am

Hi,

Thanks very much, but I'm still not getting the result. My source text is black as is the 'base color' in the expression.
I tried adding an animator before the one I had with color set to black, and the result is the same. This is the full code on the second animator:

txt = text.sourceText;
switch(txt[textIndex-1]){
case "a":
color = [255,128,0];
break;
case "b":
color = [0,102,0];
break;
case "c":
color = [0,102,102];
break;
case "d":
color = [0,76,153];
break;
case "e":
color = [76,0,153];
break;
case "f":
color = [153,0,153];
break;
case "g":
color = [204,0,102];
break;
case "h":
color = [50,75,75];
break;
case "i":
color = [153,0,0];
break;
case "j":
color = [0,102,0];
break;
case "k":
color = [0,102,102];
break;
case "l":
color = [0,76,153];
break;
case "m":
color = [0,153,153];
break;
case "n":
color = [153,0,153];
break;
case "o":
color = [204,0,102];
break;
case "p":
color = [50,75,75];
break;
case "q":
color = [153,0,0];
break;
case "r":
color = [0,102,0];
break;
case "s":
color = [0,102,102];
break;
case "t":
color = [0,76,153];
break;
case "u":
color = [76,0,153];
break;
case "v":
color = [153,0,153];
break;
case "w":
color = [204,0,102];
break;
case "x":
color = [50,75,75];
break;
case "y":
color = [204,0,102];
break;
case "z":
color = [50,75,75];
break;
default:
color = [22,40,69];
break;
}
color*100/255


Also attached is a new screenshot trying your suggested setup:


Thanks!!

Thanks,
Ari


Return to posts index

Kalleheikki Kannisto
Re: Expression to assign a color to a letter?
on Jun 10, 2019 at 1:22:09 pm

Works just fine for me.



Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index


Ari Grunzeweig
Re: Expression to assign a color to a letter?
on Jun 10, 2019 at 1:47:39 pm

Amazing!

I can't figure out what I am doing differently :(

Thanks,
Ari


Return to posts index

Kalleheikki Kannisto
Re: Expression to assign a color to a letter?
on Jun 11, 2019 at 4:20:21 am

Here's my file.

13421_colorletters.aep.zip

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Ari Grunzeweig
Re: Expression to assign a color to a letter?
on Jun 12, 2019 at 2:20:55 am

Thank you!

Thanks,
Ari


Return to posts index


Kalleheikki Kannisto
Re: Expression to assign a color to a letter?
on Jun 12, 2019 at 6:16:07 am

Did you figure out what the difference was?

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

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