Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change layer color using text

  • Change layer color using text

    Posted by Asaf Lazarovich on April 26, 2018 at 2:58 pm

    Hi, so I need to change a layer’s color using the fill effect, but I need to get the color data as a text from a spreadsheet.
    I have Layer1 which is a text layer
    and Layer2 which I want it’s source text (for example: 1E29FF) to be used by Layer1’s fill effect to determine Layer1’s color
    is that possible?
    thank you!

    Dan Ebberts replied 3 years, 3 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    April 26, 2018 at 4:46 pm

    If Layer2 has the text for a hex number, I think something like this would work:

    txt = thisComp.layer(“Layer2”).text.sourceText;
    hex = parseInt(txt,16);
    r = hex >> 16;
    g = (hex & 0x00ff00) >> 8;
    b = hex & 0xff;
    [r/255,g/255,b/255,1]

    Dan

  • Asaf Lazarovich

    April 26, 2018 at 6:42 pm

    works perfectly, thanks so much Dan

  • Ian Ball

    April 11, 2023 at 2:09 pm

    Hello, I am trying to do this exact same thing but I cannot get it to work. I am pasting this code into the effects > fill > color property and my text layer is called “Layer2” – the error is “invalid or unexpected token” – Any advice greatly appreciated. Thanks!

  • Dan Ebberts

    April 11, 2023 at 3:42 pm

    This should be all you need:

    c = thisComp.layer("Layer2").text.sourceText.value;
    hexToRgb(c)

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