ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

sourceRect text layers which play off each other.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chris Meadmore
sourceRect text layers which play off each other.
on Jul 2, 2019 at 9:41:53 am
Last Edited By Chris Meadmore on Jul 2, 2019 at 9:44:36 am

Hi,

I'm using sourceRect.time to scale a text layer to a specific width. Works great.

Now I have 2 layers which have the same expression applied and I'm trying to rig them off each other. So:

Layer A scales to designated width unless Layer B is smaller in which case follow that.

I've almost got it working with one layer, it scales itself depending on length but also monitors the other layer and adjusts accordingly. When I apply this same expression to the other layer it doesn't work.

Is there a way to do this without introducing extra layers / Nuls?

Thanks for any help! Kinda urgent :D

textwidth = thisLayer.sourceRectAtTime().width;
s = 100*1700/textwidth;
b = thisComp.layer("Layer A").transform.scale;

if(s < 100) [s,s] else b;


Return to posts index

Chris Meadmore
Re: sourceRect text layers which play off each other.
on Jul 2, 2019 at 9:51:37 am

Oops... think I solved it on my own. Just needed a smoke break!

a = thisLayer.sourceRectAtTime().width;
b = thisComp.layer("Layer A").sourceRectAtTime().width;
c = 100*1700/a;
d = 100*1700/b;

if(a > b) [c,c] else [d,d];


Return to posts index

Chris Meadmore
Re: sourceRect text layers which play off each other.
on Jul 2, 2019 at 9:56:01 am

Never mind, still not solved.

The layers are playing off each other perfectly but I need to cap them at 100% so they don't scale beyond that.


Return to posts index


Scott McGee
Re: sourceRect text layers which play off each other.
on Jul 2, 2019 at 10:20:59 am

There's probably a better way.

You can clamp your scale to not go above 100 for example.

s = clamp(c,0,100);

[s,s]


Return to posts index

Chris Meadmore
Re: sourceRect text layers which play off each other.
on Jul 2, 2019 at 11:17:37 am

Thanks Scott!

I've brought a coder into the mix and he produced the below expression which worked perfectly although we're now struggling with trying to apply it to 3 layers and find the max value from them.

Any ideas how to do this? Thanks so much for the help!

Layer1Width = thisComp.layer("LINE_01").sourceRectAtTime().width;
Layer2Width = thisComp.layer("LINE_02").sourceRectAtTime().width;


Layer1Ratio = 100 * 1700 / Layer1Width;
Layer2Ratio = 100 * 1700 / Layer2Width;

Layer1Ratio = Layer1Ratio > 100 ? 100 : Layer1Ratio;
Layer2Ratio = Layer2Ratio > 100 ? 100 : Layer2Ratio;

if(Layer1Width > Layer2Width ) [Layer1Ratio, Layer1Ratio] else [Layer2Ratio, Layer2Ratio];


Return to posts index

Andrei Popa
Re: sourceRect text layers which play off each other.
on Jul 2, 2019 at 11:32:53 am

So you try to go for the largest layer, but not over 100?

Layer1Width = thisComp.layer("LINE_01").sourceRectAtTime().width;
Layer2Width = thisComp.layer("LINE_02").sourceRectAtTime().width;
Layer3Width = thisComp.layer("LINE_03").sourceRectAtTime().width;

LayerRatio = 100 * 1700 /Math.max( Layer1Width, Layer2Width, Layer3Width);
(LayerRatio<100) ? [LayerRatio, LayerRatio] : [100,100];


You can put however many layers you wish.

Andrei
My Envato portfolio.


Return to posts index


Chris Meadmore
Re: sourceRect text layers which play off each other.
on Jul 2, 2019 at 11:53:39 am

That is PERFECT!

Thank you


Return to posts index

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