Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions can Math.round be used to round up to the next whole number?

  • can Math.round be used to round up to the next whole number?

    Posted by Thomas Horne on August 16, 2010 at 11:56 pm

    I’m making a grid, I want the layer order to determine place in the grid. I’m trying to write an expression that goes in the 2D position.

    The rows are 23 layers long.

    I want to use Math.round to round up, in order to assign rows and columns automatically by index.

    I’m really close, but don’t quite have it yet, can anyone help?

    q = Math.round(index/23);
    x = (index-(23*q))*315;
    y = 355*q+178;

    [x, y];

    Dan Ebberts replied 15 years, 9 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    August 17, 2010 at 1:31 am

    I’m not sure about the numbers, but this is how I lay out a 2D grid:

    origin = [0,178];
    numCols = 23;
    horizSpacing = 315;
    vertSpacing = 355;
    row = Math.floor((index-1)/numCols);
    col = (index-1)%numCols;
    origin + [col*horizSpacing, row*vertSpacing]

    Dan

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