Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Color and Position

  • Color and Position

    Posted by Nikola Morin on November 15, 2012 at 2:38 pm

    Hi everyones

    how can i link a color to a position?

    What I want is:

    if my arrow layer is between for example 100 and 200 on the X axis i would like affect the colors of my red solid who’s having a Fill effect on.

    The color between 100 and 200 is blue.
    So how should I write my expression to tell to the color fill effect of my red solid to become blue when the arrow is between 100 and 200 on x axis???

    am i enough clear???
    Thank you!!!!

    Nikola Morin replied 11 years, 3 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    November 15, 2012 at 3:41 pm

    It will be something like this:


    arrow = thisComp.layer("arrow");
    p = arrow.transform.position;
    if (p[0] > 100 && p[0] < 200)
    [0,0,1,1]
    else
    value

    Color values are four-element arrays (RGBA) with values between 0 and 1, so solid blue would be [0,0,1,1].

    Dan

  • Nikola Morin

    November 15, 2012 at 3:55 pm

    How Come it becomes so simple when you explain this??
    Thank you again Dan that work perfectly!
    i knew about the four-element in the array, it was moe how to write this. when a tell it in my head it’s really simple, but it’s writting the langage who’s not simple!!

    Thank you and have a nice day!

  • Nikola Morin

    November 15, 2012 at 4:27 pm

    What happen if i have multiple condition?

    the expression was:

    arrow = thisComp.layer(“arrow”);
    p = arrow.transform.position;
    if (p[0] > 100 && p[0] < 200)
    [0,0,1,1]
    else
    value

    but if i have something between another color between 250 and 350 pixel on the x axis? ond still another color between 400 and 500
    ?
    How should write with multiple condition??
    Thank you!!

  • Dan Ebberts

    November 15, 2012 at 4:32 pm

    You could do it like this:


    arrow = thisComp.layer("arrow");
    p = arrow.transform.position;
    if (p[0] > 100 && p[0] < 200)
    [0,0,1,1]
    else if (p[0] > 250 && p[0] < 350)
    [0,1,0,1]
    else if (p[0] > 400 && p[0] < 500)
    [1,1,0,1]
    else
    value

    Dan

  • Nikola Morin

    November 15, 2012 at 4:35 pm

    thank you!!! work perfectly!!

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