• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Responsive colour change in After Effects

Community Beginner ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

Hi Everyone,

 

I just want to ask if it's possible to create a responsive colour change in After Effects. I created a composition where I have a white text colour and a dark background.

 

What I wanted is for whenever I change the background to a light colour, the text colour would change to black so the text would still be visible. Is this possible?

 

Thank you very much!

TOPICS
Expressions , FAQ , Resources

Views

543

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

correct answers 1 Correct answer

Community Expert , Feb 15, 2023 Feb 15, 2023

If you start with white text, and add a black fill color animator to it, you could add an expression to the range selector's amount property that would sample the center pixel of the background layer and go with black if the luminance is over 50%. Something like this should work:

 

 

bg = thisComp.layer("background");
rgb = bg.sampleImage([bg.width,bg.height]/2,[.5,.5]);
hsl = rgbToHsl(rgb);
hsl[2] > .5 ? 100 : 0

 

 

Votes

Translate

Translate
Community Expert ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

If you start with white text, and add a black fill color animator to it, you could add an expression to the range selector's amount property that would sample the center pixel of the background layer and go with black if the luminance is over 50%. Something like this should work:

 

 

bg = thisComp.layer("background");
rgb = bg.sampleImage([bg.width,bg.height]/2,[.5,.5]);
hsl = rgbToHsl(rgb);
hsl[2] > .5 ? 100 : 0

 

 

Votes

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 Beginner ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

Hi @Dan Ebberts . Thanks for your response. I tried it but it says Error: expression result must be of dimension 4, not 1 Maybe I can ask if you can drop an EA file here so I can dissect it? >_<

Votes

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 ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

Sorry, the expression gets applied to the Amount property in the Advanced section of the Range Selector, not to the Fill Color property.

Votes

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 Beginner ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

LATEST

Oh my god! That worked!!! Thank you so much @Dan Ebberts . I really appreciate your help. 🙂 

Votes

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