Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Limiting index-driven values within range, and looping the overflow.

  • Limiting index-driven values within range, and looping the overflow.

    Posted by Christopher Rutherford on February 10, 2017 at 8:24 pm

    Hey all, trying to make a grid system using a bunch of 120px square shape layers. The x position is governed by the layer index. I was wondering how I’d be able to force the x positions to fall between -900 and 900, so that a value of 1020 would return -900, and 1140 would return -780 and so on.

    Ideally, each cycle would output a value that can be used to affect the Y position. But my priority is figuring out the X position.

    I vaguely recall seeing an expression that fit the bill, long ago, but “loop” and “cycle” aren’t the best search terms.

    x =-900+120*(index-1);
    y = value[1];
    [x,y]

    Christopher Rutherford replied 9 years, 6 months ago 1 Member · 1 Reply
  • 1 Reply
  • Christopher Rutherford

    February 10, 2017 at 11:43 pm

    Figured it out. Just used the modulus operator (%). Used the ratio of the base x value and the cycled x value to determine the y.

    xbase = 60+120*(index-1);
    x =60+120*(index-1)%1920;
    y = 60+((xbase-x)/1920)*120;

    [x,y]

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