Copy link to clipboard
Copied
Is there a way to tell if the pixels of a layer are visible in a specific time?
Things like .width or .sourceRectAtTime will give the original dimensions of a layer, even if the opacity/scale is set to 0. But how to mesure what's actually visible in the screen?
I found sampleImage(), which might do the trick, but I honestly have no idea how to make it work, even after reading the documentation.
Thanks!
Copy link to clipboard
Copied
You can use opacity and scale to determan if a layer will theoretically be visible or not (if opacity > 0 and scale !=0 = layer visible). But this is not bullet proof, since a layer can also be not visbile due to countless effects and layer modes.
sampleImage() might be a better approach, but it kind of feels like you'll need to check every pixel in your comp and compare its value with the pixels of the layer. Tricky!
What is your use case?
*Martin
Copy link to clipboard
Copied
sourceRect gives you the size in layer space. So you need to convert the 4 corners to comp space taking into account the layer transforms and all the potential parenting. Unfortunately, scripting in contrast to expressions does not hav toComp transforms built-in. So there is not really an easy way to do that. Either you implement the transforms yourself, or you create a hack, where you create a layer with an expression to do the transform you need, read the result from the expression and delete the layer again.
Copy link to clipboard
Copied
sampleImage() is an expression function, are you building a script or an expression? And are you using transparent footage that may or may not be visible at certain points, or do you just want to check if a layer has opacity / the visibility toggle on?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now