ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Text follows logo

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Elizabeth Starr
Text follows logo
on May 18, 2020 at 5:44:10 pm

I have a version of this working properly that's on the opposite side of the screen, but for some reason, I can't get the left side version to work properly. I need the logo to follow the left-most character on line 2 as the line of text expands to the left. The text needs to line up flush right. What am I missing? I've attached the expression that works, but I can't get the logo to follow the second line.






var xDist = thisComp.layer("SText").sourceRectAtTime().width * +1;
var logoWidth = length(thisComp.layer("LOGOS NON TYPE FACE").transform.xPosition, thisComp.layer("LINE 2").transform.xPosition)-50;
(thisComp.layer("Ctrl").effect("Logo Selector")("Slider") == 7) ? xDist - logoWidth :xDist;


Return to posts index

Elizabeth Starr
Re: Text follows logo
on May 18, 2020 at 5:46:38 pm

I should have titled the subject of this post "Logo follows text"


Return to posts index

Robert Müller
Re: Text follows logo
on May 19, 2020 at 9:07:10 am

Okay, I dont really get what you are doing here. You have two text objects, one for each line, is that right? So if your logos position should be dependend on the second line, why are you measuring the width of the first line (and btw, multiplying by +1 does nothing, you can leave that out. Only -1 inverts the sign)? Why are you getting the distance between the logo and the second line and substract 50 from it? This is what I came up with as far as I understood:
var xDist = thisComp.layer("SText").sourceRectAtTime().width * -1;
var logoWidth = length(thisComp.layer("LOGOS NON TYPE FACE").transform.xPosition, thisComp.layer("LINE 2").transform.xPosition)-50;
(thisComp.layer("Ctrl").effect("Logo Selector")("Slider") == 7) ? xDist + logoWidth :xDist;

Its always a good tipp to mess around with the signs when switching directions in an expression.
But I think, again based on my understanding of the situation, it would be far easier to grab the position of your second line, subtract the width of the same layer and maybe add some padding (assuming your text is aligned to the right and the anchor point is on the right edge).


Return to posts index


Elizabeth Starr
Re: Text follows logo
on May 19, 2020 at 4:29:50 pm

I figured out how to do the left and right justified versions, but am now stuck on a center-justified version.

Line 2 is always centered. The logo follows the position of the Line 2 text and is stuck to the left side, but Line 2 + the logo should appear centered on the screen. There is a ctrl layer that has logos with a slider selector. When you type "7", there is no logo, so I need the Line 2 text to shift about 60 pixels to the left and recenter.

Right now, when I type into line 2, the text shifts over to the left and doesn't stay centered.

I am not sure what I'm doing wrong, but I also don't totally understand the coding and am experimenting to try and get the best result. I'm suspecting something is wrong with both my anchor point positions and some of the numbers I've plugged into the expressions.



Line 2 Null expression:

var xDist = thisComp.layer("LINE 2").sourceRectAtTime().width;
var logoWidth = length(thisComp.layer("LOGOS NON TYPE FACE").transform.xPosition, thisComp.layer("LINE 2").transform.xPosition+165);
(thisComp.layer("Ctrl").effect("Logo Selector")("Slider") == 7) ? xDist - logoWidth :xDist;


Logos expression:

textRect = thisComp.layer("LINE 2").sourceRectAtTime();
text_width = textRect.width;
text_left = textRect.left;

xOffset = +490;

x = text_left + xOffset;

[x]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]