Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change colour base on expression slider value

  • Change colour base on expression slider value

    Posted by Andy Bryce on September 9, 2016 at 4:02 pm

    Hello All,

    I currently have a Radial Wipe connected to a number value. I have linked both of these up to an expression slider.

    This part works.

    I would now like to change the colour of the solid the radial wipe is revealing based on the number value.

    When the value is between 1 and 39 the color is red

    When the value gets to 40 the color changes from red to purple

    When the value gets to 70 the color from purple to green

    Alexandru Graur replied 4 years, 1 month ago 4 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    September 9, 2016 at 5:02 pm

    Assuming you’ve applied a Fill effect to your solid, something like this probably:


    s = thisComp.layer("controls").effect("Slider Control")("Slider");
    if (s < 40)
    [1,0,0,1]
    else if (s < 70)
    [.5,0,1,1]
    else
    [0,1,0,1]

    Dan

  • Andy Bryce

    September 9, 2016 at 5:18 pm

    Works perfectly thank you!

    How can I change the colour of each to a particular HEX colour code?

  • Andy Bryce

    September 9, 2016 at 5:48 pm

    One other question.

    Can I add an expression to a text layer to change text based of the value.

    From – critical – weak – strong

    Thanks in advance

  • Dan Ebberts

    September 9, 2016 at 5:53 pm

    This would be one way:


    s = thisComp.layer("controls").effect("Slider Control")("Slider");
    c1 = 0xff0000; // red
    c2 = 0x7f00ff; // purple
    c3 = 0x00ff00; // green
    function hexToFloat(c){
    r = ((c & 0xff0000) >> 16)/255;
    g = ((c & 0xff00) >> 8)/255;
    b = (c & 0xff)/255;
    return [r,g,b,1];
    }
    if (s < 40)
    hexToFloat(c1)
    else if (s < 70)
    hexToFloat(c2)
    else
    hexToFloat(c3)

    Dan

  • Dan Ebberts

    September 9, 2016 at 6:07 pm

    This should work:


    s = thisComp.layer("controls").effect("Slider Control")("Slider");
    if (s < 40)
    "critical"
    else if (s < 70)
    "weak"
    else
    "strong"

    Dan

  • Andy Bryce

    September 9, 2016 at 6:15 pm

    You have really helped me out I am extremely gratefulT

    Thank you!

  • Ben Christie

    March 28, 2019 at 10:44 pm

    Hi Dan,

    I know you gave this answer a long time ago but it has been extremely helpful.

    Wondering if you know any quick tips on how to make an actual transition between colors vs just immediately popping to the needed color?

    Thanks.

    Ben

  • Dan Ebberts

    March 29, 2019 at 12:07 am

    I guess it could be something like this:


    s = thisComp.layer("controls").effect("Slider Control")("Slider");
    c1 = 0xff0000; // red
    c2 = 0x7f00ff; // purple
    c3 = 0x00ff00; // green
    function hexToFloat(c){
    r = ((c & 0xff0000) >> 16)/255;
    g = ((c & 0xff00) >> 8)/255;
    b = (c & 0xff)/255;
    return [r,g,b,1];
    }
    if (s < 40){
    ease(s,0,40,hexToFloat(c1),hexToFloat(c2));
    }else{
    ease(s,40,70,hexToFloat(c2),hexToFloat(c3));
    }

    Dan

  • Alexandru Graur

    March 23, 2022 at 12:14 pm

    <yt-formatted-string slot=”content” split-lines=””>Hello. </yt-formatted-string>

    <yt-formatted-string slot=”content” split-lines=””>Quick question:</yt-formatted-string>

    <yt-formatted-string slot=”content” split-lines=””>Is there a way to change the fill color with expression based on a number? Let’s say you want -20 to be blue, 0 to be light yellow/white and 50 to be orange.</yt-formatted-string>

    <yt-formatted-string slot=”content” split-lines=””>Thanks.</yt-formatted-string>

    <ytd-button-renderer aria-expanded=”false” noink=”” use-keyboard-focused=”” button-renderer=”true”></ytd-button-renderer><ytd-button-renderer aria-expanded=”true” noink=”” use-keyboard-focused=”” button-renderer=”true”></ytd-button-renderer>

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