1

In After Effects, I created a shape layer, added a path to that, edited the expression of it to contain

var path = thisProperty;
var cx = 100;
var cy = 200;
var r1 = 300;
var ratio =  20;
var quality = 30;
var closedPath = true;
var allPoints = new Array();

for (var a = 0; a < 360; a++) {
    var theta = degreesToRadians(a);
    x0 = Math.cos(theta);
    x = cx + r1 * x0;
    y = cy + 0.75 * r1 * (Math.sin(theta) - Math.sqrt(Math.abs(x0)));
    allPoints.push([x,y]);
}
path.createPath(allPoints, [], [], closedPath);

and added a stroke and a fill to the shape layer and set the width of the stroke to 10 and the color of the fill to light red. I got this shape as a result.

heart

Now, I want to animate the end point of that stroke, you may see that I am looping the variable a from 0 to 360. That 360 value represents the end angle of the shape and I would like to have it animated to make an animation that "draws" the heart.

How do I animate the end value?

Is there a way to add a "dummy effect" so I can use it like

var a_max = effect("dummy")("endpoint")
0
2
  1. Press the triangle marked "Add" next to the Contents of your shape layer.
  2. Add a "trim path"
  3. Add a keyframe to the "End" parameter of 0%.
  4. Move along your timeline.
  5. Add another keyframe of 100%.

Your path will draw on. You probably don't want to fill it until it is drawn. grab

0

Tom's answer is a good way to do it, but if you're interested, to do it only in the expression, just add a couple of lines at the start like

myDuration = 5; // the duration of the animation in seconds
let completion = Math.min(time/myduration, 1)

and then in the for loop, substitute "360" with 360 * completion

for (var a = 0; a < (360 * completion); a++) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.