Copy link to clipboard
Copied
Hi,
Is there any way to have an expression so the null layer follows the text range selector x and y position even when we have multiple lines of text?
Thank you in advance.
Copy link to clipboard
Copied
I have seen what Dan did a few years ago when expression provides tracking position on X-axis but I can not figure out how this expression could be adjusted to follow position on Y-axis as well so it could be used for multiple lines text. Thank you in advance for any help. This is old Dan's expression wor X position :
L = thisComp.layer("Your Text Layer");
gotIt = false;
for (i = thisComp.width; i >= 0; i--){
temp = L.sampleImage([i,thisComp.height/2],[0.5,thisComp.height/2],true,time);
if (temp[3] > 0){
gotIt = true;
break;
}
}
if (gotIt)
[i + width/2,L.transform.position[1]]
else
L.transform.position + [width/2,0]
Copy link to clipboard
Copied
Works no different for the Y position, so I'm not clear what specifically you are having difficulty with. Of course the expression might benefit from smartening it up by adding internal string processing to have a safety to determine whether or not something is actually on a new line, but otherwise you only need to duplicate the relevant lines that reference X axis and width parameters and refactor them to scan in Y direction and height.
Mylenium
Copy link to clipboard
Copied
Thank you Mylenium.
I will try that.
Copy link to clipboard
Copied
I am still trying to figure this one out. I am able to adjust Dan's code to follow Y-axes but I am unable to make it work to follow x and y at the same time. Is this possible? I would like when for example the second line of text appears my null (which is run by expression) moves down and to the left so it starts following alpha information of that row. Thanks in advance.
I was trying to modify Dan's script for x and y but I am getting an error message and I am not sure if this is the right approach. This is that (not working) code.
Copy link to clipboard
Copied
AFAIK, this is not possible, in an elegant manner, with current constructs. What you can do is to, internally, deconstruct the text into individual lines but before that, you will have to set the Based On property to Characters. And priorly, you will have to calculate the total number of characters for the text string. And then find out which row the current/active text characters appears within. And the list goes on ... .
There is obviously quite a fair bit of work to be done. Perhaps a quicker algorithm is viable if you stated clearly what it is that you are trying to achieve.
Copy link to clipboard
Copied
Thank you Roland,
What I am trying to do is to build a template with range selector/opacity text reveal where still image of the hand will trace the text reveal. So I was thinking if we are able to get the position value of the range selector and provide that information to the hand that will be exactly what will work for this template. Thank you in advance.
Copy link to clipboard
Copied
You can pull the length of a line of text using sourceRectAtTime().
The Range Selector can be set to use a percentage.
The distance the hand moves can be calculated by using the start and end values.
If you read the current position of the hand layer as a percentage of the total distance traveled and you combine that with the width of the text layer, you should be able to drive the percentage of the range selector end value by that number and get the opacity to follow the movement of the hand in a straight line. You would have to subtract the width of the hand to get the edge to line up, but the math should be fairly simple.
If you need to adjust the movement of the hand layer to cover the text that involves another expression. The easiest approach would be to animate the movement of the hand and then just calculate the percentages and offset and let the range selector follow the movement.
This would work with a single line of text. If you have multiple lines of text then the position of the hand becomes much more difficult to calculate, but it could probably be done as long as the lines of text were all about the same length.
I don't have the time to fiddle with it now, but if I get some free time I might take a stab at it later.
Copy link to clipboard
Copied
Turned out not to be that difficult.
Without taking into account the position of each layer all you need is this:
txtWidth = thisLayer.sourceRectAtTime().width;
txtStart = (thisComp.width/2) - (txtWidth / 2);
handLyr = thisComp.layer("Hand");
xPos = handLyr.position[0];
xCover = (xPos - txtStart) / txtWidth;
wipePos = xCover * 100;
wipe = wipePos - 4 // padding for hand layer
if (wipe < 0){
Start = 0;
}
else{
Start = wipe;
}
The comp looks like this:
All that is left is to add in some compensation for the position of the text layer and replace my placeholder rectangle with an image of a hand.
If you have multiple lines of text and you have created the proper path for your hand layer you can divide the sourceRectAtTime().height by the number of lines and work out the percentages so that the wipe follows the text reveal. It's just a little more fiddling.
Making the motion path of the hand layer follow the progression of the text animator would involve the same kind of thinking but a little more math. You would also have to retrieve the position of the text box. The general idea is the same. Maybe I'll try and figure that one out later.
Copy link to clipboard
Copied
Thank you so much, Rick. This is great. Thank you for your time and your help.
All the best.
Copy link to clipboard
Copied
This is great Rick thank you so much.
Copy link to clipboard
Copied
Yes, use this expression on the Null’s position to follow the text range selector across multiple lines:
txt = thisComp.layer("YourTextLayer");
anim = txt.text.animator("Animator 1").selector("Range Selector 1");
x = txt.sourceRectAtTime().left + txt.sourceRectAtTime().width * (anim.start + anim.end) / 200;
y = txt.sourceRectAtTime().top;
txt.toComp([x, y])
Make sure to adjust the YourTextLayer and selector names according.