Video updated: 29 November 2018
Video 5 of the Controllers & Expressions Series:
Angie’s blushing cheeks, part 2 of 2
Starting from where I left off in the previous video, I’m going to connect the blush control to the opacity property. This will require a couple of linear( ) statements as well as an if/else expression, which is a conditional expression that I will introduce in this video.
Code from the video
The code below is provided as a reference, and was copied directly from the video After Effects file. Expression fields that contained only a pick whip connection are not included.
Clamp expression for the controller handle
clamp(transform.position,[-100,0],[100,0])
Expression that connects controller handle to opacity property
DB=thisComp.layer("Blush Control Handle").effect("Default Blush Opacity")("Slider"); //DB - Default Blush opacity BC=thisComp.layer("Blush Control Handle").transform.position[0]; //BC - Blush Control handle if(BC>=0){ Tr=linear(BC,0,100,DB,100); }else{ Tr=linear(BC,-100,0,0,DB); } Tr
Adding scale to your Blush Control
As mentioned in the video, your blush effect can be improved a great deal by adding an expression to the scale property. Here are the steps:
- Pick whip the scale property of the R Blush layer to the scale property of the L Blush layer (just as we did with the opacity property).
- Option left-click (Windows: Alt left-click) the R Blush layer’s scale property stopwatch and paste the code below into the expression field.
NOTE: The code will only work if you used the same layer name for the controller handle as I did in the video. You can, of course, replace the handle layer name by deleting it in the code and using the pick whip to replace it.
BC=thisComp.layer("Blush Control Handle").transform.position[0]; //BC - Blush Control handle if(BC>=0){ Sc=linear(BC,0,100,[100,100],[200,200]); }else{ Sc=linear(BC,-100,0,[50,50],[100,100]); } Sc
This expression dumps the Default Blush Opacity line, as it’s not needed here, but keeps the Blush Control variable. The if/else conditional statements are based on the same code as the opacity expression. The only thing that’s changed, besides the variable name, is the last two values in each linear( ) expression.
Remember that scale, when working in two dimensions, is a two-value array, so when the Blush Control is at 0 the scale value will be [100,100]. I selected the scale [200,200] when the Blush Control is at 100, but that value can be easily adjusted to fit your own taste. Likewise, when the Blush Control is at -100 the scale value will be [50,50], which can be change.