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

Change colours using code

Explorer ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

Hello, I am trying to figure out how to change a fill colour with code. For example, if I have a solid with a colour overlay of red how can I change this to another hex value? Many thanks.

TOPICS
Expressions

Views

228

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 2 Correct answers

LEGEND , Apr 11, 2023 Apr 11, 2023

hexToRgb(your color code here) into whatever property or effects control you want. 

 

Mylenium

Votes

Translate

Translate
Community Expert , Apr 11, 2023 Apr 11, 2023

You just need to make sure you get the value of the sourceText:

var hexColor = thisComp.layer("TextLayer").text.sourceText.value;
hexToRgb(hexColor)

Votes

Translate

Translate
LEGEND ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

hexToRgb(your color code here) into whatever property or effects control you want. 

 

Mylenium

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
Explorer ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

Great, thanks. I was also trying to read the value from a text layer so I needed to convert it to a string otherwise it gave me an error...

var hexColorSource = thisComp.layer("TextLayer").text.sourceText;
var hexColor = hexColorSource.value.toString();
hexToRgb(hexColor)

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 ,
Apr 11, 2023 Apr 11, 2023

Copy link to clipboard

Copied

You just need to make sure you get the value of the sourceText:

var hexColor = thisComp.layer("TextLayer").text.sourceText.value;
hexToRgb(hexColor)

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
Explorer ,
Apr 12, 2023 Apr 12, 2023

Copy link to clipboard

Copied

LATEST

Great, even better, thanks! I've been told off for "verbose code" before. 😆

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