Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Color Fill Text based on a number.

  • Color Fill Text based on a number.

    Posted by Alexandru Graur on March 23, 2022 at 12:21 pm

    Hello.

    I am working on a project and I need some help.

    I created a master comp with all the elements I need. I linked the master comp to a .json file and each time i change something in the .json the project is updating. Everything fine and perfect but I am looking for a way to change the fill color for the temperature based on a number (like in the picture i attached). Let’s say you want -20 to be blue, 0 to be white and 40 to be orange.

    So each time I update the json file with a new temerature the fill should change to the asign color.

    Thanks!

    Alex

    Chris Voelz replied 4 years, 5 months ago 2 Members · 4 Replies
  • 4 Replies
  • Chris Voelz

    March 23, 2022 at 3:21 pm

    You can use the text source to control an if else statement. Add an Animate Fill Color property and add an expression to that to control the color. You can use an array to change the color of the property. One thing to note is that the array is RGBA and the values have to be between 0-1. So to find the value for each channel just divide the number by 255.

    For example an orange color with a hex of EEA031 or RGB value of 238, 160, 49 would be [0.93, 0.63, 0.19, 1]. So you could set your color values in an expression and reference them using an if/else statement.

    txt = thisLayer.text.sourceText.value; //this is your text layer
    blue = [0,0,1,1];
    white = [1,1,1,1];
    orange = [0.93, 0.63, 0.19, 1];
    if (txt <= -20){blue}
    else if (txt > -20 & txt <= 39) {white}
    else {orange}

    You can change the values in the if/else to control at which point the color switch happens or add more colors.

  • Alexandru Graur

    March 24, 2022 at 7:32 pm

    Hello Chris

    Thank you very much for the help.

    Just curious… is there a way to get a smooth gradient color from blue to white and then to orange?

    Thanks!

    Alex

  • Alexandru Graur

    March 24, 2022 at 7:54 pm

    I manage to find something but I don’t know how to apply it:

    Using data from a csv, each frame returns a different color. The difference is that I don’t want the frame to be the reference of my gradient.

    This is the expression that I am talking:

    To slider ->

    var compTime = compToFrames (time);

    Footage(“Data.csv”).dataValue([0,compTime])

    To fill ->

    var slider = effect(“Data”)(“Slider”);

    var c1 = effect(“Color 1”)(“Color”);

    var c2 = effect(“Color 2”)(“Color”);

    var c3 = effect(“Color 3”)(“Color”);

    If (slider < -20) {

    ease(slider, -20, 0, c1, c2)

    }

    else {

    ease(slider, 0, 50, c2, c3)

    }

  • Chris Voelz

    March 25, 2022 at 1:49 pm

    in the Fill Color

    var temp = text.sourceText.value;

    var c1 = [0,0,1,1];

    var c2 = [1,1,1,1];

    var c3 = [0.93, 0.63, 0.19, 1];

    if (temp < 0) {

    ease(temp, -20, 0, c1, c2);

    }

    else {

    ease(temp, 0, 40, c2, c3);

    }

    You can change the colors based on what I said above. The first “if” statement is your middle value. So when it drops below 0 it will transition between white and blue. If it is above 0 it will transition between white and orange. The first ease value is between your middle and lower color value and the second is between middle and higher value.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy