ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mike O'Connor
Writing an Expression to set a specific set of colors to a slider
on Jan 17, 2019 at 1:47:32 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.


Return to posts index

Dan Ebberts
Re: Writing an Expression to set a specific set of colors to a slider
on Jan 17, 2019 at 6:15:48 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



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]