Gradual Sinusoidal Pulsating Scale Animation with Smooth Ramp-Up Starting at Keyframetitle

To create a sinusoidal pulsating effect that starts at a keyframe in After Effects, you can apply an expression to the Scale or Opacity (or any property you want to animate). The expression will use a sine wave to create the pulsating effect, and it will start the effect from a keyframe.

To make the pulsating effect start gradually from 100% scale (or whatever the base scale value is), we can introduce a smooth ramp-up to the sine wave. This will prevent the pulsation from starting immediately with full amplitude, allowing it to build up gradually. We can use an easing function for this purpose.

JavaScript
// Get the time of the first keyframe
var startTime = key(1).time;

// Set the pulsating speed (in cycles per second)
var frequency = 2; 

// Set the pulsating amplitude (maximum deviation from the base scale)
var amplitude = 20; 

// Set the base value (the scale at rest, without pulsating)
var baseScale = 100;

// Set how long the ramp-up period lasts (in seconds)
var rampUpDuration = 1; 

// If current time is before the keyframe, just use the base value
if (time < startTime) {
    value;
} else {
    // Time since the first keyframe
    var elapsedTime = time - startTime;
    
    // Smooth ramp-up factor (goes from 0 to 1 over rampUpDuration seconds)
    var rampFactor = ease(elapsedTime, 0, rampUpDuration, 0, 1);

    // Sinusoidal pulsating effect
    var pulsating = Math.sin(elapsedTime * frequency * 2 * Math.PI) * amplitude * rampFactor;

    // Add the pulsation to the base scale
    [baseScale + pulsating, baseScale + pulsating];
}
  • startTime: This gets the time of the first keyframe so the pulsation starts at that point.
  • frequency: This controls how fast the pulsation happens (in cycles per second).
  • amplitude: This sets how strong the pulsation is (e.g., how much the scale changes from its base value).
  • baseScale: The default size of the object (100% scale in this case).
  • Math.sin(): This function generates the sinusoidal oscillation. It multiplies by the frequency and the elapsed time to create the effect.

Notes:

  • This example assumes you are using the Scale property, with a starting value of [100, 100]. You can adjust baseScale, frequency, and amplitude to suit your needs.
  • If you want the pulsating effect to start from another keyframe, simply change the key(1) to the specific keyframe number.
  • rampUpDuration: This variable controls how long it takes for the pulsating effect to reach its full amplitude after the keyframe. You can adjust it based on how gradual you want the ramp-up to be.
  • rampFactor: This uses the ease() function to smoothly transition from 0 to 1 over the defined rampUpDuration. The pulsation starts at 0% strength and builds up to 100% strength over the ramp-up period.
  • The pulsating effect is multiplied by rampFactor, making it start at zero and gradually increase to full amplitude.

Now, the pulsating effect starts from 100% scale and smoothly increases its intensity over time. You can adjust the rampUpDuration and amplitude values to fine-tune the effect.

Leave a Reply

Your email address will not be published. Required fields are marked *