-
Position any number of layers between two others
Hi, this is my first attempt to write an expression, i would like to get suggestions on how to improve it..
I’ve found in AE help the expression to maintain one layer at a balanced distance between two other layers and i wanted it to work for any number of layers:
x2 = thisComp.layer(“extr2”).transform.position[0];
y2= thisComp.layer(“extr2”).transform.position[1];
pos2 = thisComp.layer(“extr2”).transform.position;
x1= thisComp.layer(“extr1”).transform.position[0];
y1= thisComp.layer(“extr1”).transform.position[1];
pos1= thisComp.layer(“extr1”).transform.position;if (x1 >= x2&&y1 >= y2){ (((pos1-pos2)*(index-1))/(thisComp.numLayers-2)+pos2)
}else{
if (x1 < x2&&y1 >= y2){ [(((x2-x1)*(index-1))/(thisComp.numLayers-2)+x1),(y1-((y1-y2)*(index-1))/(thisComp.numLayers-2))]
}else{
if (x1 < x2&&y1 < y2){ [(((x2-x1)*(index-1))/(thisComp.numLayers-2)+x1),(((y2-y1)*(index-1))/(thisComp.numLayers-2)+y1)] }else{ if (x1 > x2&&y1 < y2){ [(((x1-x2)*(index-1))/(thisComp.numLayers-2)+x2),(y2-((y2-y1)*(index-1))/(thisComp.numLayers-2))] } } } }This expression is for the position of the layers between the two layers(“extr2” and “extr1”).
You can download the comp here:https://rapidshare.com/files/234297399/equidistanza_2_layer.aep.zip
I will really appreciate any tip 🙂