Distribute lines evenly based on gap instead of position
- November 22, 2024
- 1 reply
- 1159 views
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:
- No change
- 35px up (10pt weight increase * [7 middle layers/2] )
- 60px up (35 from the previous increase + 25)
- 75px up (60 from the previous increase + 15)
- 80px up (75 from the previous increase + 5)
- 75px up (80 - 5)
- 60px up (75 - 15)
- 35px up (60 - 25)
- No change (also 35 - 35)
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?
