Changing text colour midway through a sentence with expressions

New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

I am trying to create a MoGrt for a client, and at one stage the client needs to input 2 values in the same text sentence, the issue I'm having is I need the second input to be a different colour.

My source text field will look something like this:

 

"input 1" + (different colour)"input 2"

 

I cannot seem to find the right way to word this in expressions, to change colour at the marked point. I know how to link the text input using other text layers but can anyone help me with the expression to change the text fill colour before the second input.

 

Thanks!

TOPICS
Expressions , Scripting

Views

53

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

As far as I know, you cannot control the color of individual letters with an expression on the source text. But you can do things like that with a range selector expression: https://www.youtube.com/watch?v=wgiaNEQit3g

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Thanks for the reply, I'll give it a shot and see how I go!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

LATEST

Thanks, you really set me on the right path, here's my solution:

 

- I applied a fill effect using text animators to the final text layer

- Applied this expression to the final text layer referencing the two input text layers:

      thisComp.layer("Input 1").text.sourceText + " " + thisComp.layer("Input 2").text.sourceText

- I applied this expression to the range selector 'start' which is set to 'index' instead of 'percentage':

      thisComp.layer("Input 1").text.sourceText.length

- Set the end range to a very high number

 

Now the colour change is applied after the first text input.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines