-
layer spacing
So I’ve asked this question a couple years ago, and unfortunately I only got one response and it didn’t quite work for what I was trying to do. At the time I just did a work around and made it work, but now I’m hoping someone can help me with it again.
First off, I’m not very good with after effects expressions, but I do love the idea of being able to build little systems with them, so I spend a lot of time with trial and error and usually I’m able to figure things out, but this has got me stumped.
its basically a bar graph setup. My setup is 2 null object called “TR” & “BL” that defines the top left and bottom right area my layers stay in. Each bar layer is named “bar 1, bar 2, bar 3, etc…). Currently I can add any number of bars and they all stay within that area with even spacing between each, centered within the box. I would like to be able to add additional spacing between every 3rd, 4th or 5th… bar using a slider control. basically I would want to add two sliders one that defines how many bars should be in a group and one that adds this additional spacing.
I figured I needed to use the modulus operator in some way and probably a for loop to add the spacing to each layer, but honestly I’m completely stuck. The last time I posted this question the solution was to name the layers differently but that kind of defeats the purpose. the expression below is what I currently have on all my layers x position. Also maybe there is a more efficient/better way to do what I’m doing, but this is currently working for me. I’m pretty sure I have way too many parenthesis as well, but I haven’t cleaned it up yet.
Thanks in advance
Brian Holzknecht
barNum = thisLayer.name.split("bar ")[1];
barTot= Math.floor(thisComp.layer("Layout").effect("number bars")("Slider"));
boxTR = thisComp.layer("TR").transform.position;
boxBL = thisComp.layer("BL").transform.position;
boxWidth = boxTR[0] - boxBL[0];
barWidth = thisComp.layer("Layout").effect("bar width")("Slider");
newSpace = boxWidth / (barTot-1);(boxTR[0] + boxBL[0]) /2 + barNum*(newSpace-(barWidth/(barTot-1))) - (newSpace+(boxWidth*.5))+((barWidth/2)+(barWidth/(barTot-1)))