Flicker Opacity Expression
//FLICKER OPACITY blinkSpeed =10; n = Math.sin(time*blinkSpeed); if (n<=0) 0 else 100;
This After Effects expression is intended to create a flickering effect by adjusting the opacity of a layer over time. Here’s how it works:
- Variable Setup:
blinkSpeed = 10;
: This variable sets the speed of the flicker effect. Higher values will make the flickering faster.
- Sine Wave Calculation:
n = Math.sin(time * blinkSpeed);
: This line calculates a valuen
using the sine function (Math.sin()
).time
represents the current time in the composition, andblinkSpeed
determines how quickly the flicker occurs.- The sine function produces values between -1 and 1, oscillating over time. This will create a smooth flickering effect.
- Opacity Adjustment:
if (n <= 0) 0 else 100;
: This conditional statement adjusts the opacity of the layer based on the value ofn
.- If
n
is less than or equal to 0 (indicating the trough of the sine wave, where the opacity should be lowest), the opacity is set to 0. - Otherwise, if
n
is positive (indicating the crest of the sine wave, where the opacity should be highest), the opacity is set to 100.
- If
- Explanation:
- When the sine wave of
n
is at its lowest point (0 or negative), the opacity of the layer is set to 0, creating the flicker effect by making the layer briefly invisible. - As the sine wave rises and falls over time, the opacity alternates between 0 and 100, causing the layer to flicker on and off at the specified speed determined by
blinkSpeed
.
- When the sine wave of
In summary, this expression creates a flickering effect by modulating the opacity of a layer based on a sine wave, resulting in a smooth and rhythmic transition between visible and invisible states. Adjusting the blinkSpeed
variable will change the speed of the flickering effect.
Leave a Reply
Want to join the discussion?Feel free to contribute!