ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Change Shape Layer Color Based on Source Text Value

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam Haas
Change Shape Layer Color Based on Source Text Value
on Aug 14, 2018 at 5:36:54 pm

I have a text layer that shows "Good" or "Bad" based on another layer.

I have a shape layer that is behind that text, and I want the color to change to red if the text says "Bad" and green if the text says "Good".

I thought this would be pretty simple, but an if statement on the color attribute of the shape layer doesn't seem to be working.


Return to posts index

Dan Ebberts
Re: Change Shape Layer Color Based on Source Text Value
on Aug 14, 2018 at 5:51:47 pm

Something like this, probably:


txt = thisComp.layer("text").text.sourceText;
if (txt == "Good")
[0,1,0,1]
else if (txt == "Bad")
[1,0,0,1]
else
value



Dan



Return to posts index

Adam Haas
Re: Change Shape Layer Color Based on Source Text Value
on Aug 14, 2018 at 5:58:02 pm

Well, it's kind of working. I see the colors change, however when I try to set to a specific color, it just ignores it:


txt = thisComp.layer("text").text.sourceText;
if (txt == "Good")
[121,193,143,1]
else if (txt == "Bad")
[189,80,80,1]
else
value


Return to posts index


Dan Ebberts
Re: Change Shape Layer Color Based on Source Text Value
on Aug 14, 2018 at 6:00:05 pm

The colors have to be normalized (between 0 and 1):


txt = thisComp.layer("text").text.sourceText;
if (txt == "Good")
[121,193,143,255]/255
else if (txt == "Bad")
[189,80,80,255]/255
else
value



Dan



Return to posts index

Adam Haas
Re: Change Shape Layer Color Based on Source Text Value
on Aug 14, 2018 at 6:05:04 pm

That did the trick! Thank you so much.


Return to posts index

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