1

I am trying to create a heart shape using an expression like this:

  • Start AE
  • New Composition + Ok
  • Layer, new shape layer
  • Expand to get the contents node and click add Path
  • Path -> Edit expression

Then I paste this expression:

var path = thisProperty;
var allPoints = new Array();
for (var a = 0; a < 360; a++) {
  var theta = degreesToRadians(a);
  x0 = Math.cos(theta);
  x = 300 * x0;
  y = 0.75 * 300 * (Math.sin(theta) - Math.sqrt(Math.abs(x0)));
  allPoints.push([x,y]);
}
path.createPath(allPoints, [], [], true);

and I see this on the screen

heart shape

But this will only be visible in the designer. If the object is deselected, it will become invisible.

There is no way to control the stroke width, color or fill.

How can I control those properties?

I am trying to add a stroke alongside the path, but they will not "connect".

2
  • I get an error when I apply that expression to a path: "property labelled cx in class Global is missing or does not exist" – tomh Feb 15 at 17:00
  • I am sorry, removing some left over variables. Correcting the code. @tomh – Anders Lindén Feb 15 at 17:20
2

Apologies if I've misunderstood, but you can just click on the Add triangle, and add a fill or a stroke to your shape: screengrab

The modifiers in the "Add" menu are hierarchical - so you have to add them below the path's hierarchical level.

1
  • Can I add a variable that I can tween at the timeline as well? Acessible through the script. – Anders Lindén Feb 22 at 18:07

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.