SampleImage Behaving Oddly
- March 29, 2023
- 3 replies
- 958 views
I can only categorize this as a bug, because it works except under the circumstances I'm about to describe.
I've got a comp set up to change the opacity of layers if they overlap with a PNG file resembling a mouse cursor (I'm re-creating a GUI). This is done by applying this to the layer I want to appear or disappear when the mouse passes over it:
L = thisComp.layer("Layer 2/Mouse Cursor.ai");
p = L.transform.position;
sampleImage(p,[.5,.5],true)[3] > 0 ? 100 : 0
This works flawlessly as long as the layer it's applied to is either an image file or an AE shape layer. When I try to apply it to a composition however, it doesn't work quite right.
In short--the layers don't light up individually when the mouse is over them. Instead, they light up when the mouse is nowhere near them.
See the attached AEP to see what I'm talking about (I also attached the PNG of the mouse cursor). I thought it might have something to do with the fact that several of the layers are scaled, but I've got one here that's not scaled at all and it behaves differently than the others. Then there's a basic shape layer that works exactly the way it's supposed to.
