Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression: Trim path percentage complete drive values

  • Filip Vandueren

    March 20, 2022 at 10:37 am

    Hi Eric,

    I’m sure you’re aware that the code in this form can only work for rectangular shapes, not for freeform polygons, But I think you are aware of this and you don’t mind the incorrect results if the nulls are not placed exactly.

    That being said, your logic for getting the length of individual sides in percentages from the ratios is not correct:

    //Ratio and total length

    var ratio = boxWidth/boxHeight;

    var totalLength = boxWidth*2 + boxHeight*2;

    var bottomEdge = ratio/2;

    var rightEdge = (1.0 – bottomEdge)/2

    For example a square would have ratio 1, so both bottom-edge and right-edge would be 0.25;

    while your code yields bottomEdge = 0.5 and rightEdge = 0.25

    But when the box-ratio is 2, your bottomEdge becomes 1 and your rightEdge = 0 instead of 2/3 and 1/3.

    so…

    leftEdgeRatio = boxHeight/totalLength; // rightEdge is equal

    bottomEdgeRatio = boxWidth/totalLength; // topEdge is equal

    for your corners, you would add the edges together, for example 3/4 corner = leftEdgeRatio+bottomEdgeRatio+rightEdgeRatio; or leftEdgeRatio*2 + bottomEdgeRatio; (or equivalently, 1-topEdgeRatio)

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy