Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions comparing 4 values?

  • Dan Ebberts

    August 28, 2010 at 2:35 am

    It really depends on exactly what you’re trying to do. JavaScript provides a number of options. Can you give an example of how you would use this?

    Dan

  • Erin Shelby

    August 29, 2010 at 12:22 am

    Yes, basically I have four values on 4 different expression sliders. They will constantly be differing values, but depending on which value is the highest I want a text layer to be a certain color. So (in pseudo code) ideally it would be something like:

    if
    x is highest = make this text layer green
    y is highest = make this text layer yellow
    z is highest = make this text layer blue
    w is highest = make this text layer red

    Filip’s code works for two values, but four is a bit more perplexing. Do i have to nestle the statements?

    Also, I am not sure how to determine the colors exact values using the odd [1,1,1,0] format of after effects. I have the RGB values, is the conversion just divided by 255?

    Thanks for all your help thus far.

    Erin.

  • Dan Ebberts

    August 29, 2010 at 1:01 am

    There must be a simpler way to do this, but this seems to work:


    if (x >= y && x >= z && x >= w){
    c = [0,255,0,255];
    }else if (y >= x && y >= x && y >= w){
    c = [255,255,0,255];
    }else if (z >= x && z >= y && z >= w){
    c = [0,0,255,255];
    }else{
    c = [255,0,0,255];
    }
    c/255;

    Dan

  • Dan Ebberts

    August 29, 2010 at 9:10 am

    I like this better:


    t1 = Math.max(x,y);
    c1 = x > y ? [0,255,0,255] : [255,255,0,255];
    t2 = Math.max(z,w);
    c2 = z > w ? [0,0,255,255] : [255,0,0,255];
    t1 > t2? c1/255 : c2/255

    Dan

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