ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Shape size auto-adjust to text - excluding text descenders!

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Stephen Wiseman
Shape size auto-adjust to text - excluding text descenders!
on Feb 6, 2017 at 11:18:50 am

Hi all

I'm designing some video brand assets for a client and as they have little knowledge of after effects it needs to be simple for them to use. With this in mind I have designed an orange "tab" (as per their branding) that sits next to text and which adjusts automatically to text height when they type something in. The tab is simply a rectangle shape layer. This works fine but they are very specific about their branding and the tab needs to stop at the baseline of the text and not include in it's height any descenders (hang bits on y's, p's etc).

I can't for the life of me think of anything to add to my expression that will do this but maybe someone knows an answer? I thought about deducting so many pixels or percentage from the height but if there are no descenders in their text then the shape will not match the baseline.

Any help would be appreciated, expressions attached below

Size expression on Rectangle path:

theTextLayer = thisComp.layer("TITLE - EDIT ME");
theTextRectInfo = theTextLayer.sourceRectAtTime(time);
theWidth = 60;
theHeight = theTextRectInfo.height;
[theWidth,theHeight]

Postion expression on rectangle path:

theTextLayer = thisComp.layer("TITLE - EDIT ME");
theTextRectInfo = theTextLayer.sourceRectAtTime(time);
theX = 0;
theY = theTextLayer.toComp([0,0])[1] - (theTextRectInfo.height/2);
[theX,theY]


Return to posts index

Kevin Camp
Re: Shape size auto-adjust to text - excluding text descenders!
on Feb 6, 2017 at 8:21:14 pm

maybe try a layer as a track matte for the tab...?

if you position the track matte on the baseline of the text, i think it would work.. you could even parent that track matte to the text layer in case they decide to reposition the text.

or, since you are likely using a shape layer as the tab, you might be able to add another rectangle path to that tab, and use 'merge paths' to subtract one from the other...

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Kevin Camp
Re: Shape size auto-adjust to text - excluding text descenders!
on Feb 6, 2017 at 10:04:40 pm

you could also try linear wipe, you just need to link the completion to the y-position relative to the comp height:

target = thisComp.layer("TITLE - EDIT ME");
100 - ( 100 * target.position[1] / thisComp.height );

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

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