-
A for loop inside an if statement inside a for loop = confusion
I’m trying to set up an expression that will allow me to place a bunch of layers in a grid, like tiles across the frame. I want the edges of the layers to touch. I’m assuming that I’m working with a 16:9 frame and all the layers are also 16:9.
Apparently i’m going about this the wrong way, but I can’t figure out why this expression isn’t working. I’m sure it has to do with the fact that I’m not very confident with my Javascript skills.
Any suggestions?
*edit* The following expression gives me this:

The first row works fine, after that each “row” starts cascading diagonally, stacking on top of each other in groups of 5.
x=width*transform.scale[0]/200;
y=height*transform.scale[0]/200;
xOffset = 0;
yOffset = 0;
tilesPerRow = 5;for (i=0; i<=tilesPerRow; i++){ if (thisLayer.index/tilesPerRow > i && thisLayer.index/tilesPerRow <= i+1){ for(j=i*tilesPerRow+1; j
0){
yOffset += thisComp.layer(i).height*thisComp.layer(i).transform.scale[1]/100;
}
}
}
}[x+xOffset,y+yOffset]