Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Needs of cycle or reset expression for an offset (Roughen Edges)

  • Needs of cycle or reset expression for an offset (Roughen Edges)

    Posted by Santiago Suarez on June 24, 2020 at 7:17 pm

    Hi, I have this scenario:

    I have a simple bar made with a box Shape layer. To get fancy i added a Rough Edges effect (RE).

    Then i animated the height of my box but the RE remains static, so no problem, i linked by expression the Y Offset of the RE to the height of the box, and works great, it gives the illusion of move accordingly to the growth of the bar.

    The problem came when i noticed that the RE has an offset limit of 32000 pixels, so when the height of the box exceed this amount (and it does by a lot), the RE stop moving, losing the illusion.

    So, my idea to solve it, is to get a kind of expression that reset the RE offset every time the height’s box gets 32000 or a multiple of it, and start from zero again but still linked to the growth of the bar. I think that this can still maintain the illusion of movement.

    So if you could help me with this expression or with another solution, i will apreciate.

    //code to link RE Offset to box height

    x = value[0];
    L = thisLayer;
    y = L.sourceRectAtTime(time-L.inPoint).height;

    [x,-y*5];

    Santiago Suarez replied 6 years, 1 month ago 2 Members · 4 Replies
  • 4 Replies
  • Andrei Popa

    June 25, 2020 at 7:23 am

    Try this:

    x = value[0];
    L = thisLayer;
    y = L.sourceRectAtTime(time-L.inPoint).height%32000;

    [x,-y*5];

    Andrei
    My Envato portfolio.

  • Santiago Suarez

    June 25, 2020 at 3:28 pm

    Hi Andrei, thank you for reply

    It worked really nice, i had to make a minor adjustment but the approach was pretty effective.

    If you don’t mind i would like to understand why this %32000 works, i’m not a very Code man, but i like to understand this simple concepts that probably would help me in the future.

    ///////The code you gave to me

    x = value[0];
    L = thisLayer;
    y = L.sourceRectAtTime(time-L.inPoint).height%32000;

    // Previously I multiplied the offset by 5 at the end
    [x,-y*5];

    ///////The code updated

    x = value[0];
    L = thisLayer;

    // I had to multiply by 5 before add %32000, other wise the offset get a little crazy
    y = (L.sourceRectAtTime(time-L.inPoint).height*5) %32000;

    [x,-y];

  • Andrei Popa

    June 25, 2020 at 3:33 pm

    It’s called modulo operator. It is what left when you divide it by that number.

    Eg: if you divide 5 by 2, it is 2 and 1 left. So 5%2 is 1.
    You use this operator when want to create a cycle. time%10 would start from zero to 10. Then the second it hits 10, starts from zero again. Because 10%10 is 0. And again at 20 and so on.

    Andrei
    My Envato portfolio.

  • Santiago Suarez

    June 26, 2020 at 3:40 am

    Thank you very much Andrei, for the solution and for the explanation.

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