Copy link to clipboard
Copied
I have a rig set up where I can have a stack of line layers all parented to a control layer which allows me to set the 'top' and 'bottom' layers of the stack and then have the middle layers linearlly interpolate the line shape, position, color, and stroke weight. This is nice because it allows me to create one shape layer, apply an effect preset, and then simply duplicate the layer to make the blended array. It works and looks great as long as the top and bottom lines are the same weight. If there is an increase, the spacing starts to look funny as it's just a linear distribution of each layer's position rather. What I'm trying to do is update the position calculation's expression to adjust for a difference in line thickness.
Using Illustrator and rectangles instead of lines, I've identified a pattern in the difference between a center-based distribution and a gap-based distribution. The difference in distribution increases at a predictable rate to the center of the layer stack and back down at the same rate, so the distribution would be the same regardless of whether the top or bottom stroke is thicker.
However, I cannot figure out how to translate the math I'm doing on paper to an Ae expression, but it's the type of thing that seems like there is a way to do it. The calculation is: 1/2 the number of center layers*weight increase for the first middle layer and then each subsequent layer is the previous increase value + the difference between that value and the prior one - the weight increase until the middle where it starts going back down.
I don't think I explained that well, so here is an example (also see attached image):
For a 9-layer stack where the top has a thickness of 10 and the bottom is 90 (an increase of 10pt between each layer), the gap-based distribution would be:
This pattern's calculation is the same regardless of the number of layers or the amount of the weight increase. But recognizing that pattern and getting the computer to calculate it are not the same thing.
I've been able to calculate the weight increase, what the gap should be, and how far away each layer's index is from the center of the stack. That feels like it should be enough to figure this out by moving the layer from its linear distribution, but it just isn't working.
Is there an easier way to do this?
Copy link to clipboard
Copied
The actual spacing is just the base spacing plus half the thickness of the start line of a segment and the same for the end line. The rest is just based on index-1 or index+1 type calculations, so I'm not sure what the problem is. You may just need to construct a loop to add up all values for any given index and you may also need to calculate those values first to determine what the real available free space in-between start and end is.
Mylenium
Copy link to clipboard
Copied
I've used the index+/- expression a bunch of times to get transform properties from other layers to use in calculations, but for some reason I keep getting an error with this one. (I don't recall the exact text of the error, but I do remember that it didn't seem to make sense).
Again, I've used thisComp.layer(index+1) or (index-1) a ton in the past and never had problems with it.
The strange thing is that the expression works just fine if I'm basing the spacing on one layer and then entering what I want the gap to be. The problem occurs when I want to space the layers out by changing the position of the top and bottom layer (instead of just adjusting what the gap is). For some unknown reason, the expression breaks when I have the gap as a calculated value instead of an entered value.
Copy link to clipboard
Copied
It would probably help if you shared the expression you're using.
Copy link to clipboard
Copied
That certainly would have helped - I apologize!
I ended up playing around with this more and eventually just rewrote the whole thing and now it's working fine. I'm still not 100% sure what the issue was originally because it looks about the same, but it was probably a missing letter or something that I kept missing.
Here is the working code I landed on. I am still a rookie when it comes to expressions and don't always do things the simplest way, so if anyone sees a way to simplify this, let me know. Otherwise, I can close this thread. Also, the reason I had separated the dimentions is because I wanted the x position to always be linear, since the lines are only up and down.
var posTOP = thisLayer.parent.effect("Path Blend CTRL")("Start Layer").transform.yPosition;
var posBOT = thisLayer.parent.effect("Path Blend CTRL")("End Layer").transform.yPosition;
var layerTOP = thisLayer.parent.effect("Path Blend CTRL")("Start Layer").index;
var layerBOT = thisLayer.parent.effect("Path Blend CTRL")("End Layer").index;
var gapS = thisLayer.parent.effect("Gap Spacing")("Checkbox");
var ref = (index == layerTOP) ? thisLayer : thisComp.layer(index-1);
var refPos = ref.transform.yPosition;
var refStroke = ref.content("Shape 1").content("Stroke 1").strokeWidth/2;
var gapDist = thisLayer.parent.effect("Gap")("Slider");
var thisStroke = thisLayer.content("Shape 1").content("Stroke 1").strokeWidth/2;
var gapSpace = refPos+(refStroke+gapDist+thisStroke);
var linSpace = linear(index,layerTOP,layerBOT,posTOP,posBOT);
(index == layerTOP || index == layerBOT) ? value : (gapS == 1) ? gapSpace : linSpace;