Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Writing an Expression to set a specific set of colors to a slider

  • Writing an Expression to set a specific set of colors to a slider

    Posted by Mike O’connor on January 17, 2019 at 1:47 pm

    Hi All!

    I’m trying to make lower thirds that can be changed to colors from a specific color palette through a slider. For example if there were ten colors, the slider would be clamped to 1-10. And each number on the slider would correspond to a specific color number, example color #149bf4 (light blue) is always 1, color #2decdb (cyan) is always 2, etc. What would an expression for that look like? My gut says setting a color value to some sort of position value, but I can wrap my head around that completely.

    I’m trying to make this in after effects so I can have a fully customizable and on-brand lower third in essential graphics. I figured out the other parts such as adjustable text and automatic resizing, this would the last piece of the puzzle.

    Any help would be much appreciated.

    Dan Ebberts replied 7 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    January 17, 2019 at 6:15 pm

    Something like this, probably:


    function hexToRGBA(theHex){
    var r = theHex >> 16;
    var g = (theHex & 0x00ff00) >> 8;
    var b = theHex & 0xff;
    return [r/255,g/255,b/255,1];
    }
    s = Math.round(effect("Slider Control")("Slider"));
    colors = [0x149bf4,0x2decdb];
    idx = clamp(s-1,0,colors.length-1);
    c = colors[idx];
    hexToRGBA(c)

    Dan

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