Activity › Forums › Adobe After Effects Expressions › Expression to Compare two effects “Color Control”
-
Expression to Compare two effects “Color Control”
Posted by Tiago Cav on December 8, 2015 at 9:00 pmMy project have a layer with two effects “Color Control”,
I want to create a condition which compare two colors,
and if the colors are equals,
“Color Control 1” is black color.
“Color Control 2” keep color.Tiago Cav replied 10 years, 5 months ago 2 Members · 6 Replies -
6 Replies
-
Dan Ebberts
December 8, 2015 at 9:29 pmExactly equal? Something like this applied to Color Control 1 should work:
c = effect(“Color Control 2”)(“Color”);
if ((c[0] == value[0]) && (c[1] == value[1]) && (c[2] == value[2]))
[0,0,0,1]
else
valueDan
-
Tiago Cav
December 9, 2015 at 12:43 am(Updated)
One more thing;
I need to propose something more daring.
Could determine half range of the same color (such as all Red variations, for example), for all #seven colors (Red; Violet; Blue; Cyan; Green; Yellow; Orange)?In other words,
a division between Light and Dark in each color separately.If “Color Control 1” is a color, (Red for example), Dark Red; #cc0000 rgb(204, 0, 0)
and
“Color Control 2” is a variation of Dark Red; #990000 rgb(153, 0, 0)“Color Control 1” = black; “Color Control 2” keep color.
Another condition which result is the same:
If “Color Control 1” is Light Red; #ff8080 rgb(255, 128, 128)
and
“Color Control 2” is a variation of Light Red; #ff4d4d rgb(255, 77, 77)And:
If “Color Control 1” is dark and the “Color Control 2” is light (or inverted) variation of the same color (which can be #seven colors), keep color in “Color Control 1” and in “Color Control 2”.Thanks. I want to know, at least, if all this is possible.
-
Tiago Cav
December 10, 2015 at 1:12 amI got some interesting results with an expression that I created rapidly using the color red. I could go on, but it would be a very complex work, and results might be satisfactory, however, I would find many problems because of having to combine the three color channels extensively for simple colors.
Just one more thing:
When you asked me about the color be exactly the same; this suggests that After Effects might make an mode recognize colors within its range where a non-accurate color could be considered the same (of the same family)?
Thanks.
// TEST RED COLORc = effect("Color Control 2")("Color")
if ((clamp(c[0]*2, 0,2) >1 && clamp((value[0]*2),0,2) >1) || (clamp(c[0]*2, 0,2) <1 && clamp((value[0]*2),0,2) <1))
[0,0,0,1]
else
value -
Dan Ebberts
December 10, 2015 at 1:21 amThe reason I asked about being exactly equal is that == will only return true if the values are exactly the same. Otherwise, you would need to check for values within a certain range.
I don’t know if it would help, but you might want to switch your RGB colors into HSL color mode (using rgbToHsl()), where it would be (I assume) easier to check for reds, for example.
Dan
-
Tiago Cav
December 10, 2015 at 1:36 amI understand, Good observation, HSL can be better for this.
Now that You taught me the base to work with colors, I can develop over that.
You’ve helped enough, thanks again.
Reply to this Discussion! Login or Sign Up
