Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Expressions - Double name strap with with BG layer that follows the lines of text in height

New Here ,
Oct 21, 2021 Oct 21, 2021

I am new to expressions but i need help with a double name strap and its lines of text and background. 

 

The strap is 14 seconds in duration and always animates to the second part at 7 seconds. I want the background to grown dynamically in height according to how many lines of text are put in with one or two lines of text in part one and part 2 (with some padding) . the double name super always animates in the same point of time and has a trasition, so  this may also need to be catered for . 

 

It is easy to accomplish if it was just one part. I have a shape layer (Boarder) which is the background image and 4 seperate lines of text .

 

I have the shape layer parented to a null object and currently have an expression in the nulls expression position.  My problem is i want an expression if possible, to cater for the lines of text in part one, but the the background to move dynamically at 7 seconds depending on the lines of text put into part 2 . Part 2 is where im stuck. 

 

I tried making a second null object and background layer but ideally i want it to work from the one background. 

 

My script so far is 

 

var message = comp("CTRL").layer("page").text.sourceText;

if (message == ""){
thisProperty = [0,0]
} else {
thisProperty = [0,-20]
}

 

 

TOPICS
Expressions , Scripting
300
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 21, 2021 Oct 21, 2021

I can't make sense of your description or your code snippet. then again it's evening around here and I'm kind of tapped out. Anyway, clearly you must be using otehr code fragments to actually make your BG scale rather than just move, so it would be more useful if you actually posted a screenshot and the full code. Technically functions like sourceRectAtTime() don't discriminate and really base their calculations on the layer content size, regardless how many lines your text has, so I'm not sure what you are having issues with.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 22, 2021 Oct 22, 2021

my code is atttached to the null position above and controls the x and y values depending if a text field is empty or not. Its straight forward but my problem as already descirbed above is doing this twice basically using the same background layer.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 29, 2021 Oct 29, 2021

If you only have one text layer and a shape layer behind the text, use this for the shape layer's size.

var paddingx = 10;
var paddingy = 10;
var x = thisComp.layer("asdfasdfasd asdfasfd").sourceRectAtTime(time).width + paddingx;
var y = thisComp.layer("asdfasdfasd asdfasfd").sourceRectAtTime(time).height + paddingy;
[x,y];


And use this for the text's anchorpoint so the anchorpoint remains in the center.

boxTop = thisLayer.sourceRectAtTime(time).top;
boxHeight = thisLayer.sourceRectAtTime(time).height;
boxLeft = thisLayer.sourceRectAtTime(time).left;
boxWidth = thisLayer.sourceRectAtTime(time).width;
[boxLeft + boxWidth/2, boxTop + boxHeight/2 ];


Let me know if it works! 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 31, 2021 Oct 31, 2021

Hi 🙂

 

Thanks For your valuable input its really helpful. I have tried your expression on the background image layer on its scale but its made it far to big on height (i know i will have to play around with it but so far i havent had much luck)

 

I also have two seperate text layers for part one and 2 text layers for part 2. I tried the expression on a text layer anchor point in part one and even though it moves it im not sure that this will work either. I basically just want to move the background layer up or down depending if one or two lines of text are used in part 1, then  i want the back ground layer to move again to the correct height for part 2, depending if one or two text layers are used for part 2 . The part 2 animation is always at 7 seconds. Any further input would be great 🙂 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 31, 2021 Oct 31, 2021

Oh. My example was for was for a text box shape behind the text. I thought that was what you needed.  Why don't you send me a copy of the file to see how's ur work flow like, so that I can better whip up something for you?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2021 Nov 01, 2021
LATEST

So you have one caption saying:

 

ShveringCactus

ACP

 

And after 7 seconds, a second caption appears alongside saying:

KJAE

New Here

 

So you want them both to appear on one layer with the background growing to accomodate them, something like:

ShveringCactus                          KJAE

ACP                                            New here

 

If that's the case, have you considered using a Pre-Comp with Essential Graphics properties?  You know the timings, you could have each text on its own layer and have the background respond to the two top lines with code like:

var message1 = comp("CTRL").layer("page").text.sourceText;

var message2 = comp("CTRL").layer("page2").text.sourceText;

if (message1 == ""){
thisProperty = [0,0]
} else {
thisProperty = [0,-20]

if (message2 !== "" and time > 7){

    thisProperty = [0,-100]

}
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines