Activity › Forums › Adobe After Effects Expressions › if this then that random color expression
-
if this then that random color expression
Posted by Andrew Blake on August 23, 2018 at 8:27 amIn after effects I want to change the color value in an effect when the keyframe of another layer = 1, preferably with easy ease out. if else, I would like the color to stay the same.
I have attached the code that I have so far (that I dont even know if it works).thanks in advance.
if(thisComp.layer("Soundkeys").effect("Sound Keys")("Output 1")==1) effect("Saber")("Glow Color")Dan Ebberts replied 8 years, 1 month ago 3 Members · 5 Replies -
5 Replies
-
Kalleheikki Kannisto
August 24, 2018 at 9:44 amThe expression would go in the color value, so you need to set the color to another color. The easy way would be to pick it from another color value. Since you want an ease, you would have to calculate a percentage between two color value depending on how close the Soundkeys output is to 1. So if you wanted it to ease from 0.8 to 1, you’d calculate the mix using those two points as the 0-100 scale.
Another option is to animate the hue/saturation effect so that the color gets changed through effect strength. Or perhaps VCP Color Vibrance as an effect, that has the same color logic as Sabre, I believe.
Kalleheikki Kannisto
Senior Graphic Designer -
Andrew Blake
August 25, 2018 at 3:43 amI have the expression in the colour value of saber, I could have it cycle through predetermined colours, but I don’t know how to that either.
I have soundkeys set to on/off trigger as that’s the most appropriate for what I’m trying to achieve, and I meant ease between colours. -
Kalleheikki Kannisto
August 25, 2018 at 2:38 pmLet’s start with the simple case. If you make a shape layer with a shape that has the color you want the effect to change to, then you should be able to do the following for saber color value. (I don’t have saber installed on the computer I’m at so can’t verify this.)
thisColor = *pick whip saber color here*;
otherColor = *pick whip shape layer shape color here*;
input = *pick whip soundkeys output here* ;
(input==0)?thisColor:otherColorThis should give you the original color when value is 0 and the new color when value is 1. If you want a random color, you could wiggle the color value of the shape.
Kalleheikki Kannisto
Senior Graphic Designer -
Andrew Blake
August 27, 2018 at 8:04 amI would like to get the shape to cycle colours, perhaps from red green and blue, I tried colorama, and it worked fine until I tried to do if soundkeys = 1, +120 else +0 in the phase shift tab, it would go to 120 on the beat, but would then go back to 0 after soundkeys went back to 0.
-
Dan Ebberts
August 27, 2018 at 3:31 pmIt sounds like you may not be aware that expressions have no memory, and no access to results calculated on previous frames. If your result depends on events that happened in the past, your expression will have to go look for them by looping back in time, frame-by-frame, using valueAtTime() to find the triggering events. In your case it sounds like your expression would have to find the number of times the SoundKeys value went from less than 1 to 1 and then either use that number as in index into a color table, or multiply it by some value for Colorama, etc.
Dan
Reply to this Discussion! Login or Sign Up