ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

sourceRectAtTime& Text Tracking

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Claire Selim
sourceRectAtTime& Text Tracking
on Jun 23, 2020 at 1:11:46 pm

Hi all,

Thanks so much in advance for your time / any thoughts you can offer.

I'm looking to set up an easy to use template in After Effects and am trying to connect the values from a Tracking Animator applied to a text layer with the sourceRectAtTime() value from that text.

Essentially, I'm hoping to create a piece of text that always stays the same width (via tracking between the letters) across the screen, regardless of what that text is (without the tracking going below 0). A simple 4 letter word would fill the same width of the screen as a full sentence - the only difference being the tracking between the letters...

I've managed to link the two using duplicate layers and a slider control etc, but it isn't really fit for purpose. I can't get it to fix to a width - the best I can manage is a simple inverse relationship clamped to positive values.

Any help you can offer would be very much appreciated!
Thanks so much,
Claire


Return to posts index

Andrei Popa
Re: sourceRectAtTime& Text Tracking
on Jun 24, 2020 at 9:20:31 am

You can try this.
I used linear for the value because if I directly inserted the value, tracking would be set correctly but the text would not change.
Basically, what I did is measure the text at -1 time(outside comp, before tracking), and set tracking to change from 0 to the calculated value in the frame before zero.
For calculating the value, I divided the difference between actual size and desired size by the number of letters-1. Also, if the text is larger, the tracking stays at zero. If you want to change this, change last line to linear(time, 0 - thisComp.frameDuration, 0, 0, diff / numLetters)


actualWidth = sourceRectAtTime(-1, false).width;
desiredWidh = 250;
diff = desiredWidh - actualWidth;
numLetters = text.sourceText.value.split("").length;
diff > 0 ? linear(time, 0 - thisComp.frameDuration, 0, 0, diff / numLetters) : 0;


Andrei
My Envato portfolio.


Return to posts index

Andrei Popa
Re: sourceRectAtTime& Text Tracking
on Jun 24, 2020 at 9:23:29 am

Forgot to subtract the 1 from the letter number.


actualWidth = sourceRectAtTime(-1, false).width;
desiredWidh = 250;
diff = desiredWidh - actualWidth;
numLetters = text.sourceText.value.split("").length-1;
diff > 0 ? linear(time, 0 - thisComp.frameDuration, 0, 0, diff / numLetters) : 0;


Andrei
My Envato portfolio.


Return to posts index


Claire Selim
Re: sourceRectAtTime& Text Tracking
on Jun 24, 2020 at 11:33:41 am

Oh my goodness, that is brilliant!

Thank you so much for your help, that works perfectly!!

I wasn't even sure it could be done! Thank you so much Andrei, I really appreciate your help! Really kind of you.

Many thanks again,
Claire


Return to posts index

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