Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Turn on/off layer opacity with specific color value

  • Turn on/off layer opacity with specific color value

    Posted by Itay Bartal on January 27, 2021 at 5:16 pm

    Hi,

    The layer opacity is linked to a Color Control.

    I want to turn on to 100 the opacity when I get the color value: [0.973,0.831,0.055,1]

    and if I get other color value I want to turn off the opacity to 0.

    This is what I tried but didn’t work:

    yellow_color = [0.973,0.831,0.055,1];

    if (comp(“_FF_Dark_01”).layer(“CHANGE_COLOR_HERE”).effect(“Color Control”)(“Color”) == yellow_color) {100} else {0}

    THANKS

    Itay Bartal replied 5 years, 7 months ago 3 Members · 3 Replies
  • 3 Replies
  • Kevin Camp

    January 28, 2021 at 6:43 pm

    try just one = (equal sign). I think since it is a numerical value comparison, it should just be one equal.

  • Dan Ebberts

    January 28, 2021 at 8:37 pm

    Colors are arrays, so I think you need to check them element by element. Also, floating point values may not match exactly, so I think I’d include a “close enough” tolerance. Something like this:

    tolerance = .001;

    yellow_color = [0.973,0.831,0.055,1];

    function compareColors(color1,color2,theTolerance){

    for (i = 0; i < color1.length; i++){

    if (Math.abs(color1[i] - color2[i]) > theTolerance) return false;

    }

    return true;

    }

    color = comp("_FF_Dark_01").layer("CHANGE_COLOR_HERE").effect("Color Control")("Color").value;

    compareColors(yellow_color, color, tolerance) ? 100 : 0

  • Itay Bartal

    January 29, 2021 at 6:47 am

    Like magic!

    THANKS DAN!

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