Copy link to clipboard
Copied
This is a pretty basic question. I have 1 text layer to which I added 2 keyframes on the scale property. I need to record its width and height at each key index. It is point text (although eventually I will need to figure out how to do this with box/allocated text as well).
so I have
if (layer.property("Scale").isTimeVarying){
for (var i = 1; i <= layer.property("Scale").numKeys; i++){
alert(layer.sourceRectAtTime(layer.property("Scale").keyTime(i), false).width);
}
}
unless I'm missing something, if I have transformed the layer's scale between keyframes, I should be getting different values in my alerts, but I don't. Am I misunderstanding something about how sourceRectAtTime works, or is this something unique to text layers, or...?
The result is always expressed in the (text) layer coordinates system. It is independant of the scale and other transform parameters.
If you need to get the result expressed in comp system, you'll need to find your way.
In CC2014 and later there is this useful method : myLayer.sourcePointToComp(position_of_some_point_in_layer_system) which gives the result immediately.
Xavier
Copy link to clipboard
Copied
The result is always expressed in the (text) layer coordinates system. It is independant of the scale and other transform parameters.
If you need to get the result expressed in comp system, you'll need to find your way.
In CC2014 and later there is this useful method : myLayer.sourcePointToComp(position_of_some_point_in_layer_system) which gives the result immediately.
Xavier
Copy link to clipboard
Copied
Thanks for that. I remember seeing that as a new feature when CC 2015 came out but didn't compute at the time that I could extrapolate dimensions from it.
For what it's worth, what I ended up doing (for point and paragraph text) was taking the sourceRectAtTime/boxTextSize, storing the scale value of each keyframe, and
(layer source width or height * keyframed scale value) / 100
Find more inspiration, events, and resources on the new Adobe Community
Explore Now