Copy link to clipboard
Copied
Hi all, I've seen tons of tutorials on how to have the shape layer auto resize around the text, but I can't seem to find a tutorial for the text that auto-resizes based on the shape. The few tutorials I've found didn't work for some reason, I swear I re-verified the expressions so many times. Can anyone help? the shape is a circle by the way.
A scale expression like this should size the text to fit the circle:
d = thisComp.layer("Shape Layer 1").content("Ellipse 1").content("Ellipse Path 1").size[0]; // circle diameter
r = sourceRectAtTime(time,false);
w = r.width;
h = r.height;
angle = Math.atan2(h,w);
wNew = d*Math.cos(angle); // desired text width
sf = wNew/w; //scale factor
[sf,sf]*100
Copy link to clipboard
Copied
A scale expression like this should size the text to fit the circle:
d = thisComp.layer("Shape Layer 1").content("Ellipse 1").content("Ellipse Path 1").size[0]; // circle diameter
r = sourceRectAtTime(time,false);
w = r.width;
h = r.height;
angle = Math.atan2(h,w);
wNew = d*Math.cos(angle); // desired text width
sf = wNew/w; //scale factor
[sf,sf]*100
Copy link to clipboard
Copied
How can I use it please help me
Copy link to clipboard
Copied
If you have a circle shape layer and a text layer, you would apply the expression to the text layer's scale property and it should scale the text so that it will just fit inside the circle. That's all it does.
Copy link to clipboard
Copied
If you also wanted to automate centering the text on the circle, you could use a position expresion like this for the text layer:
L = thisComp.layer("Shape Layer 1");
r1 = L.sourceRectAtTime(time,false);
c1 = L.toComp([r1.left + r1.width/2,r1.top + r1.height/2]);
r2 = sourceRectAtTime(time,false);
c2 = toComp([r2.left + r2.width/2,r2.top + r2.height/2]);
delta = c2 - c1;
value - delta
Find more inspiration, events, and resources on the new Adobe Community
Explore Now