Forums › Adobe After Effects Expressions › Changing specific keyframe that holds color value using expressions
-
Changing specific keyframe that holds color value using expressions
-
Ivan de Wolf
July 20, 2022 at 3:31 pmHi! I have been trying to adjust a keyframe in an animation that holds specifically a color value, so I can control that color state via a controller of some sort. I know there are ways to manipulate key values using the ‘linear()’ function, but somehow it doesn’t work on color values…Probably because the value type is not something that can be scaled? The error I get is: “ERROR: Argument 1 to linear() must be scalar”
Here is my current code:
t1 = key(1).value;
t2 = key(2).value;
v1 = 0;
v2 = hexToRgb(“739C8A”);
linear(value,t1,t2,v1,v2); <—- This part doesn’t work!
}else value
Any help would be much appreciated! Thank you!!!
-
Dan Ebberts
July 20, 2022 at 3:47 pmI think you’d want to set it up like this:
t1 = key(1).time;
t2 = key(2).time;
v1 = hexToRgb("0");
v2 = hexToRgb("739c8a");
linear(time,t1,t2,v1,v2) -
Michael Mathes
August 2, 2022 at 11:49 pmThe scalar error you’re getting is because your v1 variable is only supplying 1 value when it needs 4 for a color value. So you could also use [0,0,0,0] as your v1 value. I’ve run into this issue enough times that I thought it might be helpful to share what the error means.
Log in to reply.