Complementary Colours

Moderators: Disciple, zlovatt

Post Reply
Ed Smith
Posts: 19
Joined: October 22nd, 2007, 3:57 am
Location: Dublin, Ireland
Contact:

Looking for an expression to automatically generate complementary colours. So far I have this (below) but it's not working for me, and I can't figure out why.

Code: Select all

Col = thisComp.layer("LIGHT CONTROLLERS").effect("Color 001")("Color") ;
BitD = 32768;
R = Math.round(Col[0]*BitD);
G = Math.round(Col[1]*BitD);
B = Math.round(Col[2]*BitD);
A = Math.round(Col[3]*BitD);
[BitD - R,BitD - G,BitD - B,A]
Bascially I'm applying this expressioon to a fill effect on another layer to generate the complementary colour. Working in 16 bit, hence the 32768. I've applied the esxpression to a text layer and the results I'm getting I don't understand. I seem to be getting the correct answer mulitplied by 32768 for some reason but I can't see where I'm going wrong.

Any help?
It's not the dog in the fight, it's the fight in the dog that matters.
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

In scripting/expressions colours are always defined in the range 0.0-1.0
Ed Smith
Posts: 19
Joined: October 22nd, 2007, 3:57 am
Location: Dublin, Ireland
Contact:

After a few more discussions, and a few quick searches it was easier to convert to HSL and then invert the values that way to get the complementary colour. Used Filip Vanduerens solution from this this creative cow topic.

Code: Select all

c = thisComp.layer("master").effect("Fill")("Color"); 
hsl = rgbToHsl(c); 
hue = (hsl[0]+0.5)%1; 
compl = [hue, hsl[1], hsl[2], hsl[3]]; 
hslToRgb(compl);
It's not the dog in the fight, it's the fight in the dog that matters.
Post Reply