FORUMS: list search recent posts

Color Array on Fill effect assigned to Slider

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Terje Lundgren
Color Array on Fill effect assigned to Slider
on Oct 22, 2015 at 1:04:13 pm

How do I get this to work?

if sliderValue is 0, color value in colors[0] is assigned to Fill -> Color.
if sliderValue is 1, color value in colors[1] is assigned, etc...

colors = [[0/255,0/255,0/255,255/255],[128255,128/255,129/255,255/255],[114/255,25/222,26/255,255/255],[12/255,62/255,0/255,255/255]]; //etc...
sliderValue = Math.floor(comp("mainComp").layer("COLOR_ADJUSTMENT").effect("Slider Control")("Slider"))).value;
value = colors[sliderValue];



/Terje


Return to posts index

Kalle Kannisto
Re: Color Array on Fill effect assigned to Slider
on Oct 22, 2015 at 1:23:34 pm

I think you just need to take the ".value" out at the end of the second line.


Return to posts index

Terje Lundgren
Re: Color Array on Fill effect assigned to Slider
on Oct 22, 2015 at 1:56:14 pm

Oh.. You are right. Thanks. There was a ")" too many in the code as well. Updated below in case someone wants to use it.

However, this expression is very picky and breaks if the sliderValue goes out of range.

Is there a way to prevent that?

colors = [[0/255,0/255,0/255,255/255],[128255,128/255,129/255,255/255],[114/255,25/222,26/255,255/255],[12/255,62/255,0/255,255/255]]; //etc...
sliderValue = Math.floor(comp("mainComp").layer("COLOR_ADJUSTMENT").effect("Slider Control")("Slider"));
value = colors[sliderValue];


/Terje


Return to posts index


Terje Lundgren
Re: Color Array on Fill effect assigned to Slider
on Oct 22, 2015 at 2:21:38 pm

no luck in preventing the expression to break with the code below.

value = colors[sliderValue];

if (sliderValue > colors.length)
value = [0/255,0/255,0/255,1]
if (sliderValue &lt; 0)
value = [0/255,0/255,0/255,1]


/Terje


Return to posts index

Terje Lundgren
Re: Color Array on Fill effect assigned to Slider
on Oct 22, 2015 at 2:28:41 pm

Found Dan's solution, which seems to work when applied to the slider!

linear(value,1,100,1,100)

/Terje


Return to posts index

Chris Scalzo
Re: Color Array on Fill effect assigned to Slider
on Oct 22, 2015 at 4:28:20 pm
Last Edited By Chris Scalzo on Oct 22, 2015 at 4:40:43 pm

Whenever I make templates like this I tend to use the Color Control expression control instead. Then on top of Hue, saturation and brightness controls; end users can use the dropper to select colors.


Return to posts index


Terje Lundgren
Re: Color Array on Fill effect assigned to Slider
on Oct 22, 2015 at 7:49:28 pm

Thanks for the input Chris. I agree the dropper is very convenient. Just a little bit more risky when you have to stick to a restricted palette.

/Terje


Return to posts index

Chris Scalzo
Re: Color Array on Fill effect assigned to Slider
on Oct 22, 2015 at 8:23:08 pm

That is exactly why I use the picker. We put guide layers with color palate for the appropriate show instead of a slider.


Return to posts index

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