Hi, I'm struggling with what I think could have an easy solution.
I have linked my project to a spreadsheet to enter the Artist, Featuring and Title. The featuring needs to be in the thin font style while the artist needs to be in the regular font style. Hence why I need to use two seperate layers. See example below:
This is the result I'm trying to make responsive.
The problem is that I want these two layers to be centered as a group. I know how to align the featuring to the artist text, but I can't seem to center the two to the comp width. When there is no featuring, the Artist name need to be centered.
It needs to be responsive as the input data changes with every track.
I hope somebody can help me 🙂
There's literally hundreds of tutorials on using sourceRectAtTime() to align and resize things and just typing this as a search term in your web browser will bring them up.
I've already looked at a lot of these tutorials. I know how to align and size object using those expressions but can't figure out how to center two object next to each other to the entire comp size.
You could probably use an expression but that could get annoying. Check this out: https://creativecow.net/forums/thread/align-two-layers-across-comp/ You can use a null layer and parent your layers to that.
When testing around, I also found that just simply using different alignments in the Paragraph panel could work for you. Let me know if this helps with your problem!
The comp is just a third value that needs to be considered, so I'm not sure what you are really having issues with. Could be as trivial as subtracting thisComp.width*0.5 somewhere.
Copy link to clipboard
The most efficient way to line up text layers is to use the sourceRectAtTime() function in an expression on the position property of the first two text layers. The Anchor Point of a text layer combined with the height, top, left, and width values can be combined with the layer's position and even scale to tell you exactly where the text layer is in the comp frame and how big it is. All that is left is a little math.
I. would stack all text layers on top of each other in order, with the top layer being the first layer, then use the layer index instead of the layer names to line up all of the layers and set the horizontal and vertical padding between words. With your design, the bottom line would be the master layer, so it would not have any expressions, and the other two layers would be offset by the bottom layer's height and centered above it by their combined width.
If the first two layers are left-justified and the bottom layer is center-justified, these expressions should work:
// apply to the first text layer layer position property secondTxt = thisComp.layer(index + 1); sSize = secondTxt.sourceRectAtTime(); vPad = - 50; p = secondTxt.position; s = secondTxt.scale * .01; t = sSize.top * s; h = sSize.height * s; w = sSize.width * s; l = sSize.left * s; src=thisLayer.sourceRectAtTime(); srcS = scale * .01; srcT = src.top * srcS; srcH = src.height * srcS; srcW = src.width * srcS; srcL = src.left * srcS; x = p + l + w - srcL - srcW - w + vPad; y = p + t + h - srcT - srcH; [x, y] // apply to the second text layer position property firstTxt = thisComp.layer(index - 1); sSize = firstTxt.sourceRectAtTime(); vPad = - 50; hPad = - 50; p = firstTxt.position; s = firstTxt.scale * .01; w = sSize.width + sSize.left; h = sSize.height + sSize.top; srcSize = thisLayer.sourceRectAtTime(); srcScale = scale * .01; srcWidth = srcSize.width - srcSize.left; cntrOfst = vPad + srcWidth + w - thisComp.width; thirdTxt = thisComp.layer(index + 1) mstrPos = thirdTxt.position; mScale = thirdTxt.scale * .01; mSize = thirdTxt.sourceRectAtTime(); mt = mSize.top; x = mstrPos - (srcWidth - w) / 2; y = mstrPos + mt + vPad; [x, y]
Save those position expressions as animation presets, and you can apply them to any set of text layers. All you have to do is animate the position of the third layer in the stack.
I didn't take the time to fully optimize the expressions for scale, baseline shift, and paragraph justification. If I get time later, I'll do that.
I have also included a project file for you to fiddle examine.
Much appreciated, thank you so much for taking the time to help me!
The only issue I still find is that the Artist text isn't centered when there is no featuring. I'm going to examine the code and fiddle around, but any help with this would be appreciated very much 🙂
I had this issue, if there is no featuring you could use a simple if then statement to ignore that position and have it center itself
Helps a lot. Thanks!
Thanks for welcome me
here are 2 projects. one with messy math, the other i think i managed to have a slider for your gap between the 2 texts, there is also a rcenter on the artist in case you dont use the featuring layer
This was so incredibly helpful for me, thank you so much!