Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions change color according to value

  • change color according to value

    Posted by Ido Shor on July 31, 2016 at 11:07 am

    Hey.

    I want to make an expression for a randomly changing number, (so far so good), but each time it will change a value, I want it to change color relatively to the previous value it had. MEANING… if it will goes up, then it will change to blue and if down then to orange (for example).

    one more thing. I want it to change value every few seconds and do it with a “hold interpolation” so it will jump to the next value instead of working it’s way toward it…

    hopefully I explained myself right…
    thanks!

    I.S.

    Ido Shor replied 9 years, 10 months ago 2 Members · 3 Replies
  • 3 Replies
  • Ido Shor

    August 3, 2016 at 10:58 am

    Ok…. I am probably way off here, because my knowledge in expression is almost limited to a Wiggle… 🙂

    but just to show you I am making an effort, and maybe sparkles an idea in one of your brilliant minds.. here goes a test I did:

    ————————————————————————————————————————————–

    upColor = thisComp.layer(“Ctrl”).effect(“Up Color”)(“Color”);
    downColor = thisComp.layer(“Ctrl”).effect(“Down Color”)(“Color”);
    value = thisComp.layer(“Ctrl”).effect(“Slider Control”)(“Slider”);
    prevframe = thisComp.layer(“Ctrl”).effect(“Slider Control”)(“Slider”).valueAtTime(time – thisComp.frameDuration);

    if(prevframe.valueAtTime < ((time * 25) % 2 == 0).valueAtTime))downColor else upColor;

    value;

    ————————————————————————————————————————————–

    And a screen capture of my comp attached.

    so… basically I am trying to get a value from a place that doesn’t has one… (linking the source of the text to a slider)

    any ideas how to solve this nut?

    tnxx, I.S

    10367_capture.jpg.zip

  • Hammers Nail

    August 3, 2016 at 9:35 pm

    Not sure if I understood what you wanted to achieve, but let’s say try to put this line in the Fill’s Color attribute

    UC = thisComp.layer("Ctrl").effect("Up Color")("Color");
    DC = thisComp.layer("Ctrl").effect("Down Color")("Color");
    S = thisComp.layer("Ctrl").effect("Slider Control")("Slider"); //determines how many times per-second the color will change
    if (1-Math.round(time*S)%2) UC else DC;

  • Ido Shor

    August 3, 2016 at 10:12 pm

    Hey Hammer, tnx, but it seems ur code is making the letters flash back and forth from one colour to the next.

    in the meantime, with the help of Xavier from Adobe forums we managed to achieve this code:

    ——————————————————————————————

    upColor = thisComp.layer(“Ctrl”).effect(“Up Color”)(“Color”);
    downColor = thisComp.layer(“Ctrl”).effect(“Down Color”)(“Color”);
    X = thisComp.layer(“Ctrl”).effect(“Slider Control”)(“Slider”);
    ta = time – thisComp.frameDuration;
    a = X.valueAtTime(ta);
    b = X.value;
    while (a===b && ta>=inPoint){
    b=a;
    ta -= thisComp.frameDuration;
    a = X.valueAtTime(ta);
    };
    if (b

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