ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Is it possible to partially change color of text with Expressions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dmitry Yershov
Is it possible to partially change color of text with Expressions
on Sep 17, 2016 at 12:47:13 pm

Hey everyone,

I'm trying to do a Twitter template and I want the user to be able to change colors of text and links separately with expressions. Is it possible to get regular text be Color 1 and words starting with # or @ - Color 2?

Thanks!


Return to posts index

Dan Ebberts
Re: Is it possible to partially change color of text with Expressions
on Sep 17, 2016 at 3:55:24 pm

Try this:

1) add a Fill Color animator for Color 2
2) add an Expression Selector
3) replace the expression for the Expression Selector's Amount property with this:


myChar = "";
for (i = textIndex; i > 0; i--){
c = text.sourceText[i-1];
if (c == " ") break;
myChar = c;
}
if (myChar == "@" || myChar == "#") 100 else 0


Dan



Return to posts index

Dmitry Yershov
Re: Is it possible to partially change color of text with Expressions
on Sep 17, 2016 at 4:34:41 pm

Hi Dan,

You are a GOD. Thank you so much, that worked really nicely, just what I needed.


Return to posts index


Dmitry Yershov
Re: Is it possible to partially change color of text with Expressions
on Sep 17, 2016 at 6:35:09 pm

One small issue though: every time I edit the text it gives me this error:



It disables the expression and when I enable it - everything is fine again. Until I edit again. Any idea on what the issue might be?

I'm using AE CS6.


Return to posts index

Dan Ebberts
Re: Is it possible to partially change color of text with Expressions
on Sep 17, 2016 at 8:24:52 pm

This should take care of it:


try{
myChar = "";
for (i = textIndex; i > 0; i--){
c = text.sourceText[i-1];
if (c == " ") break;
myChar = c;
}
if (myChar == "@" || myChar == "#") 100 else 0
}catch(e){
value
}



Dan



Return to posts index

Dmitry Yershov
Re: Is it possible to partially change color of text with Expressions
on Sep 18, 2016 at 5:06:55 am

Thank you very much, Dan!


Return to posts index


Scott McGee
Re: Is it possible to partially change color of text with Expressions
on Oct 4, 2017 at 12:12:54 pm

Hey Guys,

This is a brill expression, but for some unknown reason it doesn't like paragraphing...Is there a little bit more that can be added to the expression to take into account for this?

I'm taking a stab in the dark that it's because of this if (c == " ") break; is just looking at each work in a row, but as soon as I paragraph, if it's the first word, it doesn't work, but if you hit space, the word color fills but not the @ or #.

Other than that I'm clueless.


Return to posts index

Scott McGee
Re: Is it possible to partially change color of text with Expressions
on Oct 4, 2017 at 12:21:55 pm

Funnily enough though, if I treat is as a textbox, when it wraps the text...It's not affected that way.


Return to posts index

Scott McGee
Re: Is it possible to partially change color of text with Expressions
on Oct 4, 2017 at 1:24:07 pm
Last Edited By Scott McGee on Oct 4, 2017 at 2:13:57 pm

This works, but if you hit return on the very first character, or if you delete the space that at the end of the line, it shifts the colour forward one otherwise it works...Yay

try{
myChar = "";
for (i = textIndex; i > 0; i--){
thisText = text.sourceText.replace(/\r?\n|\r/g, ' ').replace(/\s{2,}/g, ' ');
c = thisText[i-1];
if (c == " ") break;
myChar = c;
}
if (myChar == "@" || myChar == "#") 100 else 0
}catch(e){
value
}


Return to posts index

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