ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Position value / rendered display mismatch when using sourceRectAtTime in position expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andrew Saunders
Position value / rendered display mismatch when using sourceRectAtTime in position expression
on Jun 21, 2018 at 12:16:52 pm

I am using the below code within expressions for the position and scale properties of a solid layer in order to auto offset / rescale its position / size. The idea is to resize and reposition a solid layer based on the global dimensions of a target text layer (a sort of advanced / dynamic parenting).

function getWorldDimensions(targetLayer) {
var tL = targetLayer
rect = tL.sourceRectAtTime()

topLeft = tL.toWorld([rect.left, rect.top])
topRight = tL.toWorld([rect.left + rect.width, rect.top])
bottomLeft = tL.toWorld([rect.left, rect.top + rect.height])
w = length(topLeft, topRight)
h = length(topLeft, bottomLeft)
return [w, h]
}


The function calculates the world-space dimensions of the target layer (i.e. the text layer), however when using the returned height value (h) within the rest of the expression I am getting this very strange result:



The bounding box points (and the returned position value as displayed in the layer dropdown) are drawing / calculating correctly but the actual rendering of the layer pixels themselves appears to be offset in the y-axis slightly. There are no other effects on the solid layer doing any other offsetting or resizing.

The problem goes away if I disable the scale expression and also (very strangely) if I then re-enable it (i.e. nothing has changed in my expression code but it now draws correctly).

The problem also doesn't seem to occur if the solid layer's anchor point is set at the top or bottom...

Can anyone else replicate this and do you have any idea why it might be happening? My first guess was this was a bug but perhaps more likely I am just using my expressions incorrectly and there's a better way to get a similar result..


Return to posts index

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