ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# calculate complimentary colors from shape layer

FAQ   •   VIEW ALL
 calculate complimentary colors from shape layer on Feb 14, 2019 at 9:32:29 pm

hi all,

I have a comp with multiple lights and I'd like to be able to control the hues of the lights parametrically.
I can create a shape layer and a light, and use an expression to make the light color the same as the color of the shape layer.

What I'd like to do:

Make a spot light and an ambient light, and have the hues of these 2 lights always be opposite colors (180 degrees away in the HSL wheel), or something like that. eg, if the spot light is red, ambient light is cyan. As spot light moves toward yellow, ambient light moves toward blue.

This involves coercing the RGBA color of the shape layer to HSL, changing just the H value, then coercing back to RGBA.
I tried this but get error in line 1, "array piece can't expand to more than one value"

Anyone have syntax for making this work? thanks!!

```masterCol = (thisComp.layer("Shape Layer 1").content("Fill 1").color) ; hslCol = rgbToHsl(masterCol) ; hue = hslCol [1] ; sat = hslCol [2] ; lum = hslCol [3] ; newHue = hue + 180 ; newCol = [newHue,sat,lum] ; [hslToRgb(newCol)] ;```

 Re: calculate complimentary colors from shape layeron Feb 14, 2019 at 11:13:54 pm

Try it this way:

masterCol = (thisComp.layer("Shape Layer 1").content("Fill 1").color) ;
hslCol = rgbToHsl(masterCol) ;
hue = hslCol [0] ;
sat = hslCol [1] ;
lum = hslCol [2] ;
newHue = (hue + .5)%1;
newCol = [newHue,sat,lum,1] ;
hslToRgb(newCol);

Dan

 Re: calculate complimentary colors from shape layeron Feb 15, 2019 at 2:42:43 am

YOU ARE THE BEST

 Re: calculate complimentary colors from shape layeron May 5, 2020 at 9:30:23 pm

Another question concerning this is how to calculate real complementary colors in AE in general. To shift the H value 180 degrees is not what the eye feels as complemantry, i guess.
The adobe color tool (https://color.adobe.com/de/create/color-wheel) uses this colorwheel, and when you set a hue of 1, the complemantry hue is 137, (and not 180)
So my question, is there a way to calculate complemantary colors inside AE.
And if not, does anyone know of a way to calculate these complemantry hues manually, or also triade hues?