Using Expressions to compare sampled Colors.
In simple terms, I'm trying to compare a color that is pulled using the sampleImage() function, to a variable with a specific HEX value stored in it.
My scene has a composition in it that has several different colored "swatches" in the same position, separated by frames. So I can scrub the timeline and see if the changes to those colors will trigger the changes I need in the expression.
I'm using a series of if statements, and the if's always fail. Since AE has no variable "tracing", I'm using some text fields to display the value of these variables. I think I discovered why it's not working but it's completely unclear as to the cause.
I have a reference text field, displaying the value of this function:
hexToRgb("0x1B10DD");
The first value it displays reads:
0.10588235294117647
Then I have some basic test code on another text field layer:
var swatchComp = thisComp.layer("Color Swatches Pre-comp 1");
swatchComp.sampleImage([5,5],[1,1],false);
And its value reads:
0.10588236153125763
They should be the exact same value!
If this doesn't work, there's no way my if statements are going to work at all. Btw, I tried adjusting sampleImage to read the value before / after effects (e.g. false or true), no effect.
Appreciate any thoughts.
