ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Change colour base on expression slider value

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andy Bryce
Change colour base on expression slider value
on Sep 9, 2016 at 4:02:29 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


Return to posts index

Dan Ebberts
Re: Change colour base on expression slider value
on Sep 9, 2016 at 5:02:05 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



Return to posts index

Andy Bryce
Re: Change colour base on expression slider value
on Sep 9, 2016 at 5:18:51 pm

Works perfectly thank you!

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


Return to posts index


Andy Bryce
Re: Change colour base on expression slider value
on Sep 9, 2016 at 5:48:32 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


Return to posts index

Dan Ebberts
Re: Change colour base on expression slider value
on Sep 9, 2016 at 6:07:47 pm

This should work:


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



Dan



Return to posts index

Andy Bryce
Re: Change colour base on expression slider value
on Sep 9, 2016 at 6:15:26 pm

You have really helped me out I am extremely gratefulT

Thank you!


Return to posts index


Dan Ebberts
Re: Change colour base on expression slider value
on Sep 9, 2016 at 5:53:20 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



Return to posts index

Ben Christie
Re: Change colour base on expression slider value
on Mar 28, 2019 at 10:44:23 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


Return to posts index

Dan Ebberts
Re: Change colour base on expression slider value
on Mar 29, 2019 at 12:07:18 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



Return to posts index

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