Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Color if expression

  • Color if expression

    Posted by Alexander Weil on November 23, 2016 at 5:17 pm

    hey
    is there any way i can control the color with an if expression? it has to check that the value color is for example Blue, if that is true it has to change to a color i defined with a color controller, but if it is not it should use the value color
    here is what i tried but it did not yet work:


    cColor = effect("check Color")("Color"); //the color it should check
    gColor = effect("Global Color")("Color"); //the color it should be if its the checked color
    vColor = effect("Wales")("Color"); //the value color

    if (vColor == cColor){
    gColor
    }else{
    vColor
    }

    Alexander Weil replied 9 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Yahor Hayeuski

    November 24, 2016 at 3:18 pm

    Hi!
    Color in AE is an array [red, green, blue, alpha]. And you can’t compare two arrays using “==”. More info here. Instead of this you need to check every value in array separately. Also you don’t need to check alpha value (the last value (id = 3) in array). So this code should work for you:

    cColor = effect("check Color")("Color"); //the color it should check
    gColor = effect("Global Color")("Color"); //the color it should be if its the checked color
    vColor = effect("Wales")("Color"); //the value color

    if ((vColor[0] == cColor[0]) &&
    (vColor[1] == cColor[1]) &&
    (vColor[2] == cColor[2])){
    gColor
    }else{
    vColor
    }

  • Alexander Weil

    November 24, 2016 at 9:40 pm

    thanks a lot, i already thought something like that but im not yet very deep into expressions.

    thanks and have a nice day 🙂

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