Skip to main content
Participant
August 31, 2021
Question

Easing in Checkbox Control Effects

  • August 31, 2021
  • 2 replies
  • 290 views

I linked a color overlay with a Checkbox Control, so when it's On, the color is red, and when it's off, the color is grey. Is there any way to make the transition from Red to Grey eased?? Like, when it's On, it fades 0.5s after the keyframe, and when it's off, it fades 0.5s before the Off keyframe.

If there's an expression for that it'd really help me

This topic has been closed for replies.

2 replies

ShiveringCactus
Community Expert
Community Expert
September 1, 2021

Try this, it's based on code Dan Ebberts helped me with:

fadetime = 0.5;
dur = 2;
p = effect("Checkbox Control")("Checkbox");
grey = 'cccccc';
red = 'ff0000';
val = hexToRgb(grey);
if(p.numKeys > 0){
    n = p.nearestKey(time).index;
    if(p.key(n).time > time) {
	n--;
    }
	if (p == 1) {
		endCol = red;
		startCol = grey;
	} else {
		endCol = grey;
		startCol = red;
	}

    if(n > 0){
        t = p.key(n).time;
        val = linear(time, t, t+fadetime, hexToRgb(startCol), hexToRgb(endCol));
    } 
}
val

 

 

Mylenium
Legend
August 31, 2021

Not a matter of simply using a built-in function or canned expression. You still have to calculate the time backwards from your keyframe. For a single(!) keyframe on your layer this could be as trivial as

 

key(1).time-0.5

 

and then you pipe it into a linear() expression

 

linear(time,key(1).time-0.5,key(1).time,0,1)

 

which needs to be repeated for all three color channels. Things will however get infinitely more complicated if you need to toggle this multiple times on teh same layer. You would need to run it in a loop, check which keys are on and which ones are off and you may also need to have extra checks so the differnt fades don't overlap and get in teh way of each other. All that being the case, it would probably make more sense to keyframe the color directly or e.g. the opacity of a Fill effect or similar.

 

Mylenium