ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Switching layer opacity with color sampler.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Eddy van Mourik
Switching layer opacity with color sampler.
on Aug 7, 2018 at 12:59:57 pm

Hiya all,

I'm trying to make a layer visible when the color of the layer underneath matches a specified color.

I've put this in the opacity of said layer.

I don't get any errors but it never comes on either. Any feedback would be greatly appreciated.

sampleColour = effect("Color Control")("Color")

sourceLayer = thisComp.layer("Shape Layer 1 Comp 1");
sampleSize = [1,1];
samplePoint = transform.position;
colour = sourceLayer.sampleImage(samplePoint,sampleSize);

if(colour == sampleColour)100 else 0

Return to posts index

Dan Ebberts
Re: Switching layer opacity with color sampler.
on Aug 7, 2018 at 4:54:29 pm

I don't think comparing arrays will work that way. Try changing the last line to this:

if(colour[0] == sampleColour[0] && colour[1] == sampleColour[1] && colour[2] == sampleColour[2])100 else 0

For this to work though, it assumes that the colors are exactly the same and that the layer being sampled is comp-sized and centered.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved