-
Getting layers real bounds using sampleImage()
Hi, forum! I am trying to write an expression that will return a position of the pixel that is furthest to the left side (as an example) and alpha of its color is not equal to zero.
How I see the algorithm:
We have a “point” that is located at [0, 0]. We “move” that point down until it hits thisLayer.height ( [0, 1080] for example) and then we add +1 to x value and change y value to 0, so it becomes [1, 0] and so on until the “point” meets the first pixel that has non-zero alpha.I suggest this to apply on a point control:
x=[0, 0];do {
if (x[1]>thisLayer.height) {
x[0]=x[0]+1
x[1]=0 }
else x[1]++
}
while (thisLayer.sampleImage(x, [0.5, 0.5]/2, true, time)[3] == 0);x
but it gives error – “Timeout while waiting for the engine”.So is it possible to make it work?